mirror of
https://github.com/minetest-mods/digtron.git
synced 2024-12-22 20:32:22 +01:00
fix crate protection (#25)
* fix crate protection all crates check area protection (minetest.is_protected) protected crates check area and owner (even if not in protected area) * separate check and action * whitespace stuff * another missing whitespace * add suggestion from T4im
This commit is contained in:
parent
d3397563ec
commit
1011901938
@ -77,6 +77,12 @@ local store_digtron = function(pos, clicker, loaded_node_name, protected)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("crated_layout", layout_string)
|
||||
|
||||
if protected then
|
||||
-- only set owner if protected
|
||||
meta:set_string("owner", clicker:get_player_name() or "")
|
||||
end
|
||||
|
||||
meta:set_string("title", S("Crated Digtron"))
|
||||
meta:set_string("infotext", S("Crated Digtron") .. "\n" .. protection_suffix)
|
||||
end
|
||||
@ -98,6 +104,10 @@ minetest.register_node("digtron:empty_crate", {
|
||||
},
|
||||
paramtype = "light",
|
||||
|
||||
can_dig = function(pos, player)
|
||||
return player and not minetest.is_protected(pos, player:get_player_name())
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
store_digtron(pos, clicker, "digtron:loaded_crate")
|
||||
end
|
||||
@ -130,7 +140,7 @@ minetest.register_node("digtron:empty_locked_crate", {
|
||||
meta:set_string("infotext", S("Digtron Crate") .. "\n" .. S("Owned by @1", placer:get_player_name() or ""))
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
return player_permitted(pos,player)
|
||||
return player and not minetest.is_protected(pos, player:get_player_name()) and player_permitted(pos, player)
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
if player_permitted(pos,clicker) then
|
||||
@ -297,7 +307,9 @@ minetest.register_node("digtron:loaded_crate", {
|
||||
end,
|
||||
|
||||
on_dig = function(pos, node, player)
|
||||
return loaded_on_dig(pos, player, "digtron:loaded_crate")
|
||||
if player and not minetest.is_protected(pos, player:get_player_name()) then
|
||||
loaded_on_dig(pos, player, "digtron:loaded_crate")
|
||||
end
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
@ -321,7 +333,7 @@ minetest.register_node("digtron:loaded_locked_crate", {
|
||||
end,
|
||||
|
||||
on_dig = function(pos, node, player)
|
||||
if player_permitted(pos,player) then
|
||||
if player and not minetest.is_protected(pos, player:get_player_name()) and player_permitted(pos,player) then
|
||||
return loaded_on_dig(pos, player, "digtron:loaded_locked_crate")
|
||||
else
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user