Overview
Thescheduler global allows you to schedule tasks to run after a delay or at regular intervals. All time values are in milliseconds.
Scheduling Tasks
One-Shot Tasks
Periodic Tasks
Interval in milliseconds between executions
Function to execute repeatedly. Must return
true to continue, false to stop.Optional initial delay before first execution (defaults to
interval)Periodic with Initial Delay
Task Management
Cancel Task
The task ID returned by
schedule() or schedule_periodic()Cancel All Tasks
Cancel all pending tasks.
Check if Task is Pending
The task ID to check
true if the task is still pending (not executed or cancelled).Get Pending Task Count
Returns the number of pending tasks.
Examples
Simple Delay
Periodic Timer
Delayed Message
Position Tracker
Auto-Disconnect Timer
Countdown Timer
Task Manager
Cleanup on Disconnect
Coroutine Integration
You can use Lua coroutines with the scheduler for async-style code:Best Practices
See Also
Events API
Use scheduler with events
Examples
More scheduler examples