Game Development Community

Schedule issue

by Howard Dortch · in Torque 3D Professional · 10/05/2012 (12:08 pm) · 4 replies

I have a schedule running using

%this.schedule(2000,run,%obj);

I tried to cancel the schedule using the object name as in cancel(pump.schedule) but it keeps running. Can someone tell me how to cancel this type of schedule?

#1
10/05/2012 (12:26 pm)
Quote:
void cancel

cancel(eventId)

void cancelAll

cancelAll(objectId): cancel pending events on the specified object. Events will be automatically cancelled if object is deleted.

$theSchedule = %this.schedule(2000, "run", %obj);

cancel($theSchedule);
cancelAll(%this.getId());

I've not tried cancelAll() - it might be 1.2 only - but do use cancel() in 1.1;
#2
10/05/2012 (1:08 pm)
Well the issue there is I use a single run function for all the pumps so I can't use a global like that otherwise it would cancel the run on all 4 objects.
The setup is like so:

function WaterPump::Run(%this,%obj)
{
bla...
%this.schedule(2000,Run,%obj);
}

I need to selectively kill one of the pumps via cancel
#3
10/05/2012 (2:04 pm)
function WaterPump::Run(%this, %obj)
{
   bla...
   %obj.runSchedule = %this.schedule(2000, Run,%obj);
}

later...

cancel(%obj.runSchedule);
#4
10/05/2012 (2:29 pm)
That works, thanks. Seems rather redundant tho....