add entity events to docs
This commit is contained in:
@@ -136,3 +136,66 @@ rig:set_texture(key: str, value: str)
|
||||
-- Returns the bone index by name or nil
|
||||
rig:index(name: str) -> int
|
||||
```
|
||||
|
||||
## Component events
|
||||
|
||||
```lua
|
||||
function on_despawn()
|
||||
```
|
||||
|
||||
Called when the entity is despawned.
|
||||
|
||||
```lua
|
||||
function on_grounded(force: number)
|
||||
```
|
||||
|
||||
Called on landing. The first argument is the impact force (Speed module).
|
||||
|
||||
```lua
|
||||
function on_fall()
|
||||
```
|
||||
|
||||
Called when the entity starts to fall.
|
||||
|
||||
```lua
|
||||
function on_save()
|
||||
```
|
||||
|
||||
Called before component data is saved. Here you can write the data you want to save into the *SAVED_DATA* table, which is available for the entire life of the component.
|
||||
|
||||
```lua
|
||||
function on_sensor_enter(index: int, entity: int)
|
||||
```
|
||||
|
||||
Called when another entity hits the sensor with the index passed as the first argument. The UID of the entity that entered the sensor is passed as the second argument.
|
||||
|
||||
```lua
|
||||
function on_sensor_exit(index: int, entity: int)
|
||||
```
|
||||
|
||||
Called when another entity exits the sensor with the index passed as the first argument. The UID of the entity that left the sensor is passed as the second argument.
|
||||
|
||||
```lua
|
||||
function on_aim_on(playerid: int)
|
||||
```
|
||||
|
||||
Called when the player aims at the entity. The player ID is passed as an argument.
|
||||
|
||||
```lua
|
||||
function on_aim_off(playerid: int)
|
||||
```
|
||||
|
||||
Called when the player takes aim away from the entity. The player ID is passed as an argument.
|
||||
|
||||
```lua
|
||||
function on_attacked(attackerid: int, playerid: int)
|
||||
```
|
||||
|
||||
Called when an entity is attacked (LMB on the entity). The first argument is the UID of the attacking entity. The attacking player ID is passed as the second argument. If the entity was not attacked by a player, the value of the second argument will be -1.
|
||||
|
||||
|
||||
```lua
|
||||
function on_used(playerid: int)
|
||||
```
|
||||
|
||||
Called when an entity is used (RMB by entity). The player ID is passed as an argument.
|
||||
|
||||
Reference in New Issue
Block a user