diff options
author | Ciaran Gultnieks <ciaran@ciarang.com> | 2014-02-07 18:05:23 +0000 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-02-07 18:07:56 -0500 |
commit | 1a5efd07f1360059e70b450734c9a6df0a2f46ca (patch) | |
tree | a1a139be2a12e289029160027a2da12e48fc4b31 /chatcommands.lua | |
parent | a8e5b90aebc0fae02c8ccd88fe3399d5e48d4b6f (diff) |
Allow areas to be optionally open to all other users
In other words, you can retain ownership of an area but disable and
re-enable the protection aspect at will, via the area_open chat command.
By default, nothing is any different following this commit - all
existing areas are protected, as are new ones. But you can do (for
example) "area_open 1" and if you're the owner of that area, it's
now possible for other users to interact there. "area_open 1" again to
toggle the protection back on.
Where there are sub-areas, the main owner and ALL sub-area owners at a
particulare location must have set the areas to open to disable
protection.
Diffstat (limited to 'chatcommands.lua')
-rw-r--r-- | chatcommands.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/chatcommands.lua b/chatcommands.lua index 00a31b0..e533602 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -305,3 +305,29 @@ minetest.register_chatcommand("change_owner", { name..'" has given you control over an area.') end}) +minetest.register_chatcommand("area_open", { + params = "<id>", + description = "Toggle an area open (anyone can interact) or not", + privs = {}, + func = function(name, param) + local id = tonumber(param) + + if not id then + minetest.chat_send_player(name, + "Invalid usage, see /help area_open") + return + end + + if not areas:isAreaOwner(id, name) then + minetest.chat_send_player(name, + "Area "..id.." does not exist" + .." or is not owned by you.") + return + end + local open = not areas.areas[id].open + -- Save false as nil to avoid inflating the DB. + areas.areas[id].open = open or nil + areas:save() + minetest.chat_send_player(name, "Area "..(open and "opened" or "closed")..".") +end}) + |