summaryrefslogtreecommitdiff
path: root/client/lua.cc
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 /client/lua.cc
parent5c23a4df137cedeed695657d6f7aa4d9f83d9825 (diff)
Added name to predefined lua values
Diffstat (limited to 'client/lua.cc')
-rw-r--r--client/lua.cc15
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;