events
Subscribes functions to server events.
Source: src/Moongate.Scripting/Modules/EventsModule.cs
Functions
Section titled “Functions”events.off(handle) -> booleanRemoves a subscription by handle. Returns false when no such subscription exists.
| Parameter | Type | Default |
|---|---|---|
handle | string |
Returns boolean.
events.on(name, fn) -> stringRuns fn with the event's table every time the event happens. Returns a handle for off.
EventName is one of the names listed under
Available events; another name raises an error.
Load this from your bootstrap or a required module, then create a new character in the client. The listener remains registered and logs the new character’s name.
local handle = events.on("character_created", function(e) log.info("New character {Name}", e.name)end)Keep handle in the scope that will perform cleanup later. Unsubscribe only when
you no longer want notifications:
events.off(handle) -- returns false when the handle is unknown| Parameter | Type | Default |
|---|---|---|
name | EventName | |
fn | function |
Returns string.
Made with ❤️ by Tom
