Entity:AddCallback
Description
Add a callback function to a specific event. This is used instead of hooks to avoid calling empty functions unnecessarily.
This also allows you to use certain hooks in engine entities (non-scripted entities).
This method does not check if the function has already been added to this object before, so if you add the same callback twice, it will be run twice! Make sure to add your callback only once.
Arguments
2 function func
The function to call. It's arguments and return values will depend on the hook specified in the first argument.
Returns
1 number
The callback ID that was just added, which can later be used in Entity:RemoveCallback.
Returns nothing if the passed callback function was invalid or when asking for a non-existent hook.
Example
Adds a callback to an entity which is called every time the entity angles change.
Example
Creates watermelon prop which creates sparks on collision point whenever touches something.