Core Concepts
Event-Driven Callbacks
The scripting engine is event-driven. Instead of running your script in an infinite loop, you register functions to be called when specific events occur. This is more efficient and integrates cleanly with the application's lifecycle.
Callback Name
Frequency
Description
onUpdate
~5ms
For logic that needs to run many times per second, like target finding or physics calculations.
onSlowUpdate
~1s
For non-critical background tasks, like checking a value periodically or logging stats.
onPaint
Every Frame
(Most Common) All drawing must be done here. Use the
drawlibrary to draw to the screen.
local function my_paint_function()
draw.rect(10, 10, 100, 100, 255, 0, 0, 255)
end
-- Register the function to be called by the engine
cheat.reigster("onPaint", my_paint_function)
Last updated