Global Command: getTime
From The Official Visionaire Studio: Adventure Game Engine Wiki
(Redirected from GetTime (CMS))
Returns the number of milliseconds since the "getTime()" function was first called or since the timer was reset.
Use this command for relative time measurements; for example: call "getTime()" at the beginning of an action and then again when the action has finished to get the time taken to perform said action.
Syntax
getTime([flags])
Parameters
Parameter | Type/Structure | Description | |
---|---|---|---|
flags | table | flags = 1 | indicates flags table |
reset (bool) | If true the timer is reset back to zero. If the "flags" parameter is omitted, this defaults to false. |
Return values
Type | Description |
---|---|
int | Returns the number of milliseconds since the command was first called or since the timer was reset. |
Examples
Example 1: Execute an action based on how much time elapsed since the game started or since the action was last executed.
-- Call getTime() to start time measuring initially
getTime()
-- If more than 3 seconds elapsed, do something and reset the timer to start counting from zero again;
-- this function would be most effective if included in a "mainLoop" event handler
function checkTime()
if getTime() > 3000 then
startAction(Actions["cock_a_doodle_doo"])
getTime({flags=1, reset=true})
end
end