Class: Timer

Timer()

new Timer()

Source:

Methods

CancelTimer(id)

Cancels an existing timer that was created with SetTimeout/SetInterval.
Parameters:
Name Type Description
id number The timer's ID returned by either SetTimeout or SetInterval.
Source:

GetLatestTurnLength() → {number}

Source:
Returns:
- The duration of the latest turn in milliseconds.
Type
number

GetTime() → {number}

Source:
Returns:
- The elapsed time in milliseconds since the game was started.
Type
number

OnUpdate(msg)

Parameters:
Name Type Description
msg Object A message containing the turn length in seconds.
Source:

SetInterval(ent, iid, funcname, time, repeattime, data) → {number}

Create a new repeating timer, which will call the 'funcname' method with arguments (data, lateness) on the 'iid' component of the 'ent' entity, after at least 'time' milliseconds. 'lateness' is how late the timer is executed after the specified time (in milliseconds) and then every 'repeattime' milliseconds thereafter.
Parameters:
Name Type Description
ent number The entity the timer will be assigned to.
iid number The component iid of the timer.
funcname string The name of the function to be called in the component.
time number The delay before running the function for the first time.
repeattime number If non-zero, the interval between each execution of the function.
data any The data to pass to the function.
Source:
Returns:
- A non-zero id that can be passed to CancelTimer.
Type
number

SetTimeout(ent, iid, funcname, time, data) → {number}

Create a new timer, which will call the 'funcname' method with arguments (data, lateness) on the 'iid' component of the 'ent' entity, after at least 'time' milliseconds. 'lateness' is how late the timer is executed after the specified time (in milliseconds).
Parameters:
Name Type Description
ent number The entity id to which the timer will be assigned to.
iid number The component iid of the timer.
funcname string The name of the function to be called in the component.
time number The delay before running the function for the first time.
data any The data to pass to the function.
Source:
Returns:
- A non-zero id that can be passed to CancelTimer.
Type
number

UpdateRepeatTime(timerID, newRepeatTime)

Updates the repeat time of a timer. Note that this will take only effect after the next update.
Parameters:
Name Type Description
timerID number The timer to update.
newRepeatTime number The new repeat time to use.
Source: