Difference between revisions of "GetTime"
From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 1: | Line 1: | ||
− | <div class=" | + | ==getTime== |
− | <span class=" | + | Returns the number of milli seconds since the command was called the first time (or the timer was reset). Use this command for relative time measurements. E.g. call this command twice at different locations and calculate the time differential to see the time passed. |
− | + | <div class="command-min-version-info">Available since: <span class="command-min-version">v3.0</span></div> | |
− | |||
− | |||
+ | Lua Syntax: | ||
+ | <pre class="command-syntax">getTime({flags=1, | ||
+ | reset = true|false})</pre> | ||
+ | ===Arguments=== | ||
+ | ===Flags=== | ||
+ | ====r/reset==== | ||
− | + | :If true the timer will be reset and the next call(s) will return the time passed since this call. | |
− | + | ===Return Values=== | |
− | + | ;time | |
− | + | :Milli seconds | |
− | + | ===Examples=== | |
+ | Example 1: | ||
<syntaxhighlight> | <syntaxhighlight> | ||
− | + | -- we'll use this function to check current time elapsed & decide what action to perform | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | -- we'll use this function to check current time elapsed & | ||
function checkTime() | function checkTime() | ||
− | + | if getTime() > 3000 then -- if time elapsed is more than 3 seconds then ... | |
− | + | -- do some action | |
− | + | getTime({flags=1, reset=true}) -- let's reset timer back to zero | |
− | + | end | |
end | end | ||
− | -- the checkTime() function would be most effective | + | -- the checkTime() function would be most effective if included in a mainLoop event handler |
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 17:11, 22 November 2013
getTime
Returns the number of milli seconds since the command was called the first time (or the timer was reset). Use this command for relative time measurements. E.g. call this command twice at different locations and calculate the time differential to see the time passed.
Available since: v3.0
Lua Syntax:
getTime({flags=1, reset = true|false})
Arguments
Flags
r/reset
- If true the timer will be reset and the next call(s) will return the time passed since this call.
Return Values
- time
- Milli seconds
Examples
Example 1:
-- we'll use this function to check current time elapsed & decide what action to perform
function checkTime()
if getTime() > 3000 then -- if time elapsed is more than 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