forked from mtcontrib/unifieddyes
make sure the pointed thing is a node before checking protection
This commit is contained in:
parent
726bb75e1d
commit
cf186f5f9c
5
init.lua
5
init.lua
@ -561,21 +561,22 @@ function unifieddyes.after_dig_node(pos, oldnode, oldmetadata, digger)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function unifieddyes.on_use(itemstack, player, pointed_thing)
|
function unifieddyes.on_use(itemstack, player, pointed_thing)
|
||||||
|
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
|
|
||||||
|
if pointed_thing and pointed_thing.type == "node" then
|
||||||
if minetest.is_protected(unifieddyes.select_node(pointed_thing), playername)
|
if minetest.is_protected(unifieddyes.select_node(pointed_thing), playername)
|
||||||
and not minetest.check_player_privs(playername, "protection_bypass") then
|
and not minetest.check_player_privs(playername, "protection_bypass") then
|
||||||
minetest.chat_send_player(playername, "Sorry, someone else owns that spot.")
|
minetest.chat_send_player(playername, "Sorry, someone else owns that spot.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if pointed_thing and pointed_thing.type == "object" then
|
if pointed_thing and pointed_thing.type == "object" then
|
||||||
pointed_thing.ref:punch(player, 0, itemstack:get_tool_capabilities())
|
pointed_thing.ref:punch(player, 0, itemstack:get_tool_capabilities())
|
||||||
return player:get_wielded_item() -- punch may modified the wielded item, load the new and return it
|
return player:get_wielded_item() -- punch may modified the wielded item, load the new and return it
|
||||||
end
|
end
|
||||||
|
|
||||||
if not (pointed_thing and pointed_thing.type == "node") then return end -- if "using" the dye not on a node
|
if not (pointed_thing and pointed_thing.type == "node") then return end -- if "using" the dye on nothing at all (e.g. air)
|
||||||
|
|
||||||
local pos = minetest.get_pointed_thing_position(pointed_thing)
|
local pos = minetest.get_pointed_thing_position(pointed_thing)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user