add entity events to docs

This commit is contained in:
MihailRis
2024-07-16 14:29:56 +03:00
parent 50050dbe40
commit ef22b2d7e0
2 changed files with 127 additions and 0 deletions
+63
View File
@@ -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.