Coming soon toSteam
Modding docsAPI 1

Module · Scripting core

events

Publish and subscribe to events. Your own events are namespaced by your mod id automatically; subscribe to another mod's with "its.mod-id:name", and to the game's with names like "player.joined".

events.emit(name: string, payload?: any)

Raises one of this mod's events for scripts on the same side. The payload is copied; subscribers run after the current function returns.

events.emit("wave-started", { number = 3 })

events.gameEvents(): string[]

The names of the game events available in this build.

events.on(name: string, handler: function): Subscription

Calls handler(payload) every time the event is raised.

events.on("player.joined", function(player) log.info(player.name, "joined") end)

events.once(name: string, handler: function): Subscription

Like events.on, but only for the next time the event is raised.