|
|
(3 intermediate revisions by one other user not shown) |
Line 1: |
Line 1: |
− | <div class="toccolours mw-collapsible mw-collapsed tbl-ds">
| + | #REDIRECT [[Global Command: getTime]] |
− | <span class="bold">Command History</span>
| |
− | <div class="mw-collapsible-content">
| |
− | <div class="alt-bg">Available since v3.7</div>
| |
− | </div></div>
| |
− | | |
− | | |
− | 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!
| |
− | | |
− | | |
− | Syntax:
| |
− | <syntaxhighlight>
| |
− | getTime({flags=1, reset})
| |
− | </syntaxhighlight>
| |
− | | |
− | | |
− | Example:
| |
− | <syntaxhighlight>
| |
− | -- 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!
| |
− | </syntaxhighlight>
| |
− | | |
− | | |
− | | |
− | <span class="bold underline">Arguments</span>
| |
− | | |
− | none
| |
− | | |
− | | |
− | <span class="bold underline">Flags</span>
| |
− | | |
− | <span class="bold">r/reset</span> <br/>
| |
− | True resets timer back to zero; false does nothing (if no flags are set then reset will be false by default)
| |
− | | |
− | | |
− | <span class="bold underline">Return</span>
| |
− | | |
− | <span class="bold">time</span> <br/>
| |
− | The integer value of the current time (in ms)
| |
− | {{i18n|GetTime}}
| |