AreaTrigger
A userdata object representing an area trigger in the game.
Values:
Functions:
Operations:
id integer
Get:
Returns the id of an area trigger.
bindOnEnter(areaTrigger, callback, object=nil)
Binds an area trigger's onEnter event to a custom callback. The onEnter event is triggered when an object enters the trigger area.
The callback receives:
function MyClass.onEnter( self, trigger, results ) ...
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
string | callback | The name of the Lua function to bind. |
table | object=nil | The object that will receive the callback. (optional) |
bindOnExit(areaTrigger, callback, object=nil)
Binds an area trigger's onExit event to a custom callback. The onExit event is triggered when an object leaves the trigger area.
The callback receives:
function MyClass.onExit( self, trigger, results ) ...
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
string | callback | The name of the Lua function to bind. |
table | object=nil | The object that will receive the callback. (optional) |
bindOnProjectile(areaTrigger, callback, object=nil)
Binds an area trigger's onProjectile event to a custom callback. The onProjectile event is triggered if a projectile collides with the trigger area
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
string | callback | The name of the Lua function to bind. |
table | object=nil | The object that will receive the callback. (optional) |
bindOnStay(areaTrigger, callback, object=nil)
Binds an area trigger's onStay event to a custom callback. The onStay event is triggered every tick as long as an object is staying inside of the trigger area.
The callback receives:
function MyClass.onStay( self, trigger, results ) ...
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
string | callback | The name of the Lua function to bind. |
table | object=nil | The object that will receive the callback. (optional) |
getContents(areaTrigger)
Gets the contents of the area trigger.
Returns a table of characters and/or bodies and/or harvestables and/or lifts and/or areaTriggers.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Returns:
Type | Description |
table | The table with the content. |
getHostInteractable(areaTrigger)
Returns the attached host interactable.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Returns:
Type | Description |
Interactable | The area trigger's host interactable. |
getId(areaTrigger)
Returns the id of an area trigger.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Returns:
Type | Description |
integer | The area trigger's id. |
getShapes(areaTrigger)
Gets the shapes inside the area trigger
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Returns:
Type | Description |
table | A table of shapes. {Shape, ...} |
getSize(areaTrigger)
Returns the size of an area trigger.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Returns:
Type | Description |
Vec3 | The area trigger's size. |
getUserData(areaTrigger)
Returns the user data set on the area trigger.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Returns:
Type | Description |
table | The user data set on this trigger |
getWorldMax(areaTrigger)
Returns the world max corner position of an area trigger.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Returns:
Type | Description |
Vec3 | The area trigger's max corner position. |
getWorldMin(areaTrigger)
Returns the world min corner position of an area trigger.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Returns:
Type | Description |
Vec3 | The area trigger's min corner position. |
getWorldPosition(areaTrigger)
Returns the world position of an area trigger.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Returns:
Type | Description |
Vec3 | The area trigger's world position. |
getWorldRotation(areaTrigger)
Returns the world rotation of an area trigger.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Returns:
Type | Description |
Quat | The area trigger's world rotation. |
hasVoxelTerrainContact(areaTrigger)
Returns true if the AreaTrigger is in contact with destructable terrain.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Returns:
Type | Description |
boolean | Destructable terrain contact. |
setShapeDetection(areaTrigger, detectShapes)
Shape detection is off by default. When set to true the area trigger can calculate which shapes are inside of the trigger
with a call to AreaTrigger: getShapes
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
boolean | detectShapes | Shape detection on or off. |
setSize(areaTrigger, size)
Sets the new size of an area trigger.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Vec3 | size | The area trigger's new size. |
setWorldPosition(areaTrigger, position)
Sets the new world position of an area trigger.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Vec3 | position | The area trigger's new world position. |
setWorldRotation(areaTrigger, rotation)
Sets the new world rotation of an area trigger.
Parameters:
Type | Name | Description |
AreaTrigger | areaTrigger | The area trigger instance. |
Quat | rotation | The area trigger's new world rotation. |