To implement a new entity using Lua, two files need to be stored in the game folder.
The first one is the Ent file which is parsed by the Entity System to know the file location of the Lua script. The second one is the Lua script which implements the desired properties and functions.
With the SDK, both the .ent and .lua files are stored inside the
The Ent files are all stored inside the
<Game_Folder>\Entities directory and need to have the .ent file extension. The content is an XML file like the example below.
The following table outlines the properties parsed by the Entity System.
Name of the Entity class.
Path of the Lua script used to implement the entity class.
Prevents it from being visible as one of the available entity classes inside Sandbox.
The Lua script consist of one main table which should have the same name as the name intended for the entity class.
The Properties table needs to be placed inside the entity class table. It will be parsed by the Sandbox Editor and provides level editor a way to change entity class parameters through the user interface.
In order to have the parameters listed in the table above, the following Properties table.
The values assigned inside the Lua table are used to provide default values in Sandbox. The property values for each instance placed on a level will be saved individually in the level file.
Sandbox provide the Archetype tool for assigning a common set properties reused for multiple instance (even across multiple levels). More information on Archetypes can be found in the Sandbox Manual.
Any time a property of an instance is changed within Sandbox, the OnPropertyChange() function will be called if it is has been implemented for the Script Entity.
It is possible to give the Editor hints, concerning the value type desired for a property value. This is done by using one of the following prefixes on the value name.
an object compatible with CryENGINE: a CFG, CGA, CHR or CDF file.
The Editor table can be added inside the entity class table. It gives some information to Sandbox on additional information to draw on the instances of an entity.
CGF model which the Editor render over any instance of the entity.
Indicates if the Editor draw the bounding box of the entity when it is selected.
BMP icon drawn over the entity.
When true, the icon will be drawn on top of the entity, otherwise the icon will be drawn just under it.
You can add special comments behind a variable which can be utilized by the engine. Currently you can change the default sliders inside the editor by providing information about a number variable.
... tells the engine that:
- The value is limited to values between 25 and 100.
- In case of a decimal it will us a step of 0.01, this defines the fidelity of which the value can be changed in the editor.
- "Damage treshold" will be added to the tooltip which pops up when you hover over a variable to provide additional information.
The Script Entity can include several callback functions called by the engine or game system. Look at the Callback References for more information.