Skip to content

Commit bc112b5

Browse files
committed
initialize GoL variables, add sim.gspeed function
1 parent 9a65d60 commit bc112b5

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/lua/LuaScriptInterface.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ void LuaScriptInterface::initSimulationAPI()
742742
{"neighbours", simulation_neighbours},
743743
{"neighbors", simulation_neighbours},
744744
{"framerender", simulation_framerender},
745+
{"gspeed", simulation_gspeed},
745746
{NULL, NULL}
746747
};
747748
luaL_register(l, "simulation", simulationAPIMethods);
@@ -1981,6 +1982,20 @@ int LuaScriptInterface::simulation_framerender(lua_State * l)
19811982
return 0;
19821983
}
19831984

1985+
int LuaScriptInterface::simulation_gspeed(lua_State * l)
1986+
{
1987+
if (lua_gettop(l) == 0)
1988+
{
1989+
lua_pushinteger(l, luacon_sim->GSPEED);
1990+
return 1;
1991+
}
1992+
int gspeed = luaL_checkinteger(l, 1);
1993+
if (gspeed < 1)
1994+
return luaL_error(l, "GSPEED must be at least 1");
1995+
luacon_sim->GSPEED = gspeed;
1996+
return 0;
1997+
}
1998+
19841999
//// Begin Renderer API
19852000

19862001
void LuaScriptInterface::initRendererAPI()

src/lua/LuaScriptInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class LuaScriptInterface: public CommandInterface
106106
static int simulation_photons(lua_State * l);
107107
static int simulation_neighbours(lua_State * l);
108108
static int simulation_framerender(lua_State * l);
109+
static int simulation_gspeed(lua_State * l);
109110

110111
//Renderer
111112
void initRendererAPI();

src/simulation/Simulation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5050,6 +5050,8 @@ Simulation::Simulation():
50505050
emp_decor(0),
50515051
lightningRecreate(0),
50525052
gravWallChanged(false),
5053+
CGOL(0),
5054+
GSPEED(1),
50535055
edgeMode(0),
50545056
gravityMode(0),
50555057
legacy_enable(0),

0 commit comments

Comments
 (0)