diff --git a/src/TLuaInterpreter.cpp b/src/TLuaInterpreter.cpp index 000011c..94f7e4e 100644 --- a/src/TLuaInterpreter.cpp +++ b/src/TLuaInterpreter.cpp @@ -782,7 +782,7 @@ int TLuaInterpreter::updateMap(lua_State * L){ if (pHost->mpMap->mpMapper->mp2dMap) pHost->mpMap->mpMapper->mp2dMap->update(); } - return 1; + return 0; } int TLuaInterpreter::centerview( lua_State * L ) @@ -8924,12 +8924,25 @@ bool TLuaInterpreter::callMulti( QString & function, QString & mName ) else return false; } - bool TLuaInterpreter::callEventHandler( QString & function, TEvent * pE ) { lua_State * L = pGlobalLua; - lua_getglobal( L, function.toLatin1().data() ); - lua_getfield( L, LUA_GLOBALSINDEX, function.toLatin1().data() ); + + int error = luaL_dostring(L, QString("return " + function).toLatin1().data()); + QString n; + if( error != 0 ) + { + string e = "no error message available from Lua"; + if( lua_isstring( L, 1 ) ) + { + e = "Lua error:"; + e += lua_tostring( L, 1 ); + } + emit signalEchoMessage( mHostID, QString( e.c_str() ) ); + qDebug()<< "LUA_ERROR:"<mArgumentList.size(); i++ ) { if( pE->mArgumentTypeList[i] == ARGUMENT_TYPE_NUMBER ) @@ -8941,13 +8954,13 @@ bool TLuaInterpreter::callEventHandler( QString & function, TEvent * pE ) lua_pushstring( L, pE->mArgumentList[i].toLatin1().data() ); } } - int error = lua_pcall( L, pE->mArgumentList.size(), LUA_MULTRET, 0 ); + error = lua_pcall( L, pE->mArgumentList.size(), LUA_MULTRET, 0 ); if( error != 0 ) { string e = ""; - if(lua_isstring( L, 1) ) + if(lua_isstring( L, -1) ) { - e+=lua_tostring( L, 1 ); + e+=lua_tostring( L, -1 ); } QString _n = "event handler function"; logError( e, _n, function ); @@ -8958,7 +8971,6 @@ bool TLuaInterpreter::callEventHandler( QString & function, TEvent * pE ) else return false; } - void TLuaInterpreter::set_lua_table( QString & tableName, QStringList & variableList ) { lua_State * L = pGlobalLua; @@ -9333,7 +9345,7 @@ void TLuaInterpreter::initLuaGlobals() int error; // if using LuaJIT, adjust the cpath to look in /usr/lib as well - it doesn't by default - luaL_dostring (pGlobalLua, "if jit then package.cpath = package.cpath .. ';/usr/lib/lua/5.1/?.so;' end"); + luaL_dostring (pGlobalLua, "if jit then package.cpath = package.cpath .. ';/usr/lib/lua/5.1/?.so;/usr/lib/x86_64-linux-gnu/lua/5.1/?.so' end"); error = luaL_dostring( pGlobalLua, "require \"rex_pcre\"" );