TorqueScript Reference
Functions
Event Scheduling

Functions

void cancel (eventID)
 
Integer getEventTimeLeft (eventID)
 
Integer getScheduleDuration (eventID)
 
Integer getSimTime ()
 
Integer getTimeSinceStart (eventID)
 
Boolean isEventPending (eventID)
 
Integer schedule (t, objID||0, functionName, arg0,..., argN)
 

Detailed Description

Function Documentation

◆ cancel()

void cancel ( eventID  )

cancel a previously scheduled event

Parameters
eventIDThe numeric ID of a previously scheduled event.
Returns
No return value.
See also
getEventTimeLeft, getScheduleDuration, getTimeSinceStart, isEventPending, schedule, SimObject::schedule
See Engine Function/Method
Sim::cancelEvent

◆ getEventTimeLeft()

Integer getEventTimeLeft ( eventID  )

Determines how much time remains until the event specified by eventID occurs.

Parameters
eventIDThe numeric ID of a previously scheduled event.
Returns
a non-zero integer value equal to the milliseconds until the event specified by eventID will occur. However, if eventID is invalid, or the event has passed, this function will return zero.
See also
cancel, getScheduleDuration, getTimeSinceStart, isEventPending, schedule, SimObject::schedule
See Engine Function/Method
Sim::getEventTimeLeft

◆ getScheduleDuration()

Integer getScheduleDuration ( eventID  )

Determines how long the event associated with eventID was scheduled for.

Parameters
eventIDThe numeric ID of a previously scheduled event.
Returns
a non-zero integer value equal to the milliseconds used in the schedule call that created this event. However, if eventID is invalid, this function will return zero.
See also
cancel, getEventTimeLeft, getTimeSinceStart, isEventPending, schedule, SimObject::schedule
See Engine Function/Method
Sim::getScheduleDuration

◆ getSimTime()

Integer getSimTime ( )

get the time, in ticks, that has elapsed since the engine started executing.

Returns
the time in ticks since the engine was started.
See also
getRealTime
See Engine Function/Method
Sim::getCurrentTime

◆ getTimeSinceStart()

Integer getTimeSinceStart ( eventID  )

Determines how much time has passed since the event specified by eventID was scheduled.

Parameters
eventIDThe numeric ID of a previously scheduled event.
Returns
a non-zero integer value equal to the milliseconds that have passed since this event was scheduled. However, if eventID is invalid, or the event has passed, this function will return zero.
See also
cancel, getEventTimeLeft, getScheduleDuration, isEventPending, schedule, SimObject::schedule
See Engine Function/Method
Sim::getTimeSinceStart

◆ isEventPending()

Boolean isEventPending ( eventID  )

See if the event associated with eventID is still pending.

When an event passes, the eventID is removed from the event queue, becoming invalid, so there is no discnerable difference between a completed event and a bad event ID.

Parameters
eventIDThe numeric ID of a previously scheduled event.
Returns
true if this event is still outstanding and false if it has passed or eventID is invalid.
Example
$Game::Schedule = schedule($Game::EndGamePause * 1000, 0, "onCyclePauseEnd");
if( isEventPending($Game::Schedule) ) echo("got a pending event");
void echo(text, [...] *)
Definition output_ScriptBinding.h:36
Integer schedule(t, objID||0, functionName, arg0,..., argN)
Definition simBase_ScriptBinding.h:153
Boolean isEventPending(eventID)
Definition simBase_ScriptBinding.h:81
See also
cancel, getEventTimeLeft, getScheduleDuration, getTimeSinceStart, schedule, SimObject::schedule
See Engine Function/Method
Sim::isEventPending

◆ schedule()

Integer schedule ( ,
objID||  0,
functionName  ,
arg0  ,
  ...,
argN   
)

Schedule "functionName" to be executed with optional arguments at time t (specified in milliseconds) in the future.

This function may be associated with an object ID or not. If it is associated with an object ID and the object is deleted prior to this event occurring, the event is automatically canceled.

Parameters
tThe time to wait (in milliseconds) before executing functionName.
objIDAn optional ID to associate this event with.
functionNameAn unadorned (flat) function name.
arg0,..,argN- Any number of optional arguments to be passed to functionName.
Returns
a non-zero integer representing the event ID for the scheduled event.
Example
$Game::Schedule = schedule($Game::EndGamePause * 1000, 0, "onCyclePauseEnd");
See also
cancel, getEventTimeLeft, getScheduleDuration, getTimeSinceStart, isEventPending, SimObject::schedule
See Engine Function/Method
Sim::postEvent