mirror of
https://github.com/devZoGok/gameBase.git
synced 2026-08-26 19:43:28 +00:00
added code execution method
This commit is contained in:
+9
-5
@@ -19,13 +19,17 @@ namespace gameBase{
|
||||
}
|
||||
|
||||
void LuaManager::buildScript(vector<string> 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){
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace gameBase{
|
||||
static LuaManager* getSingleton();
|
||||
inline lua_State* getState(){return state;}
|
||||
void buildScript(std::vector<std::string>);
|
||||
void executeCode(std::string, std::string = "Error executing code\n");
|
||||
int getInt(std::string);
|
||||
float getFloat(std::string);
|
||||
int getIntFromTable(std::string, std::vector<Index>);
|
||||
|
||||
Reference in New Issue
Block a user