#include "luascript.h" LuaScript::LuaScript(const std::string& filename) { L = luaL_newstate(); } LuaScript::~LuaScript() { if(L) lua_close(L); } bool LuaScript::GetExecutionStatus( ) { return LualExecutionIsOk; } void LuaScript::loadFile(const std::string& fileName) { int status = luaL_loadfile(L, fileName.c_str()); if (status) { std::cout<<"ERROR RIGHT HERE"<getTop()); } std::vector LuaScript::getIntVector(const std::string& name) { std::vector v; lua_gettostack(name.c_str()); if(lua_isnil(L, -1)) { // array is not found return std::vector(); } lua_pushnil(L); while(lua_next(L, -2)) { v.push_back((int)lua_tonumber(L, -1)); lua_pop(L, 1); } clean(); return v; } std::vector LuaScript::getTableKeys(const std::string& name) { std::string code = "function getKeys(name) " "s = \"\"" "for k, v in pairs(_G[name]) do " " s = s..k..\",\" " " end " "return s " "end"; // function for getting table keys luaL_loadstring(L, code.c_str()); // execute code lua_pcall(L,0,0,0); lua_getglobal(L, "getKeys"); // get function lua_pushstring(L, name.c_str()); lua_pcall(L, 1 , 1, 0); // execute function std::string test = lua_tostring(L, -1); std::vector strings; std::string temp = ""; std::cout<<"TEMP:"<