From ff403df10813717698dc47e0b22f19d62c007cff Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Thu, 16 Oct 2014 13:28:44 +0200 Subject: added getInt to LuaVm --- include/luaglue/LuaVM.hpp | 1 + src/libluaglue/LuaVM.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/luaglue/LuaVM.hpp b/include/luaglue/LuaVM.hpp index 81261f3..6055fd4 100755 --- a/include/luaglue/LuaVM.hpp +++ b/include/luaglue/LuaVM.hpp @@ -27,6 +27,7 @@ class LuaVM LUAGLUE_DLL_VISIBLE std::string getString( const std::string &key ); LUAGLUE_DLL_VISIBLE std::vector getStringArray( const std::string &key ); + LUAGLUE_DLL_VISIBLE int getInt( const std::string &key ); LUAGLUE_DLL_VISIBLE bool getBoolean( const std::string &key ); LUAGLUE_DLL_VISIBLE lua_State *handle( ); diff --git a/src/libluaglue/LuaVM.cpp b/src/libluaglue/LuaVM.cpp index 566e516..9764707 100644 --- a/src/libluaglue/LuaVM.cpp +++ b/src/libluaglue/LuaVM.cpp @@ -262,6 +262,18 @@ string LuaVM::getString( const string &key ) return res; } +int LuaVM::getInt( const std::string &key ) +{ + int n = findValue( key ); + + int res = lua_tointeger( m_lua, -1 ); + lua_pop( m_lua, n ); + + //dumpStack( ); + + return res; +} + bool LuaVM::getBoolean( const string &key ) { int n = findValue( key ); -- cgit v1.2.3-54-g00ecf