CLuaInstance: Add overloaded member tableLookup() for bool vars

This commit is contained in:
M. Liebmann
2014-09-11 18:17:01 +02:00
parent c49ceac121
commit fc0f5d780a
2 changed files with 13 additions and 0 deletions

View File

@@ -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;

View File

@@ -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 */