mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-24 22:51:18 -09:00
2.6 KiB
2.6 KiB
Events
Events broadcast data for use in mods.
ModAPI.addEventListener(eventName: String, callback: Function) : void
- Used to register an event handler. Eg:
-
function myHandler(event) { console.log(event); } ModAPI.addEventListener("update", myHandler);
ModAPI.removeEventListener(eventName: String, callback: Function) : void
- Used to unregister an event handler. Eg:
-
function myHandler(event) { console.log(event); } ModAPI.removeEventListener("update", myHandler);
Basic Events
update
:- Called every client side tick.
- Event object is blank.
load
:- Called when all mods have finished loading.
- Event object is blank.
sendchatmessage
:- Called just before the player sends a chat message.
- Passes an object with properties:
message: String
- String representing the chat message.
preventDefault: Boolean
- Boolean representing whether or not to cancel processing the chat message. Default is
false
.
- Boolean representing whether or not to cancel processing the chat message. Default is
event
:- Called when any event is called. Passes an object with properties:
- Passes an object with properties:
event: String
- String representing the type of event being fired.
data: Object
- Object representing the original arguments to be passed to the callback.
Server Side Events
Can only be used in the context of the dedicated server. More: DedicatedServerDocumentation
serverstart
:- Called when the dedicated server starts.
- Event object is blank.
serverstop
:- Called when the dedicated server stops.
- Event object is blank.
tick
:- Called when the server ticks.
- Passes an object with properties:
preventDefault: Boolean
- Boolean representing whether or not to cancel the tick. Default is
false
.
- Boolean representing whether or not to cancel the tick. Default is
receivechatmessage
:- Called when the server receives a chat message.
- Passes an object with properties:
message: String
- String representing the chat message.
preventDefault: Boolean
- Boolean representing whether or not to cancel processing the chat message. Default is
false
.
- Boolean representing whether or not to cancel processing the chat message. Default is
processcommand
:- Called when the server receives a command.
- Passes an object with properties:
command: String
- String representing the command.
preventDefault: Boolean
- Boolean representing whether or not to cancel processing the command. Default is
false
.
- Boolean representing whether or not to cancel processing the command. Default is