|
|
(2 intermediate revisions by one other user not shown) |
Line 1: |
Line 1: |
− | ==getTime==
| + | #REDIRECT [[Global Command: 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.
| |
− | <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>
| |
− | -- 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
| |
− | </syntaxhighlight>
| |