Delete chest when empty

This commit is contained in:
rubenwardy 2015-11-22 18:10:33 +00:00
parent 28920d97d0
commit 344dee5359

View file

@ -93,6 +93,11 @@ minetest.register_node(":default:chest", {
on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" 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,
})