From c91a8c7061c83a33cca929859ea811afb985ac0a Mon Sep 17 00:00:00 2001 From: red-001 Date: Wed, 7 Jun 2017 08:09:06 +0100 Subject: [CSM] Add function to get player privileges (#5933) * [CSM] Add function to get player privileges + move related help functions to common * Added @Zeno- const --- src/script/lua_api/l_client.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/script/lua_api/l_client.cpp') 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); } -- cgit v1.2.3