Game Development Community

Stopping a Schedule

by Matt "Mr. Pig" Razza · in Torque Game Engine · 09/16/2006 (7:02 am) · 7 replies

I always thought that doing $schduleID.delete(); would stop the schedule from being processed. It doesn't seem to be working however. Anyone know how to stop a schedule?

Example:
function Start()
{
$id = schedule(100, 0, stop);
}

function stop()
{
if (isObject($id))
$id.delete();

//do stuff
}

function thisMayBeCalledBeforeTheSchduleTimeIsUp()
{
stop();
}

If I call "thisMayBeCalledBeforeTheSchduleTimeIsUp()" the old schdule ($id) will call stop again when the time runs out. (Even removing the isObject() check failed to work).

[EDIT]
It seems $id will track the schedule (and I can stop it) only once. I can not assign another schedule to the same var. Wierd...

#1
09/16/2006 (7:21 am)
Use cancel( $id ).
#2
09/16/2006 (7:27 am)
Ah, thanks.
#3
09/16/2006 (7:29 am)
Would isObject() check if it's started?
#4
09/16/2006 (9:00 am)
Also, a global variable named "$id" is probably not great naming. Chances are, some other piece of code wants to use that name, too, for something else. Name it something like "$playerCheckId" or "$bombTimeoutId" or whatever the schedule task is actually for.
#5
09/16/2006 (9:40 am)
It was just an example...
#6
09/16/2006 (11:19 am)
IsEventPending()

is a function for schedules.. you can use that to see if it's an active schedule or not.
#7
09/16/2006 (8:17 pm)
Thanks.