aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-04-01 01:10:06 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-04-01 01:10:29 +0300
commitd5594e431c841bf6a4c97bac946ef188404df129 (patch)
tree6f154602c2f76098a727ba294f32d447331d84f6
parent7bfa2d4da60ce2fa2754ea42e8c73314e24ca220 (diff)
downloadminetest-d5594e431c841bf6a4c97bac946ef188404df129.tar.gz
minetest-d5594e431c841bf6a4c97bac946ef188404df129.tar.bz2
minetest-d5594e431c841bf6a4c97bac946ef188404df129.zip
granting and revoking of all privileges at once
-rw-r--r--builtin/builtin.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/builtin/builtin.lua b/builtin/builtin.lua
index d681faa73..862683a90 100644
--- a/builtin/builtin.lua
+++ b/builtin/builtin.lua
@@ -994,7 +994,7 @@ minetest.register_chatcommand("privs", {
end,
})
minetest.register_chatcommand("grant", {
- params = "<name> <privilege>",
+ params = "<name> <privilege>|all",
description = "Give privilege to player",
privs = {privs=true},
func = function(name, param)
@@ -1004,6 +1004,9 @@ minetest.register_chatcommand("grant", {
return
end
local grantprivs = minetest.string_to_privs(grantprivstr)
+ if grantprivstr == "all" then
+ grantprivs = minetest.registered_privileges
+ end
local privs = minetest.get_player_privs(grantname)
for priv, _ in pairs(grantprivs) do
privs[priv] = true
@@ -1016,7 +1019,7 @@ minetest.register_chatcommand("grant", {
end,
})
minetest.register_chatcommand("revoke", {
- params = "<name> <privilege>",
+ params = "<name> <privilege>|all",
description = "Remove privilege from player",
privs = {privs=true},
func = function(name, param)
@@ -1027,8 +1030,12 @@ minetest.register_chatcommand("revoke", {
end
local revokeprivs = minetest.string_to_privs(revokeprivstr)
local privs = minetest.get_player_privs(revokename)
- for priv, _ in pairs(revokeprivs) do
- privs[priv] = nil
+ if revokeprivstr == "all" then
+ privs = {}
+ else
+ for priv, _ in pairs(revokeprivs) do
+ privs[priv] = nil
+ end
end
minetest.set_player_privs(revokename, privs)
minetest.chat_send_player(name, "Privileges of "..revokename..": "..minetest.privs_to_string(minetest.get_player_privs(revokename), ' '))