Skip to content

Commit

Permalink
initialize GoL variables, add sim.gspeed function
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Oct 10, 2015
1 parent 9a65d60 commit bc112b5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lua/LuaScriptInterface.cpp
Expand Up @@ -742,6 +742,7 @@ void LuaScriptInterface::initSimulationAPI()
{"neighbours", simulation_neighbours},
{"neighbors", simulation_neighbours},
{"framerender", simulation_framerender},
{"gspeed", simulation_gspeed},
{NULL, NULL}
};
luaL_register(l, "simulation", simulationAPIMethods);
Expand Down Expand Up @@ -1981,6 +1982,20 @@ int LuaScriptInterface::simulation_framerender(lua_State * l)
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

void LuaScriptInterface::initRendererAPI()
Expand Down
1 change: 1 addition & 0 deletions src/lua/LuaScriptInterface.h
Expand Up @@ -106,6 +106,7 @@ class LuaScriptInterface: public CommandInterface
static int simulation_photons(lua_State * l);
static int simulation_neighbours(lua_State * l);
static int simulation_framerender(lua_State * l);
static int simulation_gspeed(lua_State * l);

//Renderer
void initRendererAPI();
Expand Down
2 changes: 2 additions & 0 deletions src/simulation/Simulation.cpp
Expand Up @@ -5050,6 +5050,8 @@ Simulation::Simulation():
emp_decor(0),
lightningRecreate(0),
gravWallChanged(false),
CGOL(0),
GSPEED(1),
edgeMode(0),
gravityMode(0),
legacy_enable(0),
Expand Down

0 comments on commit bc112b5

Please sign in to comment.