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 +++++++-------- client/lua.h | 2 +- client/widgets/widget.cc | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) (limited to 'client') 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; diff --git a/client/lua.h b/client/lua.h index 92ae809..b0737a0 100644 --- a/client/lua.h +++ b/client/lua.h @@ -39,7 +39,7 @@ public: LUA(MacroWindow *macrowindow); ~LUA(); - bool run(QString program, QString value); + bool run(QString program, QString name, QString value); QString getValue(QString name); void setValue(QString name, QString value); diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index 61e2a53..25d37f6 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -83,5 +83,5 @@ bool Widget::luaValidator() { if(!hasluaprogram) return true; - return macrowindow->lua->run(luaprogram, getValue()); + return macrowindow->lua->run(luaprogram, getName(), getValue()); } -- cgit v1.2.3