Module hook-sys

Provides utilities for allowing multiple systems to hook the same set of events without interfering with each other or requiring coordination.

Anywhere the text EVENT appears in the function documentation below, this should be substituted for the name of an event, such as init or destroyed.

Entity

hook.entity Access hooks for an entity.
.on.EVENT(callback) Register to receive a callback when an event happens on this entity.
.trigger.EVENT(...) Trigger an event on this entity.

Global

hook.on.EVENT(callback) Register to receive a callback when an event happens.
hook.after.EVENT(callback) Register to receive a callback when an event happens, after all normal callbacks have been called.
hook.trigger.EVENT(...) Trigger an event.
hook.every(interval, callback) Register to receive a callback on an interval.
hook.afterDelay(time, callback) Register to receive a callback after a delay.


Entity

An entity is a thing that exists in the world of EmptyEpsilon. On non-ECS, this is a SpaceObject; on ECS, an Entity.
hook.entity
Access hooks for an entity. This table should be indexed with the entity you wish to set or trigger hooks for. The remaining functions in this section are accessed on the table returned from this index operation.
.on.EVENT(callback)
Register to receive a callback when an event happens on this entity.

Parameters:

  • callback The callback to register. Callbacks will receive a first parameter of the entity itself, followed by any arguments passed to .trigger.EVENT.
.trigger.EVENT(...)
Trigger an event on this entity.

Parameters:

  • ... The additional arguments to pass to each callback.

Global

hook.on.EVENT(callback)
Register to receive a callback when an event happens.

Parameters:

  • callback The callback to register.
hook.after.EVENT(callback)
Register to receive a callback when an event happens, after all normal callbacks have been called.

Parameters:

  • callback The callback to register.
hook.trigger.EVENT(...)
Trigger an event.

Parameters:

  • ... The arguments to pass to each callback.
hook.every(interval, callback)
Register to receive a callback on an interval. This function depends on the update hook being triggered regularly.

Parameters:

  • interval number The interval to call on.
  • callback function The callback to register.
hook.afterDelay(time, callback)
Register to receive a callback after a delay. This function depends on the update hook being triggered regularly.

Parameters:

  • time number The delay after which to call the function.
  • callback function The callback to register.
generated by LDoc 1.5.0