Fix calls to minetest.is_protected

The name parameter was not specified.
This commit is contained in:
upsilon 2017-01-13 18:04:41 +01:00
parent a6ce9315b0
commit 8a27df9c24
2 changed files with 8 additions and 7 deletions

View File

@ -157,13 +157,14 @@ function throwing.register_arrow(name, itemcraft, craft_quantity, description, t
groups = _groups,
on_place = function(itemstack, placer, pointed_thing)
if minetest.setting_getbool("throwing.allow_arrow_placing") and pointed_thing.above then
if not minetest.is_protected(pointed_thing.above) then
minetest.log("action", "Player "..placer:get_player_name().." placed arrow "..throwing.modname..":"..name.." into a protected area at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
local playername = placer:get_player_name()
if not minetest.is_protected(pointed_thing.above, playername) then
minetest.log("action", "Player "..playername.." placed arrow "..throwing.modname..":"..name.." into a protected area at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
minetest.set_node(pointed_thing.above, {name = throwing.modname..":"..name})
itemstack:take_item()
return itemstack
else
minetest.log("warning", "Player "..placer:get_player_name().." tried to place arrow "..throwing.modname..":"..name.." into a protected area at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
minetest.log("warning", "Player "..playername.." tried to place arrow "..throwing.modname..":"..name.." into a protected area at ("..pointed_thing.above.x..","..pointed_thing.above.y..","..pointed_thing.above.z..")")
return itemstack
end
else

View File

@ -45,11 +45,11 @@ end
if get_setting("dig_arrow") then
throwing.register_arrow("arrow_dig", "default:pick_wood", 1, "Dig Arrow",
{"throwing_arrow_dig.png", "throwing_arrow_dig.png", "throwing_arrow_dig_back.png", "throwing_arrow_dig_front.png", "throwing_arrow_dig_2.png", "throwing_arrow_dig.png"}, "throwing_dig_arrow",
function(pos, _, node, _, _)
function(pos, _, node, _, hitter)
if not node then
return
end
if minetest.is_protected(pos) then
if minetest.is_protected(pos, hitter:get_player_name()) then
return false, "Area is protected"
end
return minetest.dig_node(pos)
@ -107,7 +107,7 @@ end
if get_setting("build_arrow") then
throwing.register_arrow("arrow_build", "default:obsidian_glass", 1, "Build Arrow",
{"throwing_arrow_build.png", "throwing_arrow_build.png", "throwing_arrow_build_back.png", "throwing_arrow_build_front.png", "throwing_arrow_build_2.png", "throwing_arrow_build.png"}, "throwing_build_arrow",
function(_, last_pos, node, _, _)
function(_, last_pos, node, _, hitter)
if not node then
return
end
@ -115,7 +115,7 @@ if get_setting("build_arrow") then
minetest.log("warning", "[throwing] BUG: node at last_pos was not air")
return
end
if minetest.is_protected(last_pos) then
if minetest.is_protected(last_pos, hitter:get_player_name()) then
return false, "Area is protected"
end
return minetest.place_node(last_pos, {name="default:obsidian_glass"})