Don't crash on nil-player in can_dig and check the right players for attachment in chairs.

This commit is contained in:
Tim 2016-08-05 22:17:15 +02:00
parent 73a29be691
commit beeda8cb9b
3 changed files with 7 additions and 11 deletions

View File

@ -40,13 +40,9 @@ function xdecor.sit(pos, node, clicker, pointed_thing)
end end
end end
function xdecor.sit_dig(pos, player) function xdecor.sit_dig(pos, digger)
local pname = player:get_player_name() for _, player in pairs(minetest.get_objects_inside_radius(pos, 0.1)) do
local objs = minetest.get_objects_inside_radius(pos, 0.1) if player:is_player() and default.player_attached[player:get_player_name()] then
for _, p in pairs(objs) do
if not player or not player:is_player() or p:get_player_name() or
default.player_attached[pname] then
return false return false
end end
end end

View File

@ -94,10 +94,10 @@ end
function itemframe.dig(pos, player) function itemframe.dig(pos, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local pname = player:get_player_name() local pname = player and player:get_player_name()
local owner = meta:get_string("owner") local owner = meta:get_string("owner")
return player and pname == owner return pname == owner
end end
xdecor.register("itemframe", { xdecor.register("itemframe", {

View File

@ -78,10 +78,10 @@ end
function mailbox.dig(pos, player) function mailbox.dig(pos, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner") local owner = meta:get_string("owner")
local player_name = player:get_player_name() local player_name = player and player:get_player_name()
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:is_empty("mailbox") and player and player_name == owner return inv:is_empty("mailbox") and player_name == owner
end end
function mailbox.after_place_node(pos, placer) function mailbox.after_place_node(pos, placer)