From 4c096a03d6da2ce3576ea5866f8cd2e4a2d8c368 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Sun, 27 Nov 2022 19:44:54 +0200 Subject: [PATCH] new method --- luaManager.cpp | 8 ++++++++ luaManager.h | 1 + 2 files changed, 9 insertions(+) diff --git a/luaManager.cpp b/luaManager.cpp index 5f486c2..be72055 100644 --- a/luaManager.cpp +++ b/luaManager.cpp @@ -36,6 +36,14 @@ namespace gameBase{ return var; } + float LuaManager::getFloat(string varName){ + lua_getglobal(state, varName.c_str()); + int isNum; + float var = (int)lua_tonumberx(state, -1, &isNum); + lua_pop(state, 1); + return var; + } + string LuaManager::getString(string varName){ lua_getglobal(state, varName.c_str()); string result = lua_tostring(state, -1); diff --git a/luaManager.h b/luaManager.h index 776f4ea..c3194f0 100644 --- a/luaManager.h +++ b/luaManager.h @@ -35,6 +35,7 @@ namespace gameBase{ inline lua_State* getState(){return state;} void buildScript(std::vector); int getInt(std::string); + float getFloat(std::string); int getIntFromTable(std::string, std::vector); bool getBoolFromTable(std::string, std::vector); float getFloatFromTable(std::string, std::vector);