1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-09-27 15:00:35 +02:00

added news area openfarming

added area openfarming, anyone can interact only with farming mod(group plant).
added  chatcommand area_openfarming "/area_openfarming <ID>".
added display in hud when area is open to farming.
This commit is contained in:
crabman77 2015-03-02 19:19:42 +01:00
parent 4e2c557a62
commit 1cf4e252f9
4 changed files with 35 additions and 1 deletions

View File

@ -90,6 +90,10 @@ Chat commands
* /area\_pos2 \[X,Y,Z|X Y Z\]
Sets area position two to your position or the one supplied.
* `/area_open <ID>` -- Sets the area open, anyone can interact.
* `/area_openfarming <ID>` -- Sets the area openfarming, anyone can interact only farming mod.
License
-------
Copyright (C) 2013 ShadowNinja

View File

@ -25,6 +25,13 @@ function areas:canInteract(pos, name)
for _, area in pairs(self:getAreasAtPos(pos)) do
if area.owner == name or area.open then
return true
elseif area.openfarming then
-- if area is openfarming and node is in group plant, action is authorized
local node = minetest.get_node(pos).name
if minetest.registered_nodes[node] and minetest.get_item_group(node, "plant") == 1 then
return true
end
return false
else
owned = true
end

View File

@ -285,6 +285,29 @@ minetest.register_chatcommand("area_open", {
end
})
minetest.register_chatcommand("area_openfarming", {
params = "<ID>",
description = "Toggle an area open (anyone can interact farming) or closed",
func = function(name, param)
local id = tonumber(param)
if not id then
return false, "Invalid usage, see /help area_openfarming."
end
if not areas:isAreaOwner(id, name) then
return false, "Area "..id.." does not exist"
.." or is not owned by you."
end
local openfarming = not areas.areas[id].openfarming
-- Save false as nil to avoid inflating the DB.
areas.areas[id].openfarming = openfarming or nil
areas:save()
return true, ("Area %s to farming."):format(openfarming and "opened" or "closed")
end
})
minetest.register_chatcommand("move_area", {
params = "<ID>",
description = "Move (or resize) an area to the current positions.",

View File

@ -10,7 +10,7 @@ minetest.register_globalstep(function(dtime)
for id, area in pairs(areas:getAreasAtPos(pos)) do
table.insert(areaStrings, ("%s [%u] (%s%s)")
:format(area.name, id, area.owner,
area.open and ":open" or ""))
area.open and ":open" or area.openfarming and ":open to farming" or ""))
end
local areaString = "Areas:"
if #areaStrings > 0 then