1
0
mirror of https://github.com/mt-mods/plantlife_modpack.git synced 2024-12-27 02:50:19 +01:00

use minetest built-in functions for node protection

phase out the old hand-rolled protection function
drops support for old protection mods
This commit is contained in:
Vanessa Ezekowitz 2014-06-22 22:20:51 -04:00
parent ce8433ac1e
commit ca88a35f26
2 changed files with 2 additions and 38 deletions

View File

@ -94,7 +94,7 @@ for i in ipairs(lilies_list) do
place_pos = pt.above place_pos = pt.above
end end
if not plantslib:node_is_owned(place_pos, placer) then if not minetest.is_protected(place_pos, placer:get_player_name()) then
local nodename = "default:cobble" -- if this block appears, something went....wrong :-) local nodename = "default:cobble" -- if this block appears, something went....wrong :-)
@ -194,7 +194,7 @@ for i in ipairs(algae_list) do
place_pos = pt.above place_pos = pt.above
end end
if not plantslib:node_is_owned(place_pos, placer) then if not minetest.is_protected(place_pos, placer:get_player_name()) then
local nodename = "default:cobble" -- :D local nodename = "default:cobble" -- :D

View File

@ -439,42 +439,6 @@ function plantslib:grow_tree(pos, node_or_function_or_model)
minetest.spawn_tree(pos, node_or_function_or_model) minetest.spawn_tree(pos, node_or_function_or_model)
end end
-- check if a node is owned before allowing manual placement of a node
-- (used by flowers_plus)
function plantslib:node_is_owned(pos, placer)
local ownername = false
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
if HasOwner(pos, placer) then -- returns true if the node is owned
if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
if type(getLastOwner) == "function" then -- ...is an old version
ownername = getLastOwner(pos)
elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version
ownername = GetNodeOwnerName(pos)
else
ownername = S("someone")
end
end
end
elseif type(isprotect)=="function" then -- glomie's protection mod
if not isprotect(5, pos, placer) then
ownername = S("someone")
end
elseif type(protector)=="table" and type(protector.can_dig)=="function" then -- Zeg9's protection mod
if not protector.can_dig(5, pos, placer) then
ownername = S("someone")
end
end
if ownername ~= false then
minetest.chat_send_player( placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
return true
else
return false
end
end
-- Check for infinite stacks -- Check for infinite stacks
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then