SetTimer: Difference between revisions
Jump to navigation
Jump to search
Complete Lua function catalog |
Document expanded scripting capacities and complete audited limits for 0.1.3 BUILD81 |
||
| Line 1: | Line 1: | ||
= setTimer = | = setTimer = | ||
Schedules a Lua function to run after a delay, optionally more than once. | Schedules a Lua function to run after a delay, optionally more than once. | ||
| Line 34: | Line 33: | ||
== Notes == | == Notes == | ||
* Available in both client-side and server-side resource scripts. | * Available in both client-side and server-side resource scripts. | ||
* Expanded limits apply from update 0.1.3 BUILD81. Client limits: 8192 timers per resource, at most 256 selected callbacks per tick, oldest deadline first, and 32 callback arguments. The server has no corresponding fixed timer-count or callbacks-per-tick cap; memory and execution budgets still apply. See [[Scripting limits]]; earlier 0.1.3 binaries retain their old limits. | |||
[[Category:Lua Functions]] | [[Category:Lua Functions]] | ||
Latest revision as of 11:51, 12 September 2026
setTimer
Schedules a Lua function to run after a delay, optionally more than once.
Syntax
int setTimer(function callback, int intervalMs, int timesToExecute, ...)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
callback |
function |
yes | The function to execute. |
intervalMs |
int |
yes | Delay between executions in milliseconds. The minimum is 10. |
timesToExecute |
int |
yes | Number of executions. Use 0 to repeat indefinitely. |
... |
any |
no | Optional values passed to the callback each time it runs. |
Returns
Returns a positive timer identifier on success, or 0 when the timer could not be created.
Examples
Print a message three times at one-second intervals:
local timer = setTimer(function(message)
print(message)
end, 1000, 3, "One second passed")
Notes
- Available in both client-side and server-side resource scripts.
- Expanded limits apply from update 0.1.3 BUILD81. Client limits: 8192 timers per resource, at most 256 selected callbacks per tick, oldest deadline first, and 32 callback arguments. The server has no corresponding fixed timer-count or callbacks-per-tick cap; memory and execution budgets still apply. See Scripting limits; earlier 0.1.3 binaries retain their old limits.