From 0543325eb3f00c6e8ee1eb1b493708060439d54b Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 4 Jun 2008 12:10:55 +0000 Subject: Added name to predefined lua values --- client/lua.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'client/lua.cc') diff --git a/client/lua.cc b/client/lua.cc index 2299acc..7902cd2 100644 --- a/client/lua.cc +++ b/client/lua.cc @@ -28,9 +28,7 @@ #include "macrowindow.h" -#define GLOBAL_POINTER "_pracroGlobalLUAObjectPointer" - -LUA *glua; +#define GLOBAL_POINTER "_pracroGlobalLUAObjectPointerThisShouldBeANameThatIsNotAccidentallyOverwritten" static int _getValue(lua_State *L) { @@ -47,7 +45,7 @@ static int _getValue(lua_State *L) QString name = lua_tostring(L, lua_gettop(L)); lua_getglobal(L, GLOBAL_POINTER); - LUA *lua = glua;//(LUA*)lua_touserdata(L, 1); + LUA *lua = (LUA*)lua_touserdata(L, lua_gettop(L)); if(!lua) { printf("No LUA pointer!\n"); @@ -80,7 +78,7 @@ static int _setValue(lua_State *L) lua_pop(L, 1); lua_getglobal(L, GLOBAL_POINTER); - LUA *lua = glua;//(LUA*)lua_touserdata(L, 1); + LUA *lua = (LUA*)lua_touserdata(L, lua_gettop(L)); if(!lua) { printf("No LUA pointer!\n"); @@ -96,7 +94,6 @@ static int _setValue(lua_State *L) LUA::LUA(MacroWindow *macrowindow) { - glua = this; this->macrowindow = macrowindow; L = luaL_newstate(); @@ -128,11 +125,13 @@ void LUA::setValue(QString name, QString value) macrowindow->setValue(name, value); } -bool LUA::run(QString program, QString value) +bool LUA::run(QString program, QString name, QString value) { + printf("Running %s\n", program.toStdString().c_str()); + if(macrowindow->luaprograms.contains(program) == false) return false; - QString luacode = "value = " + value + "\n"; + QString luacode = "value = " + value + "\nname = " + name + "\n"; QString luaprogram = macrowindow->luaprograms.value(program); luacode += luaprogram; -- cgit v1.2.3