Difference between revisions of "GetTime"
From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "<div class="toccolours mw-collapsible mw-collapsed" style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%"> <b>Command History</b> <div class="mw-collapsible-co...") |
|||
Line 8: | Line 8: | ||
Returns the number of milliseconds since the command was first called - or since the timer was reset! <br/> | Returns the number of milliseconds since the command was first called - or since the timer was reset! <br/> | ||
Use this command for relative time measurements; for example: call getTime() at the beginning of an action & then again when the action has finished to get the time taken to perform said action! | Use this command for relative time measurements; for example: call getTime() at the beginning of an action & then again when the action has finished to get the time taken to perform said action! | ||
− | |||
− | |||
− | |||
− | |||
− | |||
Revision as of 16:05, 2 April 2013
Command History
Available since v3.7
Returns the number of milliseconds since the command 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 & then again when the action has finished to get the time taken to perform said action!
Syntax:
getTime({flags=1, reset})
Example:
-- let's store the current time in a variable & then check it against current time!
local initialTime = getTime()
-- we'll use this function to check current time elapsed & decided what action to perform!
function checkTime()
if getTime() >= initialTime + 3000 then -- if current time more than equals initial time + 3 seconds then ...
-- do some action!
getTime({flags=1, reset=true}) -- let's reset timer back to zero!
end
end
-- the checkTime() function would be most effective, if included in a mainLoop event handler!
Arguments
none
Flags
r/reset
True resets timer back to zero; false does nothing (if no flags are set then reset will be false by default)
Return
time
The integer value of the current time (in ms)