Page 1 of 1

[16 Sep 2010] is Timeout running?

Posted: Sat Jun 13, 2020 5:32 pm
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.

[17 Sep 2010] Re: is Timeout running?

Posted: Sat Jun 13, 2020 5:32 pm
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 :)