Skip to content

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()

SmoothSoft

 function self.SmoothSoft((optional int)Times to apply)
Parameter Type 📝 Description
Times to apply optional int Applies the algorithm X times. Defaults to 3 times. The more times the algorithm is applied smoother it will be, but also heavier with more polygons.

Entity.SmoothSoft

Applies a soft smoothing algorithm to the models of this entity.

Example

self.SmoothSoft()
This will smooth the models in this entity 3 times.


SmoothStrong

 function self.SmoothStrong((optional int)Times to apply)
Parameter Type 📝 Description
Times to apply optional int Applies the algorithm X times. Defaults to 3 times. The more times the algorithm is applied smoother it will be, but also heavier with more polygons.

Entity.SmoothStrong

Applies a stronger smoothing algorithm to the models of this entity.

Example

self.SmoothStrong()
This will smooth the models in this entity 3 times.


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


MakeShop

 function self.MakeShop((string array[])Possibilities , (optional bool)RandomFill, (optional int)MinAmount, (optional int)MaxAmount, (optional bool)OnlyIfEvent, (optional string)EventID)
Parameter Type 📝 Description
Possibilities string array[] An array with the item ids that this shop can display.
RandomFill optional bool If set to true it will pick a random amount of the item possibilities assigned, between MinAmount and MaxAmount. Otherwise it will show all of the possibilities.
MinAmount optional int Minimum amount of items to pick with random filling.
MaxAmount optional int Maximum amount of items to pick with random filling.
OnlyIfEvent optional bool If set to true this shop will only show up if the specified event is set.
EventID optional string Event to only show shop if the player has, in case using OnlyIfEvent

Entity.MakeShop

Makes the entity a shop

Example

self.MakeShop({"daisy","poop","seed_daisy"},true,1,1)
In the following example this shop will sell daisies and poop.


MakeCraftingStation

 function self.MakeCraftingStation((string)InteractionName , (string)StationID, (optional float)Radius, (optional bool)ShowBase)
Parameter Type 📝 Description
InteractionName string Name of the interaction trigger when the player gets close to it.
StationID string Station ID that needs to be used on the crafting info so the crafting recipes will show in this station.
Radius optional float Radius for interaction. Defaults to 3.
ShowBase optional bool If true will show base items as well as the items this workbench can craft.

Entity.MakeCraftingStation

Makes the entity a crafting station

Example

)
This will make the entity a workbench that will show any recipes that are set to Workbench_Dungeon


AddLuaTrigger

 function self.AddLuaTrigger((string)Trigger Name , (optional float)Radius, (optional bool)Auto, (optional bool)Locks Player, (optional bool)Is Secondary, (optional bool)Only Once)
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 false 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.
Only Once optional bool If set to true the trigger will only be able to be used once (local). It is set to false by default.

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'.


DelayCall

 function self.DelayCall((function)Function , (float)Delay, (parameters)Other Parameters)
Parameter Type 📝 Description
Function function Function to be called
Delay float Delay to wait before calling the function
Other Parameters parameters This method can be called with aditional parameters to be sent to the function to be called.

Entity.DelayCall

Calls a function after a delay has passed.

Example

Entity.DelayCall(TestFunction,2,"Test")
This example will call the function TestFunction with the parameter 'Test' in 2 seconds.

Comments