Comment on page
🗳
events
events.event_name:set(callback: function)
Name | Type | Description |
---|---|---|
callback | function | Lua function to call |
Sets the callback for the specified event. The registered function will be called every time the specified event occurs.
events.event_name:unset(callback: function)
Name | Type | Description |
---|---|---|
callback | function | Lua function that was passed to the :set function |
Unsets the callback that was set via the
:set
function from the specified event.events.event_name:call(...)
Name | Type | Description |
---|---|---|
... | | Arguments to be passed by the callback |
Fires the specified event.
events.event_name(callback: function[, state: boolean])
Name | Type | Description |
---|---|---|
callback | function | Lua function to call |
state | boolean | Optional. Callback state. If not specified then toggles the callback state for the specified function. |
Sets / unsets the callback for the specified event.
Toggle Behavior
State Behavior
1
local function function_callback()
2
print(globals.tickcount)
3
end
4
5
-- Sets the createmove callback for the specified function
6
events.createmove(function_callback)
7
8
-- Execute after 0.5 secs
9
utils.execute_after(0.5, function()
10
-- Toggles the createmove callback for the specified function
11
events.createmove(function_callback)
12
end)
1
local function function_callback()
2
print(globals.tickcount)
3
end
4
5
events.createmove(function_callback, true) -- Sets the callback
6
events.createmove(function_callback, false) -- Unsets the callback
Last modified 7mo ago