callbacks.Register(id:string, fn)Register a callback for an event; returns its unique name.
Callback registration and every dispatch event.
callbacks.Register(id:string, fn)Register a callback for an event; returns its unique name.
callbacks.Register(id:string, uniqueName:string):stringRegister a callback under an explicit unique name.
callbacks.Unregister(id:string, uniqueName:string):booleanUnregister a callback by its unique name.
callbacks.CreateMove(cmd:UserCmd)Runs before a command is sent.
callbacks.Draw()Runs every frame; draw on screen here.
callbacks.FireGameEvent(ev:GameEvent)Runs when a game event fires.
callbacks.FrameStageNotify(stage:number)Runs at each engine frame stage.
callbacks.DispatchUserMessage(msg:UserMessage)Runs when a user message is received.
callbacks.DrawModel(ctx:DrawModelContext)Runs when a model is drawn.
callbacks.DoPostScreenSpaceEffects()Runs after post screen-space effects.
callbacks.RenderView(view:ViewSetup)Runs before the view is rendered.
callbacks.PostRenderView(view:ViewSetup)Runs after the view is rendered.
callbacks.SendNetMsg(msg:NetMessage)Runs when a message is sent to the server.
callbacks.Unload()Runs when the script is unloaded.
Wires several callback types together: a toggle, drawing, an event, and cleanup.
local cfg = { showBox = true }
callbacks.Register("CreateMove", function()
if input.IsButtonPressed(KEY_F9) then
cfg.showBox = not cfg.showBox
end
end)
callbacks.Register("Draw", function()
if cfg.showBox then
draw.Color(0, 255, 255, 255)
draw.FilledRect(10, 10, 90, 60)
end
end)
callbacks.Register("FireGameEvent", function(ev)
if ev:GetName() == "player_hurt" then
print("hurt event: attacker", ev:GetInt("attacker"))
end
end)
callbacks.Register("Unload", function()
print("script unloaded")
end)