From bc112b54dff4c4e78ce2758dd5a45e03f44b51d4 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 10 Oct 2015 00:02:53 -0400 Subject: [PATCH] initialize GoL variables, add sim.gspeed function --- src/lua/LuaScriptInterface.cpp | 15 +++++++++++++++ src/lua/LuaScriptInterface.h | 1 + src/simulation/Simulation.cpp | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index 4a6549eb90..9edcc8508c 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -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); @@ -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() diff --git a/src/lua/LuaScriptInterface.h b/src/lua/LuaScriptInterface.h index 6f970c41d9..105cebfd1b 100644 --- a/src/lua/LuaScriptInterface.h +++ b/src/lua/LuaScriptInterface.h @@ -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(); diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 8b7c5501b0..2723701ac8 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -5050,6 +5050,8 @@ Simulation::Simulation(): emp_decor(0), lightningRecreate(0), gravWallChanged(false), + CGOL(0), + GSPEED(1), edgeMode(0), gravityMode(0), legacy_enable(0),