From 8a27df9c24663c5ba0689fa302eb65bb32a099ab Mon Sep 17 00:00:00 2001 From: upsilon Date: Fri, 13 Jan 2017 18:04:41 +0100 Subject: [PATCH] Fix calls to minetest.is_protected The name parameter was not specified. --- init.lua | 7 ++++--- registration.lua | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index f1fa7e2..7ac65c9 100644 --- a/init.lua +++ b/init.lua @@ -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 diff --git a/registration.lua b/registration.lua index 8534f38..f75dacf 100644 --- a/registration.lua +++ b/registration.lua @@ -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"})