diff options
Diffstat (limited to 'client/lua.cc')
-rw-r--r-- | client/lua.cc | 15 |
1 files changed, 7 insertions, 8 deletions
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; |