Game Development Community

OnTimer() enhancement

by Alex Rice · in Torque Game Builder · 10/02/2006 (9:34 pm) · 4 replies

I am adding this to every onTimer callback that I am implementing

function Myt2dSceneObject::onTimer( %this ) 
{   
   if( $LevelEditorActive )
   {
      %this.setTimerOff(); 
      return;
   }
// ...
}

#1
10/03/2006 (10:43 pm)
The reason why some of the callbacks are called regardless of whether you are currently in the level builder or not is to allow people to make enhancements to the level builder and take advantage of them.

There is probably an easier way to disable it, though. I assme you're calling setTimerOn in an onAdd callback. If onLevelLoaded won't do it for you, you could just check if you're in the level builder before you call setTimerOn.
#2
10/03/2006 (10:49 pm)
Thomas, OK that makes sense- I didn't think of extensibility of the level builder.

The problem is I am calling setTimerOn in onLevelLoaded() then test my level and I click the stop button to return to the level builder, yet my timers keep firing causing a strange game state, various errors, so I have to quit out of TGB.

Seems like a lot of your typical TGB users might run into the same problem. I am just speculating though.
#3
10/03/2006 (10:54 pm)
Two additional ways It seems you could do it... onLevelEnded() you could setTimerOff()...


Also you could do something like this...

function t2dSceneObject::onTimer(%this)
{ 
   echo("t2dSceneObject::onTimer()");
}

function classOne::onTimer(%this)
{
   Parent::onTimer(%this);
}
#4
10/03/2006 (10:57 pm)
OnLevelEnded(). Thanks I didn't realize there was such a callback- I will just use that instead.