12 Commits

Author SHA1 Message Date
99408df96a Delete unused textures 2020-07-05 17:10:03 +02:00
42cde6a494 Merge branch 'nalc-1.2-dev' 2020-07-05 17:02:34 +02:00
e0783cf8bf Corrige crash au démarrage 2020-06-15 01:10:47 +02:00
0b2baacb92 Merge remote-tracking branch 'upstream/master' into nalc-1.2-dev 2020-06-14 23:38:20 +02:00
54c504fa0d [areas] Remet le HUD comme avant la modif du feae996 2019-12-30 01:02:36 +01:00
26d6f56485 Ajoute description privilège \"megabuilder\" pour admins d'areas 2019-12-28 15:26:21 +01:00
57f20bb25f Ajoute infos privilège "megabuilder" dans la commande /area_info 2019-12-28 15:07:13 +01:00
feae9967dc Ajoute certaines modifications venant de MFF + ajustement HUD
* Aires openfarming
* Privilège megabuilder
* HUD légèrement modifié pour laisser de la place à celui de factions
2019-12-28 02:43:12 +01:00
c4d0fe020f Corrige lecture de paramètre de configuration 2018-12-24 02:22:29 +01:00
b0c229d80a Restore upstream default config 2016-08-23 15:43:33 +02:00
d7fba610a1 Don't use auth_table, use get_auth_handler().get_auth instead
No guarantee is made auth_table contains auth entries or even exists.
Using this table directly is incompatible with auth handlers that don't
cache auth entries (e.g. when they are stored in an SQL database
supposed to be concurrently accessed and modified).
2016-08-23 14:31:59 +02:00
2a56743f65 Apply MFF edits 2016-08-23 14:28:49 +02:00
7 changed files with 76 additions and 15 deletions

28
api.lua
View File

@ -1,5 +1,15 @@
local hudHandlers = {} local hudHandlers = {}
---plants to place in openfarming
local plants = {
["farming:blueberries"]="air", ["farming:carrot"]="air", ["farming:coffee_beans"]="air",
["farming:corn"]="air", ["farming:cucumber"]="air", ["farming:melon_slice"]="air",
["farming:potato"]="air", ["farming:pumpkin_slice"]="air", ["farming:raspberries"]="air",
["farming:rhubarb"]="air", ["farming:tomato"]="air", ["farming:seed_cotton"]="air",
["farming:seed_wheat"]="air",["default:papyrus"]="air", ["farming:trellis"]="air",
["farming:grapes"]="farming:trellis", ["farming:beanpole"]="air", ["farming:beans"]="farming:beanpole",
}
areas.registered_on_adds = {} areas.registered_on_adds = {}
areas.registered_on_removes = {} areas.registered_on_removes = {}
areas.registered_on_moves = {} areas.registered_on_moves = {}
@ -91,6 +101,24 @@ 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
local node = minetest.get_node(pos).name
if not minetest.registered_nodes[node] then return false end
local player = minetest.get_player_by_name(name)
if not player then return false end
local wstack = player:get_wielded_item():get_name()
if wstack == "" then wstack = "hand" end
--on_dig
if minetest.get_item_group(node, "plant") == 1 and (wstack == "hand" or minetest.registered_tools[wstack]) then
return true
end
--on_place
if plants[wstack] ~= nil and plants[wstack] == node then
return true
end
elseif areas.factions_available and area.faction_open then elseif areas.factions_available and area.faction_open then
local faction_name = factions.get_player_faction(area.owner) local faction_name = factions.get_player_faction(area.owner)
if faction_name ~= nil and faction_name == factions.get_player_faction(name) then if faction_name ~= nil and faction_name == factions.get_player_faction(name) then

View File

@ -284,6 +284,28 @@ minetest.register_chatcommand("area_open", {
}) })
minetest.register_chatcommand(
"area_openfarming", {
params = "<ID>",
description = "Toggle an area as open farming (anyone can harvest and plant) 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 open = not areas.areas[id].openfarming
-- Save false as nil to avoid inflating the DB.
areas.areas[id].openfarming = open or nil
areas:save()
return true, ("Area %s to farming."):format(open and "opened" or "closed")
end
})
if areas.factions_available then if areas.factions_available then
minetest.register_chatcommand("area_faction_open", { minetest.register_chatcommand("area_faction_open", {
params = S("<ID>"), params = S("<ID>"),
@ -376,6 +398,8 @@ minetest.register_chatcommand("area_info", {
table.insert(lines, table.insert(lines,
S("You have extended area protection".. S("You have extended area protection"..
" limits (\"areas_high_limit\" privilege).")) " limits (\"areas_high_limit\" privilege)."))
elseif privs.megabuilder then
table.insert(lines, "You are a megabuilder (\"megabuilder\" privilege).")
end end
-- Area count -- Area count
@ -388,7 +412,7 @@ minetest.register_chatcommand("area_info", {
table.insert(lines, S("You have @1 areas.", area_num)) table.insert(lines, S("You have @1 areas.", area_num))
-- Area limit -- Area limit
local area_limit_line = privs.areas and local area_limit_line = (privs.areas or privs.megabuilder) and
S("Limit: no area count limit") or S("Limit: no area count limit") or
S("Limit: @1 areas", max_count) S("Limit: @1 areas", max_count)
table.insert(lines, area_limit_line) table.insert(lines, area_limit_line)
@ -409,6 +433,9 @@ minetest.register_chatcommand("area_info", {
limit, size_limit) limit, size_limit)
priv_limit_info("areas_high_limit", priv_limit_info("areas_high_limit",
limit_high, size_limit_high) limit_high, size_limit_high)
table.insert(lines, "Players with the \"megabuilder\" privilege can protect unlimited areas in size and number.")
elseif privs.megabuilder then
table.insert(lines, "You can protect areas unlimited in size and number.")
elseif has_prot_priv then elseif has_prot_priv then
size_info(S("You can protect areas"), max_size) size_info(S("You can protect areas"), max_size)
end end

View File

@ -25,7 +25,7 @@ minetest.register_globalstep(function(dtime)
area.faction_open = faction_info area.faction_open = faction_info
table.insert(areaStrings, ("%s [%u] (%s%s%s)") table.insert(areaStrings, ("%s [%u] (%s%s%s)")
:format(area.name, id, area.owner, :format(area.name, id, area.owner,
area.open and S(":open") or "", area.open and S(":open") or area.openfarming and ":openfarming" or "",
faction_info and ":"..faction_info or "")) faction_info and ":"..faction_info or ""))
end end

View File

@ -27,6 +27,10 @@ minetest.register_privilege("areas", {
minetest.register_privilege("areas_high_limit", { minetest.register_privilege("areas_high_limit", {
description = "Can protect more, bigger areas." description = "Can protect more, bigger areas."
}) })
-- Mega_builder privilege -- MFF
minetest.register_privilege("megabuilder", {
description = "Can protect an infinite amount of areas."
})
if not minetest.registered_privileges[areas.config.self_protection_privilege] then if not minetest.registered_privileges[areas.config.self_protection_privilege] then
minetest.register_privilege(areas.config.self_protection_privilege, { minetest.register_privilege(areas.config.self_protection_privilege, {

View File

@ -216,6 +216,8 @@ function areas:canPlayerAddArea(pos1, pos2, name)
.." the necessary privilege.") .." the necessary privilege.")
end end
-- MFF: megabuilders skip checks on size and number of areas
if not privs.megabuilder then
local max_size = privs.areas_high_limit and local max_size = privs.areas_high_limit and
self.config.self_protection_max_size_high or self.config.self_protection_max_size_high or
self.config.self_protection_max_size self.config.self_protection_max_size
@ -225,6 +227,7 @@ function areas:canPlayerAddArea(pos1, pos2, name)
(pos2.z - pos1.z) > max_size.z then (pos2.z - pos1.z) > max_size.z then
return false, S("Area is too big.") return false, S("Area is too big.")
end end
end
-- Check number of areas the user has and make sure it not above the max -- Check number of areas the user has and make sure it not above the max
local count = 0 local count = 0
@ -248,7 +251,6 @@ function areas:canPlayerAddArea(pos1, pos2, name)
return false, S("The area intersects with @1 [@2] (@3).", return false, S("The area intersects with @1 [@2] (@3).",
area.name, id, area.owner) area.name, id, area.owner)
end end
return true return true
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 B

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 134 B