Creating a custom entity
Now that we've learned the basics of the entity system, it's time to create our first entity. For this exercise, we'll be demonstrating the ability to create an entity in Lua, C#, and finally C++.
Creating an entity using Lua
Lua entities are fairly simple to set up, and revolve around two files: the entity definition, and the script itself. To create a new Lua entity, we'll first have to create the entity definition in order to tell the engine where the script is located:
<Entity Name="MyLuaEntity" Script="Scripts/Entities/Others/MyLuaEntity.lua" />
Simply save this file as MyLuaEntity.ent
in the Game/Entities/
directory, and the engine will search for the script at Scripts/Entities/Others/MyLuaEntity.lua
.
Now we can move on to creating the Lua script itself! To start, create the script at the path set previously and add an empty table with the same name as your entity:
MyLuaEntity = { }
When parsing the script, the first thing the engine does is search for...