Repository navigation
mainLua
#main.lua
This is the starting point for the application. It sets up the list of systems being used as well as the starting entities in the game.
This file creates two global variables, systems and entities.
systems is a table containing the names of the systems you will be using.
entities is a table of entities. Each entity is a table of components.
In addition to these tables, there are a couple of helper functions to make scene setup easier.
(int)id = add_entity((table)entity)
Adds the entity to the entities table and returns the index of that entity.
(table)ids = add_entities((table)entities)
Adds a list of entities and returns a list of there ids.
###Example This file can be structured in any way possible. It just has to set up the 2 global variables. This is probably the simplest way to create these variables.
systems = {
--built in systems
"Ogre_Render_System",
"OIS_Input_System",
"Bullet_System",
"Pause_System",
--custom systems
"camera_controller",
"follow_entity"
}
entities = {}
add_entity{
Camera = {near_clip = 2},
Transform = {
pos = Vec3f(0, 0, 0),
},
custom_camera_mover = {}
}
local light = {
Transform = {pos = Vec3f(0, 10, 0) },
Light = {},
follow_component = {following = 0}
}
add_entity(light)
local player_id = add_entity{
Transform = {pos = Vec3f(10, 0, 0) },
Mesh = { filename = "mymesh.mesh" },
}
light.follow_component.following = player_id;