Events
Functions
Return Type |
Name |
Description |
number |
events.subscribe(Event type, function callback) |
Registers an event listener and returns a handle |
number |
events.unsubscribe(number handle) |
Removes an event listener by handle |
event |
events.get(number handle) |
Gets an event handler by handle |
Types
event
Property |
Name |
bool |
enabled |
function |
callback |
Examples
events.subscribe(Event.PLAYER_JOINED, function(data)
print(data.player) -- `player`
print(data.slot) -- number
end)
events.subscribe(Event.PLAYER_LEFT, function(data)
print(data.player) -- `player`
print(data.slot) -- number
end)
events.subscribe(Event.PLAYER_FLAGGED, function(data)
print(data.player) -- `player`
print(data.reason) -- string
end)
events.subscribe(Event.CHAT_MSG, function(data)
print(data.player) -- `player`
print(data.msg) -- string
end)
events.subscribe(Event.CRASH_ATTEMPT, function(data)
print(data.player) -- `player`
print(data.reason) -- string
end)
events.subscribe(Event.SCROLL_WHEEL, function(data)
print(data.offset) -- number (float, -1.0 to 1.0)
end)
events.subscribe(Event.KEY_PRESS, function(data)
print(data.key) -- number (8 to 255, keyboard only)
end)