Builtin: Add basic_privs setting
authorrubenwardy <rubenwardy@gmail.com>
Sat, 9 Apr 2016 15:07:45 +0000 (16:07 +0100)
committerparamat <mat.gregory@virginmedia.com>
Thu, 28 Apr 2016 06:19:07 +0000 (07:19 +0100)
builtin/game/chatcommands.lua
builtin/settingtypes.txt
doc/lua_api.txt
minetest.conf.example

index 4deff281dd5f53f8001f38c3e89a9f66884eb3b4..7480446f2552625547ae3d81734631dd0bfd9360 100644 (file)
@@ -181,8 +181,10 @@ core.register_chatcommand("grant", {
                end
                local privs = core.get_player_privs(grantname)
                local privs_unknown = ""
+               local basic_privs =
+                       core.string_to_privs(core.setting_get("basic_privs") or "interact,shout")
                for priv, _ in pairs(grantprivs) do
-                       if priv ~= "interact" and priv ~= "shout" and
+                       if not basic_privs[priv] and
                                        not core.check_player_privs(name, {privs=true}) then
                                return false, "Your privileges are insufficient."
                        end
@@ -223,8 +225,10 @@ core.register_chatcommand("revoke", {
                end
                local revoke_privs = core.string_to_privs(revoke_priv_str)
                local privs = core.get_player_privs(revoke_name)
+               local basic_privs =
+                       core.string_to_privs(core.setting_get("basic_privs") or "interact,shout")
                for priv, _ in pairs(revoke_privs) do
-                       if priv ~= "interact" and priv ~= "shout" and
+                       if not basic_privs[priv] and
                                        not core.check_player_privs(name, {privs=true}) then
                                return false, "Your privileges are insufficient."
                        end
index ca331ff4e46ec4fdc5e63cba8af98d5e472b4155..0a951961010d7c1cb99df399860b715b8207b047 100644 (file)
@@ -691,6 +691,9 @@ default_password (Default password) string
 #    See /privs in game for a full list on your server and mod configuration.
 default_privs (Default privileges) string interact, shout
 
+#    Privileges that players with basic_privs can grant
+basic_privs (Basic Privileges) string interact, shout
+
 #    Whether players are shown to clients without any range limit.
 #    Deprecated, use the setting player_transfer_distance instead.
 unlimited_player_transfer_distance (Unlimited player transfer distance) bool true
index 47624496baac9db53aee9b0ec4bedd2b2762e21d..4b5f969d30dd8606a61b759078d8ef8fe7f6df51 100644 (file)
@@ -1924,6 +1924,7 @@ Call these functions only at load time!
 * `minetest.register_privilege(name, definition)`
     * `definition`: `"description text"`
     * `definition`: `{ description = "description text", give_to_singleplayer = boolean, -- default: true }`
+    * To allow players with basic_privs to grant, see basic_privs minetest.conf setting.
 * `minetest.register_authentication_handler(handler)`
     * See `minetest.builtin_auth_handler` in `builtin.lua` for reference
 
index e913140ae32772285cb67334e7f008e093459c75..6f0eb7869fde4a28c002809100f19e562bbdaf53 100644 (file)
 #    type: string
 # default_privs = interact, shout
 
+#    Privileges that players with basic_privs can grant
+#    type: string
+# basic_privs = interact, shout
+
 #    Whether players are shown to clients without any range limit.
 #    Deprecated, use the setting player_transfer_distance instead.
 #    type: bool
 
 #    type: string
 # modstore_details_url = https://forum.minetest.net/mmdb/mod/*/
-