Game Development Community

C++ schedule method?.

by Peterjohn Griffiths · in Torque Game Engine · 09/18/2006 (5:54 pm) · 10 replies

Hi,
I havn't touched C++ in a long time and I want to schedule the calling of a function 1 second later.
In torque script I would use
//Schedule(millisecs, eventDependsOnThis, functionname)
Schedule(1000, 0, "PlayNextDemoCall");
I have tried google and the like but can't find what i'm after.
Many thanks

#1
09/18/2006 (6:20 pm)
Try checking simBase.cc for
ConsoleFunction(schedule, S32, 4, 0, "schedule(time, refobject|0, command, )")
and
ConsoleMethod(SimObject,schedule, S32, 4, 0, "object.schedule(time, command, );")

Also, look in simBase.h for SimEvent:
Quote:
/// Sim provides an event queue for your convenience, which
/// can be used to schedule events. A few things which use
/// this event queue:

You won't find the information on google because google shouldn't be able to index the source to torque, anywhere, ever :-)

Gary (-;
#2
09/18/2006 (7:12 pm)
I thought this would be a c++ native function?.
#3
09/18/2006 (7:17 pm)
Schedule a SimEvent. You'll have to subclass it appropriately, of course. schedule uses SimConsoleEvent, which is a subclass of SimEvent.

(Of course - easiest thing to do would be as Gary suggested and read over how schedule actually works. :)
#4
09/19/2006 (6:59 am)
Or if you're lazy like me.

Con::executef ( 4, "schedule", 1000, 0, "function" );
#5
09/19/2006 (11:17 am)
Quote:Or if you're lazy like me.

That's pretty lazy.
#6
09/19/2006 (11:23 am)
Hey, whatever works for people, right? :P

If it's already exposed to script that's not too bad an idea, obviously if you expose something to script justs so you can schedule it you might not be doing the smartest thing. ;)
#7
09/19/2006 (2:22 pm)
Isn't there anything supported natively by c++ itself?.
This is possible in other languages.
#8
09/19/2006 (2:42 pm)
C++ is not a programming API
it is a Language.

there is nothing in the standard library that does anything like this.
#9
09/19/2006 (2:59 pm)
You can use SimEvent to get there. C++ has no native assumptions about time (it's a systems programming language after all - what good is a language for implementing a time service if it already has to have one to run?! :), so we solved it in context of Torque.
#10
09/19/2006 (3:11 pm)
Quote:Or if you're lazy like me.

Con::executef ( 4, "schedule", 1000, 0, "function" );

Classic!