Entity

Functions

Include

 function self.Include(File)
Parameter Type 📝 Description
File filename without the extension. Make sure this file is within the 'libraries' folder of the mod.

Entity.Include

Includes another lua file in this entity script.

Example

self.Include("file")
This example includes a file called file.


RegisterListener

 function self.RegisterListener((int)MessageToListen , (function)Function to Call)
Parameter Type 📝 Description
MessageToListen int The id of one of the messages available on the Messager. Example: Messager.Update
Function to Call function The function that should be called once this message is sent.

Entity.RegisterListener

Registers for Messager messages.

Example

self.RegisterListener(Messager.Update,Test)
This example will call the function Test every time Update message is sent by the messager.


UnregisterListener

 function self.UnregisterListener((int)MessageToStopListening)
Parameter Type 📝 Description
MessageToStopListening int The id of one of the messages available on the Messager. Example: Messager.Update

Entity.UnregisterListener

Unregister from Messager messages.

Example

self.UnregisterListener(Messager.Update)
This example will stop calling the function Test every time Update message is sent by the messager.


ListenForNetworkCalls

 function self.ListenForNetworkCalls()

Entity.ListenForNetworkCalls

Start listening for function calls from other players in the room.

Example
self.ListenForNetworkCalls()

StopListeningForNetworkCalls

 function self.StopListeningForNetworkCalls()

Entity.StopListeningForNetworkCalls

Stop listening for function calls from other players in the room.

Example
self.StopListeningForNetworkCalls()

PreventTimePassing

 function self.PreventTimePassing()

Entity.PreventTimePassing

Prevents time from progressing in the game


AllowTimePassing

 function self.AllowTimePassing()

Entity.AllowTimePassing

Allows time from progressing in the game


AddLuaTrigger

 function self.AddLuaTrigger((string)Trigger Name , (optional float)Radius, (optional bool)Auto, (optional bool)Locks Player, (optional bool)Is Secondary)
Parameter Type 📝 Description
Trigger Name string Name of the trigger.
Radius optional float Radius the player has to be to be able to use the trigger.
Auto optional bool True if the trigger should automatically trigger when the player enters its radius. It's set to fale by default.
Locks Player optional bool True if this trigger should prevent the player from moving while it's in use.
Is Secondary optional bool Should this trigger prefer to be activated with the secondary button? Defaults to false.

Entity.AddLuaTrigger

Adds a Lua Trigger to this entity. Check the documentation on TriggerActionLua to see how to override this trigger's calls.

Example

self.AddLuaTrigger("Custom Trigger",3)
Adds a trigger to this entity with name 'Custom Trigger' and radius 3


RegisterEntityWithTag

 function self.RegisterEntityWithTag((string)Tag)
Parameter Type 📝 Description
Tag string Tag to register

Entity.RegisterEntityWithTag

Registers a entity with a tag that can be retrieved later by other entities/scripts.

Example

self.RegisterEntityWithTag("trophy")
This example registers an entity with the tag 'trophy'


UnregisterEntityWithTag

 function self.UnregisterEntityWithTag((string)Tag)
Parameter Type 📝 Description
Tag string Tag to register

Entity.UnregisterEntityWithTag

Unregisters a entity with a tag if it has been registered before.

Example

self.UnregisterEntityWithTag("trophy")
This example unregisters an entity with the tag 'trophy'


GetEntityWithTag

 function self.GetEntityWithTag((string)Tag)
Parameter Type 📝 Description
Tag string Tag to find

Entity.GetEntityWithTag

Returns a single random entity with the specified tag.

Example

self.GetEntityWithTag("trophy")
This example returns a random entity with the tag 'trophy'.


GetEntitiesWithTag

 function self.GetEntitiesWithTag((string)Tag)
Parameter Type 📝 Description
Tag string Tag to find

Entity.GetEntitiesWithTag

Returns a list of entities with the specified tag.

Example

self.GetEntitiesWithTag("trophy")
This example returns a list of entities with the tag 'trophy'.


CallFunctionOnOthers

 function self.CallFunctionOnOthers((string)Function Name , (parameters)Other Parameters)
Parameter Type 📝 Description
Function Name string Function name as a string
Other Parameters parameters Other parameters to call on this function. Can only take Numbers, Booleans, Strings, Simple Tables. When in doubt if it's a type that is acceptable send it as a json.

Entity.CallFunctionOnOthers

Call a function on other players in the room. Make sure the script that will receive the function has called self.ListenForNetworkCalls() before.

Example

self.CallFunctionOnOthers("Test","This is a test")
This example calls the function 'Test' on other players in the room with the string parameter 'This is a test'.


CallFunctionOnEveryone

 function self.CallFunctionOnEveryone((string)Function Name , (parameters)Other Parameters)
Parameter Type 📝 Description
Function Name string Function name as a string
Other Parameters parameters Other parameters to call on this function. Can only take Numbers, Booleans, Strings, Simple Tables. When in doubt if it's a type that is acceptable send it as a json.

Entity.CallFunctionOnEveryone

Call a function on all players in the room including your own. Make sure the script that will receive the function has called self.ListenForNetworkCalls() before.

Example

self.CallFunctionOnEveryone("Test","This is a test")
This example calls the function 'Test' on all players in the room including your own with the string parameter 'This is a test'.


CallFunctionOnHost

 function self.CallFunctionOnHost((string)Function Name , (parameters)Other Parameters)
Parameter Type 📝 Description
Function Name string Function name as a string
Other Parameters parameters Other parameters to call on this function. Can only take Numbers, Booleans, Strings, Simple Tables. When in doubt if it's a type that is acceptable send it as a json.

Entity.CallFunctionOnHost

Call a function on the host of the room. Make sure the script that will receive the function has called self.ListenForNetworkCalls() before.

Example

self.CallFunctionOnHost("Test","This is a test")
This example calls the function 'Test' on the host of the room with the string parameter 'This is a test'.


CallFunctionOnPlayerWithID

 function self.CallFunctionOnPlayerWithID((int)Player ID , (string)Function Name, (parameters)Other Parameters)
Parameter Type 📝 Description
Player ID int ID of the player that should receive this call.
Function Name string Function name as a string
Other Parameters parameters Other parameters to call on this function. Can only take Numbers, Booleans, Strings, Simple Tables. When in doubt if it's a type that is acceptable send it as a json.

Entity.CallFunctionOnPlayerWithID

Call a function on a player with a specific ID provided. Make sure the script that will receive the function has called self.ListenForNetworkCalls() before.

Example

self.CallFunctionOnPlayerWithID(1,"Test","This is a test")
This example calls the function 'Test' on the player with id 1 with the string parameter 'This is a test'.

Comments