Disabling timers
Superdude2411
23 Mar 2018, 12:28As far as I can tell it's either impossible or really tedious and difficult to disable a timer before it's finished.
So I have 2 questions:
A. If the "disable timer" script doesn't actually make the timer stop before it's finished, what is even the point of it? If it has to wait until the timer is finished, then by that point the timer won't be ticking anymore anyway because it will have already finished. The timer disables itself after it's finished, so why doesn't the "disable timer" script actually disable the timer before it's finished?
B. Is there an easier solution to disabling a timer before it's done its thing? Or at least a more concise way of explaining how to do it?
Please help.
The Pixie
23 Mar 2018, 13:31One way would be to let the timer finish, and then have the code check if it should run of not (i.e., do not run if it is disabled).
J_J
23 Mar 2018, 13:43Is it possible you are disabling the timer before the timer has started running? When I use timers it allows me to stop the timer mid cycle as long as the timer has already started. For example I have a timer that every 30 seconds sends a message to the player. If I disable the timer it stops sending messages (no matter how many are left in the sequence). But, if the timer is disabled before the first 30 seconds (so the timer hasn't actually started yet) the disable timer doesn't work.
Could you maybe give a more specific example of the issue so we could see if there is a way to work around your problem?
mrangel
23 Mar 2018, 13:57Does Quest really not test if a timer is enabled before running its script? That seems a little weird. But you could disable a timer by setting the script to destroy (this.name)
, or just a script that does nothing.
Or delete the timer instead of disabling it.
If you want to disable a timer and then enable it later:
- Not sure if this works; have looked at the code, but not actually tested it myself
- A timer doesn't know how much time it has remaining. When you create it, it calculates the time it should go off at and stores that. So disabling and enabling a timer cannot pause it; it will restart it instead. (setting
timer.enabled = true
should make it go off as if it hadn't been disabled)
Not sure if the code is broken in some way I can't see, but if you were hoping that disabling a timer would pause it, try this:
<function name="PauseTimer" parameters="timer">
timer.enabled = false
timer.interval = timer.trigger - game.timeelapsed
</function>
(you can then use EnableTimer to restart it again)
jmnevil54
24 Mar 2018, 00:56Hm? I've never had any trouble with the DisableTimer function...
Could we see the code?

K.V.
24 Mar 2018, 18:07In this example game, everything works as it should.
The timer does nothing.
<!--Saved by Quest 5.7.6606.27193-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Timers">
<gameid>6fda4dd3-55bf-4ec3-9963-153a1df506ad</gameid>
<version>1.0</version>
<firstpublished>2018</firstpublished>
<start type="script">
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<firstenter type="script">
DisableTimer (timer1)
</firstenter>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<timer name="timer1">
<interval>10</interval>
<enabled />
<script>
msg ("timer1")
</script>
</timer>
</asl>
If you'd like to see it with a TEST command, in this example, the message will print if the player does not enter TEST before 10 seconds:
<!--Saved by Quest 5.7.6606.27193-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Timers">
<gameid>6fda4dd3-55bf-4ec3-9963-153a1df506ad</gameid>
<version>1.0</version>
<firstpublished>2018</firstpublished>
<start type="script">
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<command name="test_cmd">
<pattern>test</pattern>
<script>
if (timer1.enabled) {
msg ("You have disabled the timer.")
DisableTimer (timer1)
}
else {
msg ("The timer is already disabled.")
}
</script>
</command>
<timer name="timer1">
<interval>10</interval>
<enabled />
<script>
msg ("timer1")
</script>
</timer>
</asl>