Setting timers with tgb
by webster07tgb · in Torque Game Builder · 03/23/2007 (11:41 am) · 2 replies
Just wondering if anybody knows how to create script for a timer, for example, to get give the user 15 seconds to answer a question.
also how to keep a running score throughout different levels.
any feedback is greatly appreciated, thanks.
also how to keep a running score throughout different levels.
any feedback is greatly appreciated, thanks.
#2
The 'timer' will continue to run, until you call SetTimerOff, if I remember correctly -- where as schedules, I believe have to be explicitly re-generated in the 'timer' callback
Both have there uses -- and they are more or less, the same thing ... they use the same 'code' internally to pull it off, the only difference really is that one generates an object-level callback, and the other calls the function passed in ...
03/23/2007 (12:00 pm)
@Ryan, there are various ways to create a timer -- schedules are one, and at an object-level you can call %obj.setTimerOn(300) and this will generate an onTimer() callback for that object --%obj = new t2dSceneObject() { class = "myClass"; };
%obj.setTimerOn(300);
function myClass::onTimer(%this)
{
warn("Timer Ticked ...");
}The 'timer' will continue to run, until you call SetTimerOff, if I remember correctly -- where as schedules, I believe have to be explicitly re-generated in the 'timer' callback
Both have there uses -- and they are more or less, the same thing ... they use the same 'code' internally to pull it off, the only difference really is that one generates an object-level callback, and the other calls the function passed in ...
Torque 3D Owner Eric Armstrong
Bloody Tongue Games
function countDown(%time) { %time = %time - 1; if(%time == 0) { timeRanOut(); } else { schedule(1000, "countDown", %time); } }The above is not checked for syntax, but should give you the idea... To start the timer, you would just call countDown passing in the starting value in seconds...