SetTimout with Quest 5.9 #1549
Replies: 2 comments 3 replies
-
Hello. I can't seem to find a function to return a list of timers, but this might be a little help. To test things, I put this in the start script to create two unnamed timeouts: SetTimeout (1000) {
msg ("foo")
}
SetTimeout (2000) {
msg ("bar")
} Now, while the game is running, in the debugger under Timers, I see those have been automatically named "timeout" and "timeout1": So, if I want to call their scripts (and they will self-destruct after their scripts run): do (timeout, "script")
do (timeout1, "script") Or to just disable them: timeout.enabled = false
timeout1.enabled = false Or to completely destroy them without running them: destroy ("timeout")
destroy ("timeout1") I don't see a built-in way to get a list of timeouts. So, you'd have to know how many timeouts like this are in the game to be able to write a script to do one of the three things above to all of them at once. ...or I just wrote this function: <function name="AllGenericTimeouts" type="objectlist"><![CDATA[
timeoutList = NewObjectList()
first = GetTimer("timeout")
if (not first <> null) {
return (timeoutList)
}
list add (timeoutList, first)
i = 100
while (i > 1) {
i = i - 1
mytimeout = GetTimer("timeout" + i)
if (mytimeout <> null) {
list add (timeoutList, mytimeout)
}
}
return (timeoutList)
]]></function> If there are more than 100 timeouts in the game, change the line That function will return an object list of every timer in the game with a name beginning with To run them all: allGenericTimeouts = AllGenericTimeouts()
if (ListCount(allGenericTimeouts) > 0) {
foreach (gt, allGenericTimeouts) {
do (gt, "script")
}
} To disable them all: allGenericTimeouts = AllGenericTimeouts()
if (ListCount(allGenericTimeouts) > 0) {
foreach (gt, allGenericTimeouts) {
gt.enabled = false
}
} To destroy them all: allGenericTimeouts = AllGenericTimeouts()
if (ListCount(allGenericTimeouts) > 0) {
foreach (gt, allGenericTimeouts) {
destroy (gt.name)
}
} https://docs.textadventures.co.uk/quest/functions/#timers-and-turnscripts |
Beta Was this translation helpful? Give feedback.
-
Is this
better than
? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to immediately trigger any active timers created through SetTimeout? My game is filled with a bunch of nameless timers created in this way, and I was hoping to give the player a function that would skip the waiting period.
Beta Was this translation helpful? Give feedback.
All reactions