[16 Sep 2010] is Timeout running?

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
User avatar
lazi
Posts: 552
Joined: Thu Feb 24, 2011 11:08 pm

[16 Sep 2010] is Timeout running?

Post by lazi »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 16 Sep 2010 21:32:46 +0200

Hello!

In a game I use SetTimeout() for random action. If the user exits to the game the running timeout should be cancelled. If I use ClearTimeout() when the timeout is finished already then I got an error. I can't check Timeout with GetAttribute if it is finished.

I made a workaround like this:

Code: Select all

SetTimeout(10,Function() EndFunction,1)
However I think it would be more useful if ClearTimeout() just ignore if the given timeout is not running.

User avatar
airsoftsoftwair
Posts: 4318
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[17 Sep 2010] Re: is Timeout running?

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 17 Sep 2010 21:06:20 +0200
Hello!

In a game I use SetTimeout() for random action. If the user exits to the game the running timeout should be cancelled. If I use ClearTimeout() when the timeout is finished already then I got an error. I can't check Timeout with GetAttribute if it is finished.

I made a workaround like this:

SetTimeout(10,Function() EndFunction,1)

However I think it would be more useful if ClearTimeout() just ignore if the given timeout is not running.
You can achieve this by simply enclosing the ClearTimeout() call in this clause:

Code: Select all

ExitOnError(False)
ClearTimeout(...)
ExitOnError(True)
This will never fail :)

Locked