Game Development Community

How to set a timeout to call a function.

by Peterjohn Griffiths · in Torque Game Engine · 08/10/2006 (11:58 pm) · 9 replies

Hi,
Bit of a Noob here with Torque and have got stuck trying to find how to set a timed call to a function.
Anyone know how to do this?.
Is it possible to do in script or will I need to code it into the engine.
Many thanks.

#1
08/11/2006 (12:20 am)
I am not 100% on this, as I have not had to do it yet. But I believe you need to SCHEDULE the command.
#2
08/11/2006 (12:29 am)
"schedule" is your friend. As this is the public area, I'm not sure if allowed to post the exact parameters - so I don't do it here.
#3
08/11/2006 (12:33 am)
Schedule is a script command so its fair game here, Only the C++ source cant be shared here
#4
08/11/2006 (12:44 am)
Just search about this point and it seems ok to post here the syntax.

@Peterjohn: schedule(millisecs, eventDependsOnThis, functionname, [arg1, arg2 . . . ])
#5
08/17/2006 (7:51 pm)
Thank you all.
I am a SDK owner. Should I be posting questions in the non public area's about scripting instead?.
Thought this was the best place.
Thanks again for the solution.
#6
08/17/2006 (10:11 pm)
Scripting questions are OK in the public area, only questions specific to the C++ part of the engine are private. By putting it in the public area, you might help out folks that are evaluating the engine before purchasing it by having this answer available to them.

But then, I don't work for GG so that last part is just my opinion.
#7
08/19/2006 (5:45 pm)
I have tried to schedule the calling of a function but it happends straight away and not 4 seconds later.
Schedule(4000, 0, PlayNextDemoCall());
Anyone got any idea why?.
#8
08/19/2006 (5:53 pm)
Try using:
Schedule(4000, 0, "PlayNextDemoCall");


The best bet when learning the engine is take a look at the exsiting code. If you use a program like ultraedit you can search your entire project for schedule calls you will see exactly how they are formatted.
#9
08/19/2006 (9:18 pm)
Thanks Peter, that works a treat and also solves another problem.
:)