summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-06-06 03:17:34 (GMT)
committer jacob1 <jfu614@gmail.com>2013-06-06 03:17:34 (GMT)
commit2119343b6a76bdc6bda0fb62cea46f0a6b2df285 (patch)
tree55b48c9d58f2f3b215aa5d5474886c2542e164a9 /src
parentc7ce3fa4b23bf14222af6403de36a501a05637a1 (diff)
downloadpowder-2119343b6a76bdc6bda0fb62cea46f0a6b2df285.zip
powder-2119343b6a76bdc6bda0fb62cea46f0a6b2df285.tar.gz
fix sim.NUM_PARTS, other small changes
Diffstat (limited to 'src')
-rw-r--r--src/cat/LuaScriptInterface.cpp20
-rw-r--r--src/cat/LuaScriptInterface.h2
-rw-r--r--src/gui/game/GameController.cpp5
-rw-r--r--src/gui/game/GameController.h5
4 files changed, 14 insertions, 18 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index b6b5506..fb01802 100644
--- a/src/cat/LuaScriptInterface.cpp
+++ b/src/cat/LuaScriptInterface.cpp
@@ -485,7 +485,6 @@ void LuaScriptInterface::initSimulationAPI()
{NULL, NULL}
};
luaL_register(l, "simulation", simulationAPIMethods);
- int simulationAPI = lua_gettop(l);
//Sim shortcut
lua_getglobal(l, "simulation");
@@ -495,7 +494,6 @@ void LuaScriptInterface::initSimulationAPI()
SETCONST(l, XRES);
SETCONST(l, YRES);
SETCONST(l, PT_NUM);
- lua_pushinteger(l, luacon_sim->NUM_PARTS); lua_setfield(l, simulationAPI, "NUM_PARTS");
SETCONST(l, R_TEMP);
SETCONST(l, MAX_TEMP);
SETCONST(l, MIN_TEMP);
@@ -506,7 +504,7 @@ void LuaScriptInterface::initSimulationAPI()
SETCONST(l, TOOL_AIR);
SETCONST(l, TOOL_PGRV);
SETCONST(l, TOOL_NGRV);
- lua_pushinteger(l, luacon_sim->tools.size()); lua_setfield(l, simulationAPI, "TOOL_WIND");
+ lua_pushinteger(l, luacon_sim->tools.size()); lua_setfield(l, -2, "TOOL_WIND");
SETCONST(l, DECO_DRAW);
SETCONST(l, DECO_CLEAR);
SETCONST(l, DECO_ADD);
@@ -524,7 +522,7 @@ void LuaScriptInterface::initSimulationAPI()
std::string propertyName = (*iter).Name;
std::transform(propertyName.begin(), propertyName.end(), propertyName.begin(), ::toupper);
lua_pushinteger(l, particlePropertiesCount);
- lua_setfield(l, simulationAPI, ("FIELD_"+propertyName).c_str());
+ lua_setfield(l, -2, ("FIELD_"+propertyName).c_str());
particleProperties[particlePropertiesCount++] = *iter;
}
}
@@ -1717,8 +1715,6 @@ void LuaScriptInterface::initElementsAPI()
lua_getglobal(l, "elements");
lua_setglobal(l, "elem");
- int elementsAPI = lua_gettop(l);
-
//Static values
//Element types/properties/states
SETCONST(l, TYPE_PART);
@@ -1770,13 +1766,13 @@ void LuaScriptInterface::initElementsAPI()
if(luacon_sim->elements[i].Enabled)
{
lua_pushinteger(l, i);
- lua_setfield(l, elementsAPI, luacon_sim->elements[i].Identifier);
+ lua_setfield(l, -2, luacon_sim->elements[i].Identifier);
char realIdentifier[20];
sprintf(realIdentifier, "DEFAULT_PT_%s", luacon_sim->elements[i].Name);
if (i != 0 && i != PT_NBHL && i != PT_NWHL && strcmp(luacon_sim->elements[i].Identifier, realIdentifier))
{
lua_pushinteger(l, i);
- lua_setfield(l, elementsAPI, realIdentifier);
+ lua_setfield(l, -2, realIdentifier);
}
}
}
@@ -2321,10 +2317,8 @@ void LuaScriptInterface::initGraphicsAPI()
lua_getglobal(l, "graphics");
lua_setglobal(l, "gfx");
- int graphicsAPI = lua_gettop(l);
-
- lua_pushinteger(l, XRES+BARSIZE); lua_setfield(l, graphicsAPI, "WIDTH");
- lua_pushinteger(l, YRES+MENUSIZE); lua_setfield(l, graphicsAPI, "HEIGHT");
+ lua_pushinteger(l, XRES+BARSIZE); lua_setfield(l, -2, "WIDTH");
+ lua_pushinteger(l, YRES+MENUSIZE); lua_setfield(l, -2, "HEIGHT");
}
int LuaScriptInterface::graphics_textSize(lua_State * l)
@@ -2781,6 +2775,8 @@ bool LuaScriptInterface::OnKeyRelease(int key, Uint16 character, bool shift, boo
void LuaScriptInterface::OnTick()
{
+ lua_getglobal(l, "simulation");
+ lua_pushinteger(l, luacon_sim->NUM_PARTS); lua_setfield(l, -2, "NUM_PARTS");
ui::Engine::Ref().LastTick(clock());
if(luacon_mousedown)
luacon_mouseevent(luacon_mousex, luacon_mousey, luacon_mousebutton, LUACON_MPRESS, 0);
diff --git a/src/cat/LuaScriptInterface.h b/src/cat/LuaScriptInterface.h
index ad0b70f..5a09be9 100644
--- a/src/cat/LuaScriptInterface.h
+++ b/src/cat/LuaScriptInterface.h
@@ -40,7 +40,7 @@ class Tool;
// idea from mniip, makes things much simpler
#define SETCONST(L, NAME)\
lua_pushinteger(L, NAME);\
- lua_setfield(L, -2, #NAME);
+ lua_setfield(L, -2, #NAME)
class TPTScriptInterface;
class LuaScriptInterface: public CommandInterface
diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp
index f4992b2..97a81c5 100644
--- a/src/gui/game/GameController.cpp
+++ b/src/gui/game/GameController.cpp
@@ -27,6 +27,11 @@
#include "gui/interface/Keys.h"
#include "simulation/Snapshot.h"
#include "debug/DebugInfo.h"
+#ifdef LUACONSOLE
+#include "cat/LuaScriptInterface.h"
+#else
+#include "cat/TPTScriptInterface.h"
+#endif
//#include "debug/ElementPopulation.h"
using namespace std;
diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h
index cc49f3b..32755df 100644
--- a/src/gui/game/GameController.h
+++ b/src/gui/game/GameController.h
@@ -14,11 +14,6 @@
#include "gui/console/ConsoleController.h"
#include "gui/localbrowser/LocalBrowserController.h"
#include "gui/options/OptionsController.h"
-#ifdef LUACONSOLE
-#include "cat/LuaScriptInterface.h"
-#else
-#include "cat/TPTScriptInterface.h"
-#endif
#include "client/ClientListener.h"
#include "RenderPreset.h"
#include "Menu.h"