Delete chest when empty
This commit is contained in:
parent
28920d97d0
commit
344dee5359
1 changed files with 10 additions and 5 deletions
|
@ -93,6 +93,11 @@ minetest.register_node(":default:chest", {
|
||||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" takes stuff from chest at " .. minetest.pos_to_string(pos))
|
" takes stuff from chest at " .. minetest.pos_to_string(pos))
|
||||||
|
local inv = minetest.get_inventory({type = "node", pos=pos})
|
||||||
|
if not inv or inv:is_empty("main") then
|
||||||
|
minetest.set_node(pos, {name="air"})
|
||||||
|
minetest.show_formspec(player:get_player_name(), "", player:get_inventory_formspec())
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue