mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-15 15:00:34 +01: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:
parent
4e2c557a62
commit
1cf4e252f9
|
@ -90,6 +90,10 @@ Chat commands
|
||||||
* /area\_pos2 \[X,Y,Z|X Y Z\]
|
* /area\_pos2 \[X,Y,Z|X Y Z\]
|
||||||
Sets area position two to your position or the one supplied.
|
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
|
License
|
||||||
-------
|
-------
|
||||||
Copyright (C) 2013 ShadowNinja
|
Copyright (C) 2013 ShadowNinja
|
||||||
|
|
|
@ -25,6 +25,13 @@ function areas:canInteract(pos, name)
|
||||||
for _, area in pairs(self:getAreasAtPos(pos)) do
|
for _, area in pairs(self:getAreasAtPos(pos)) do
|
||||||
if area.owner == name or area.open then
|
if area.owner == name or area.open then
|
||||||
return true
|
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
|
else
|
||||||
owned = true
|
owned = true
|
||||||
end
|
end
|
||||||
|
|
|
@ -285,6 +285,29 @@ minetest.register_chatcommand("area_open", {
|
||||||
end
|
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", {
|
minetest.register_chatcommand("move_area", {
|
||||||
params = "<ID>",
|
params = "<ID>",
|
||||||
description = "Move (or resize) an area to the current positions.",
|
description = "Move (or resize) an area to the current positions.",
|
||||||
|
|
|
@ -10,7 +10,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
for id, area in pairs(areas:getAreasAtPos(pos)) do
|
for id, area in pairs(areas:getAreasAtPos(pos)) do
|
||||||
table.insert(areaStrings, ("%s [%u] (%s%s)")
|
table.insert(areaStrings, ("%s [%u] (%s%s)")
|
||||||
:format(area.name, id, area.owner,
|
:format(area.name, id, area.owner,
|
||||||
area.open and ":open" or ""))
|
area.open and ":open" or area.openfarming and ":open to farming" or ""))
|
||||||
end
|
end
|
||||||
local areaString = "Areas:"
|
local areaString = "Areas:"
|
||||||
if #areaStrings > 0 then
|
if #areaStrings > 0 then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user