Class l2df.manager.event

Last updated 2021-05-28 15:24:22

Event manager.

Info:

Functions

Manager:init([kwargs]) Configure EventManager.
Manager:classInit(entity) Embed references to EventManager's methods in the entity instance that you create.
Manager.subscribe(subscriber[, event=false], handler, source) Allows the object to listen events sent to the Manager.
Manager:unsubscribe(event, handler) Disables event tracking by objects using handler.
Manager:unsubscribeById(event, id) Disables event tracking by objects using ID.
Manager:invoke(event, source) Invoke an event for all active subscribers.
Manager:monitoring(source, events[, alias[, save_result=false]]) Monitors whether an object calls certain functions.
Manager:update(...) Update event handler.

Tables

DefaultUpdateEvents Default update events bindings.
UpdateEvent Custom update event description.

Fields

Manager.active EventManager's enabled state.


Functions

Methods
Manager:init([kwargs])
Configure EventManager.

Parameters:

Returns:

    l2df.manager.event
Manager:classInit(entity)
Embed references to EventManager's methods in the entity instance that you create. Embedded methods are: subscribe, unsubscribe and unsubscribeById.

Parameters:

Manager.subscribe(subscriber[, event=false], handler, source)
Allows the object to listen events sent to the Manager.

Parameters:

  • subscriber l2df.class.entity or table Subscriber object.
  • event string Name of the event.
  • handler function Callback function which would be called with an invoked event.
  • source l2df.class.entity Source object of the calling event. If event with the same name comes from another source it would be ignored.

Returns:

    number Subscription ID. Can be used with EventManager:unsubscribeById().
Manager:unsubscribe(event, handler)
Disables event tracking by objects using handler.

Parameters:

  • event string Name of the event.
  • handler function Handler function which was subcribed.

Returns:

    boolean true if unsubscribed, false otherwise.
Manager:unsubscribeById(event, id)
Disables event tracking by objects using ID.

Parameters:

Returns:

    boolean true if unsubscribed, false otherwise.
Manager:invoke(event, source)
Invoke an event for all active subscribers.

Parameters:

Manager:monitoring(source, events[, alias[, save_result=false]])
Monitors whether an object calls certain functions.

Parameters:

  • source l2df.class.entity or table Source object of the calling event. It is used by EventManager:subscribe() to filter out events depending on its source.
  • events table or string Name(s) of the field(s) containing function to hook.
  • alias table or string If setted makes an alias which would be passed to the. EventManager:invoke() method instead of the original function name. (optional)
  • save_result boolean Whether to save the result of the function execution. (default false)
Manager:update(...)
Update event handler. Executes UpdateEvents on each entity and its. components in the order they were passed to EventManager:init().

Parameters:

  • ... Passes all arguments to each update event and liftdown / liftup callbacks.

Tables

DefaultUpdateEvents
Default update events bindings. These events are executed in the same order they are represented here (or at kwargs.updates passed to EventManager:init()) on each EventManager:update() call.

Fields:

  • DefaultUpdateEvents[1] {'preupdate','beforepreupdate',false}
  • DefaultUpdateEvents[2] {'update','beforeupdate',true}
  • DefaultUpdateEvents[3] {'postupdate','beforepostupdate',false}
  • DefaultUpdateEvents[4] {'lastupdate','beforelastupdate',false}
UpdateEvent
Custom update event description.

Fields:

  • UpdateEvent[1] string (event) Name of the custom update event.
  • UpdateEvent[2] string (before_event) Name of the event which will be triggered before actual event.
  • UpdateEvent[3] boolean (lift_support) Add support for "liftdown" and "liftup" callbacks during this event. false by default.

Fields

Manager.active boolean
EventManager's enabled state. true by default. It is not actually used yet.