added string extraction method

This commit is contained in:
devZoGok
2022-07-03 16:06:31 +03:00
parent 8e9c4d6e84
commit 56cd618b46
2 changed files with 11 additions and 0 deletions
+8
View File
@@ -36,6 +36,14 @@ namespace gameBase{
return var;
}
string LuaManager::getString(string varName){
lua_getglobal(state, varName.c_str());
string result = lua_tostring(state, -1);
lua_pop(state, 1);
return result;
}
void LuaManager::prepareTableForRetrieval(string table, vector<Index> &indices){
lua_getglobal(state, table.c_str());
+3
View File
@@ -29,12 +29,15 @@ namespace gameBase{
bool getBoolFromTable(std::string, std::vector<Index>);
float getFloatFromTable(std::string, std::vector<Index>);
std::string getStringFromTable(std::string, std::vector<Index>);
std::string getString(std::string);
private:
LuaManager();
void prepareTableForRetrieval(std::string, std::vector<Index>&);
lua_State *state = nullptr;
};
typedef LuaManager::Index Index;
}
#endif