hook( id, hookType, table, func, arg )
instance function
Hook an Entity to be notified when a specific event occurs. The function you supply will be called when the event happens.
Arguments
Name | Type | Description |
---|---|---|
id | String | Identifier for the hook. |
hookType | EntityHook.Type | The event to hook - one of the valid hook types. |
table | Table | The object to call the hook function on. Can be nil. |
func | Function | The function to call |
arg | Any | A parameter to pass to the function. Can be nil |
Returns
Type | Description |
---|---|
Boolean | True if the hook was succesfully added |
Notes
The callback function should have the following signature - entity is the Entity that invoked the call and hook is an EntityHook object. Depending on the situation, such as a destroy notification, entity may be nil.
function ExampleTable:exampleFunction( entity, hook )