summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2008-06-04 12:10:55 +0000
committerdeva <deva>2008-06-04 12:10:55 +0000
commit0543325eb3f00c6e8ee1eb1b493708060439d54b (patch)
tree34b15b73ad6d6941afc0551ea6a03c702def41c5
parent5c23a4df137cedeed695657d6f7aa4d9f83d9825 (diff)
Added name to predefined lua values
-rw-r--r--client/lua.cc15
-rw-r--r--client/lua.h2
-rw-r--r--client/widgets/widget.cc2
3 files changed, 9 insertions, 10 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;
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());
}