mirror of
https://github.com/minetest/minetest_game.git
synced 2024-11-15 22:40:19 +01:00
Don't create bones if the player's inventory is empty
This commit is contained in:
parent
579c279be2
commit
253af00743
|
@ -51,10 +51,8 @@ minetest.register_node("bones:bones", {
|
||||||
|
|
||||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if meta:get_string("owner") ~= "" and meta:get_inventory():is_empty("main") then
|
if meta:get_inventory():is_empty("main") then
|
||||||
meta:set_string("infotext", meta:get_string("owner").."'s old bones")
|
minetest.remove_node(pos)
|
||||||
meta:set_string("formspec", "")
|
|
||||||
meta:set_string("owner", "")
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -82,6 +80,12 @@ minetest.register_on_dieplayer(function(player)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local player_inv = player:get_inventory()
|
||||||
|
if player_inv:is_empty("main") and
|
||||||
|
player_inv:is_empty("craft") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
pos.x = math.floor(pos.x+0.5)
|
pos.x = math.floor(pos.x+0.5)
|
||||||
pos.y = math.floor(pos.y+0.5)
|
pos.y = math.floor(pos.y+0.5)
|
||||||
|
@ -91,8 +95,6 @@ minetest.register_on_dieplayer(function(player)
|
||||||
local nn = minetest.get_node(pos).name
|
local nn = minetest.get_node(pos).name
|
||||||
if minetest.registered_nodes[nn].can_dig and
|
if minetest.registered_nodes[nn].can_dig and
|
||||||
not minetest.registered_nodes[nn].can_dig(pos, player) then
|
not minetest.registered_nodes[nn].can_dig(pos, player) then
|
||||||
local player_inv = player:get_inventory()
|
|
||||||
|
|
||||||
for i=1,player_inv:get_size("main") do
|
for i=1,player_inv:get_size("main") do
|
||||||
player_inv:set_stack("main", i, nil)
|
player_inv:set_stack("main", i, nil)
|
||||||
end
|
end
|
||||||
|
@ -107,7 +109,6 @@ minetest.register_on_dieplayer(function(player)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local player_inv = player:get_inventory()
|
|
||||||
inv:set_size("main", 8*4)
|
inv:set_size("main", 8*4)
|
||||||
|
|
||||||
local empty_list = inv:get_list("main")
|
local empty_list = inv:get_list("main")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user