initialize GoL variables, add sim.gspeed function

This commit is contained in:
jacob1
2015-10-10 00:02:53 -04:00
parent 9a65d60c6e
commit bc112b54df
3 changed files with 18 additions and 0 deletions

View File

@@ -742,6 +742,7 @@ void LuaScriptInterface::initSimulationAPI()
{"neighbours", simulation_neighbours}, {"neighbours", simulation_neighbours},
{"neighbors", simulation_neighbours}, {"neighbors", simulation_neighbours},
{"framerender", simulation_framerender}, {"framerender", simulation_framerender},
{"gspeed", simulation_gspeed},
{NULL, NULL} {NULL, NULL}
}; };
luaL_register(l, "simulation", simulationAPIMethods); luaL_register(l, "simulation", simulationAPIMethods);
@@ -1981,6 +1982,20 @@ int LuaScriptInterface::simulation_framerender(lua_State * l)
return 0; return 0;
} }
int LuaScriptInterface::simulation_gspeed(lua_State * l)
{
if (lua_gettop(l) == 0)
{
lua_pushinteger(l, luacon_sim->GSPEED);
return 1;
}
int gspeed = luaL_checkinteger(l, 1);
if (gspeed < 1)
return luaL_error(l, "GSPEED must be at least 1");
luacon_sim->GSPEED = gspeed;
return 0;
}
//// Begin Renderer API //// Begin Renderer API
void LuaScriptInterface::initRendererAPI() void LuaScriptInterface::initRendererAPI()

View File

@@ -106,6 +106,7 @@ class LuaScriptInterface: public CommandInterface
static int simulation_photons(lua_State * l); static int simulation_photons(lua_State * l);
static int simulation_neighbours(lua_State * l); static int simulation_neighbours(lua_State * l);
static int simulation_framerender(lua_State * l); static int simulation_framerender(lua_State * l);
static int simulation_gspeed(lua_State * l);
//Renderer //Renderer
void initRendererAPI(); void initRendererAPI();

View File

@@ -5050,6 +5050,8 @@ Simulation::Simulation():
emp_decor(0), emp_decor(0),
lightningRecreate(0), lightningRecreate(0),
gravWallChanged(false), gravWallChanged(false),
CGOL(0),
GSPEED(1),
edgeMode(0), edgeMode(0),
gravityMode(0), gravityMode(0),
legacy_enable(0), legacy_enable(0),