TorqueScript Reference

- Main Page
- Related Pages
- Modules
- Classes

Functions
Event Scheduling
Function Categories

## 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

void cancel | ( | eventID |  | ) |

cancel a previously scheduled event

Parameters

  eventID | The 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

Integer getEventTimeLeft | ( | eventID |  | ) |

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

Parameters

  eventID | The 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

Integer getScheduleDuration | ( | eventID |  | ) |

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

Parameters

  eventID | The 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

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

Integer getTimeSinceStart | ( | eventID |  | ) |

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

Parameters

  eventID | The 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

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

  eventID | The 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
  1 $Game::Schedule = schedule($Game::EndGamePause * 1000, 0, "onCyclePauseEnd");
  2 if( isEventPending($Game::Schedule) ) echo("got a pending event");

See also
  cancel, getEventTimeLeft, getScheduleDuration, getTimeSinceStart, schedule, SimObject::schedule

See Engine Function/Method
  Sim::isEventPending

Integer schedule | ( | t | ,
|  | 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

  t | The time to wait (in milliseconds) before executing functionName.
  objID | An optional ID to associate this event with.
  functionName | An 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
  1 $Game::Schedule = schedule($Game::EndGamePause * 1000, 0, "onCyclePauseEnd");

See also
  cancel, getEventTimeLeft, getScheduleDuration, getTimeSinceStart, isEventPending, SimObject::schedule

See Engine Function/Method
  Sim::postEvent