summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api.lua4
-rw-r--r--chatcommands.lua26
-rw-r--r--hud.lua6
3 files changed, 34 insertions, 2 deletions
diff --git a/api.lua b/api.lua
index 95a3987..a83120d 100644
--- a/api.lua
+++ b/api.lua
@@ -24,7 +24,9 @@ function areas:canInteract(pos, name)
if area.owner == name then
return true
else
- owned = true
+ if not area.open then
+ owned = true
+ end
end
end
return not owned
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})
+
diff --git a/hud.lua b/hud.lua
index 1280afa..19a3f35 100644
--- a/hud.lua
+++ b/hud.lua
@@ -15,7 +15,11 @@ minetest.register_globalstep(function(dtime)
else
first = false
end
- areaString = areaString..id.." ("..area.owner..")"
+ local ownertxt = area.owner
+ if area.open then
+ ownertxt = ownertxt.."/open"
+ end
+ areaString = areaString..id.." ("..ownertxt..")"
end
if not areas.hud[name] then
areas.hud[name] = {}