diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client.h | 3 | ||||
-rw-r--r-- | src/script/lua_api/l_client.cpp | 11 | ||||
-rw-r--r-- | src/script/lua_api/l_client.h | 4 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/client.h b/src/client.h index 149fdfe57..9aec0d061 100644 --- a/src/client.h +++ b/src/client.h @@ -416,6 +416,9 @@ public: bool checkPrivilege(const std::string &priv) const { return (m_privileges.count(priv) != 0); } + const std::unordered_set<std::string> &getPrivilegeList() const + { return m_privileges; } + bool getChatMessage(std::wstring &message); void typeChatMessage(const std::wstring& message); diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 3c2955bcd..eab7bdfae 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -329,6 +329,16 @@ int ModApiClient::l_take_screenshot(lua_State *L) return 0; } +int ModApiClient::l_get_privilege_list(lua_State *L) +{ + const Client *client = getClient(L); + lua_newtable(L); + for (const std::string &priv : client->getPrivilegeList()) { + lua_pushboolean(L, true); + lua_setfield(L, -2, priv.c_str()); + } + return 1; +} void ModApiClient::Initialize(lua_State *L, int top) { API_FCT(get_current_modname); @@ -353,4 +363,5 @@ void ModApiClient::Initialize(lua_State *L, int top) API_FCT(get_item_def); API_FCT(get_node_def); API_FCT(take_screenshot); + API_FCT(get_privilege_list); } diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h index fe5780fb1..2f0c2e3f8 100644 --- a/src/script/lua_api/l_client.h +++ b/src/script/lua_api/l_client.h @@ -89,8 +89,12 @@ private: // get_node_def(nodename) static int l_get_node_def(lua_State *L); + // take_screenshot() static int l_take_screenshot(lua_State *L); + // get_privilege_list() + static int l_get_privilege_list(lua_State *L); + public: static void Initialize(lua_State *L, int top); }; |