diff --git a/source/shared_lib/sources/lua/lua_script.cpp b/source/shared_lib/sources/lua/lua_script.cpp index 6d9104bf..433d86ab 100644 --- a/source/shared_lib/sources/lua/lua_script.cpp +++ b/source/shared_lib/sources/lua/lua_script.cpp @@ -96,13 +96,14 @@ void LuaScript::loadCode(const string &code, const string &name){ void LuaScript::beginCall(const string& functionName) { Lua_STREFLOP_Wrapper streflopWrapper; + currentLuaFunction = functionName; SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] functionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,functionName.c_str()); SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] functionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,functionName.c_str()); lua_getglobal(luaState, functionName.c_str()); - currentLuaFunctionIsValid = (lua_isfunction(luaState,lua_gettop(luaState)) == 1); + currentLuaFunctionIsValid = lua_isfunction(luaState,lua_gettop(luaState)); argumentCount= 0; } @@ -117,6 +118,10 @@ void LuaScript::endCall() { throw runtime_error("Error calling lua function [" + currentLuaFunction + "] error: " + errorToString(errorCode)); } } + else + { + lua_pcall(luaState, argumentCount, 0, 0); + } } void LuaScript::registerFunction(LuaFunction luaFunction, const string &functionName) {