GetTimerDetails: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Updated details about third returned value. (it was wrong before)) |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 8: | Line 8: | ||
int, int, int getTimerDetails ( timer theTimer ) | int, int, int getTimerDetails ( timer theTimer ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[timer]]:getDetails||}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theTimer:''' A timer element. | *'''theTimer:''' A timer element. | ||
Line 14: | Line 14: | ||
===Returns=== | ===Returns=== | ||
* Integer one represents the time left in miliseconds (1000th of a second) of the current time left in the loop. | * Integer one represents the time left in miliseconds (1000th of a second) of the current time left in the loop. | ||
* Integer two represents the | * Integer two represents the amount of times the timer has left to execute. | ||
* Integer three represents the | * Integer three represents the time interval of timer. | ||
* Returns false if the timer doesn't exist or stopped running. Also, debugscript | * Returns false if the timer doesn't exist or stopped running. Also, debugscript will say "Bad Argument @ 'getTimerDetails'". To prevent this, you can check if the timer exists with [[isTimer]](). | ||
==Example== | ==Example== | ||
This example creates a 1 second (1000 ms) timer that will run | This example creates a 1 second (1000 ms) timer that will run 10 times, and you can see the timer details by using the command: timerdetails. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
theTimer = setTimer(function() end, 1000, 10) -- A timer that does nothing. | theTimer = setTimer(function() end, 1000, 10) -- A timer that does nothing. | ||
function timerDetails() | function timerDetails() | ||
remaining, executesRemaining, | local remaining, executesRemaining, timeInterval = getTimerDetails(theTimer) -- Get the timers details | ||
if (remaining and executesRemaining and | if (remaining and executesRemaining and timeInterval) then | ||
outputChatBox("Time remaining this second: "..remaining.." Executes remaining: "..executesRemaining.." | outputChatBox("Time remaining this second: "..remaining.." Executes remaining: "..executesRemaining.." Time interval: "..timeInterval) | ||
else | else | ||
outputChatBox("Timer no longer exists") | outputChatBox("Timer no longer exists") | ||
Line 34: | Line 34: | ||
addCommandHandler("timerdetails", timerDetails) | addCommandHandler("timerdetails", timerDetails) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | |||
{{Utility functions}} |
Latest revision as of 13:34, 15 August 2020
This function is for getting the details of a running timer.
Syntax
int, int, int getTimerDetails ( timer theTimer )
OOP Syntax Help! I don't understand this!
- Method: timer:getDetails(...)
Required Arguments
- theTimer: A timer element.
Returns
- Integer one represents the time left in miliseconds (1000th of a second) of the current time left in the loop.
- Integer two represents the amount of times the timer has left to execute.
- Integer three represents the time interval of timer.
- Returns false if the timer doesn't exist or stopped running. Also, debugscript will say "Bad Argument @ 'getTimerDetails'". To prevent this, you can check if the timer exists with isTimer().
Example
This example creates a 1 second (1000 ms) timer that will run 10 times, and you can see the timer details by using the command: timerdetails.
theTimer = setTimer(function() end, 1000, 10) -- A timer that does nothing. function timerDetails() local remaining, executesRemaining, timeInterval = getTimerDetails(theTimer) -- Get the timers details if (remaining and executesRemaining and timeInterval) then outputChatBox("Time remaining this second: "..remaining.." Executes remaining: "..executesRemaining.." Time interval: "..timeInterval) else outputChatBox("Timer no longer exists") end end addCommandHandler("timerdetails", timerDetails)
See Also
- addDebugHook
- base64Decode
- base64Encode
- debugSleep
- decodeString
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getRealTime
- getTickCount
- getTimerDetails
- getTimers
- getFPSLimit
- getUserdataType
- getVersion
- gettok
- isTransferBoxVisible
- setTransferBoxVisible
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isTimer
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- removeDebugHook
- resetTimer
- setDevelopmentMode
- setFPSLimit
- setTimer
- ref
- deref
- sha256
- split
- teaDecode
- teaEncode
- toJSON
- tocolor
- getProcessMemoryStats
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub
- bitAnd
- bitNot
- bitOr
- bitXor
- bitTest
- bitLRotate
- bitRRotate
- bitLShift
- bitRShift
- bitArShift
- bitExtract
- bitReplace