diff --git a/luaManager.cpp b/luaManager.cpp index be72055..2fe81c2 100644 --- a/luaManager.cpp +++ b/luaManager.cpp @@ -19,13 +19,17 @@ namespace gameBase{ } void LuaManager::buildScript(vector files){ - string script = ""; + string script = ""; - for(string f : files) - script += "dofile(\"" + f + "\");"; + for(string f : files) + script += "dofile(\"" + f + "\");"; - if(luaL_dostring(state, script.c_str()) && lua_pcall(state, 0, 0, 0)) - cout << "Error building Lua script\n"; + executeCode(script, "Error building script(s)\n"); + } + + void LuaManager::executeCode(string code, string errMsg){ + if(luaL_dostring(state, code.c_str()) && lua_pcall(state, 0, 0, 0)) + cout << errMsg; } int LuaManager::getInt(string varName){ diff --git a/luaManager.h b/luaManager.h index c3194f0..fcd0826 100644 --- a/luaManager.h +++ b/luaManager.h @@ -34,6 +34,7 @@ namespace gameBase{ static LuaManager* getSingleton(); inline lua_State* getState(){return state;} void buildScript(std::vector); + void executeCode(std::string, std::string = "Error executing code\n"); int getInt(std::string); float getFloat(std::string); int getIntFromTable(std::string, std::vector);