From fc0f5d780ad54f8fadf2380330d76180f0ec077c Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Thu, 11 Sep 2014 18:17:01 +0200 Subject: [PATCH] CLuaInstance: Add overloaded member tableLookup() for bool vars --- src/gui/luainstance.cpp | 12 ++++++++++++ src/gui/luainstance.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 1f59cc8ca..d35119557 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -971,6 +971,18 @@ bool CLuaInstance::tableLookup(lua_State *L, const char *what, void** value) return res; } +bool CLuaInstance::tableLookup(lua_State *L, const char *what, bool &value) +{ + bool res = false; + lua_pushstring(L, what); + lua_gettable(L, -2); + res = lua_isboolean(L, -1); + if (res) + value = lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + bool CLuaMenuChangeObserver::changeNotify(lua_State *L, const std::string &luaAction, const std::string &luaId, void *Data) { const char *optionValue = (const char *) Data; diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index daf778ebf..fd34fcc9c 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -285,6 +285,7 @@ private: static bool tableLookup(lua_State*, const char*, lua_Integer&); static bool tableLookup(lua_State*, const char*, lua_Unsigned&); static bool tableLookup(lua_State*, const char*, void**); + static bool tableLookup(lua_State*, const char*, bool &value); }; #endif /* _LUAINSTANCE_H */