Skip to content

Field manual / Level editor

events — Events

The event bus between components (§14.1). OpenGorky only.

Summary

events::EmitCalls the handlers of the event's subscribers in subscription order with the remaining arguments (as is); returns how many were called.
events::SubscribeFrom a component method: this instance hears the event through its method handler (§14.1).
events::UnsubscribeRemoves the calling instance's subscriptions to the event (with handler, only that one); returns how many were removed.

Functions

events::Emit(string event, ?any args...) → int

OpenGorky onlyClassic: Emit

Calls the handlers of the event's subscribers in subscription order with the remaining arguments (as is); returns how many were called. No deeper than 8 nested levels; in battle, writes a log line emit name n=….

events::Subscribe(string event, method handler) → bool

OpenGorky onlyClassic: Subscribe

From a component method: this instance hears the event through its method handler (§14.1). method is the name of a method of the calling component and is checked at link time.

events::Unsubscribe(string event, ?method handler) → int

OpenGorky onlyClassic: Unsubscribe

Removes the calling instance's subscriptions to the event (with handler, only that one); returns how many were removed.