cheat
The `cheat` library provides core functions for managing script execution, callbacks, and global state.
Methods
cheat.register(eventName, function)
cheat.register(eventName, function)
Registers a function to be called when a specific event occurs. This is the foundation of event-driven scripting in Sertonin.
Parameters:
eventName: string
- The name of the event to hook into.function: function
- The function to be executed when the event fires.
Available Events:
onUpdate
Fired at a very high frequency (~5ms). Ideal for game logic and fast loops.
onSlowUpdate
Fired at a low frequency (~1s). Ideal for non-critical background tasks.
onPaint
Fired every rendering frame. All drawing must be done here.
Example:
local function my_paint_function()
draw.rect(10, 10, 50, 50, 255, 255, 255, 255)
end
-- Tell the engine to call our function every frame
cheat.register("onPaint", my_paint_function)
cheat.getWindowSize()
Returns the width and height of the main game window in pixels.
Returns:
width: number - The width of the window.
height: number - The height of the window.
local screen_w, screen_h = cheat.getWindowSize()
-- Calculate the center of the screen
local center_x = screen_w / 2
local center_y = screen_h / 2
-- Draw a crosshair at the center
draw.line(center_x - 10, center_y, center_x + 10, center_y, 255, 255, 255, 255, 1)
draw.line(center_x, center_y - 10, center_x, center_y + 10, 255, 255, 255, 255, 1)
Last updated