Fix ability to place items in treasure chests by swapping (#647)
This commit is contained in:
parent
ce1bbe0246
commit
a978d8457f
1 changed files with 9 additions and 1 deletions
|
@ -75,9 +75,17 @@ minetest.register_node("tsm_chests:chest", {
|
||||||
" moves stuff to chest at " .. minetest.pos_to_string(pos))
|
" moves stuff to chest at " .. minetest.pos_to_string(pos))
|
||||||
end,
|
end,
|
||||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
local inv = minetest.get_inventory({type = "node", pos = pos})
|
||||||
|
local swapped_item = inv:get_stack(listname, index)
|
||||||
|
|
||||||
|
if swapped_item:get_name() ~= "" then
|
||||||
|
inv:remove_item(listname, swapped_item)
|
||||||
|
player:get_inventory():add_item(listname, swapped_item)
|
||||||
|
end
|
||||||
|
|
||||||
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
|
if not inv or inv:is_empty("main") then
|
||||||
minetest.set_node(pos, {name="air"})
|
minetest.set_node(pos, {name="air"})
|
||||||
minetest.show_formspec(player:get_player_name(), "", player:get_inventory_formspec())
|
minetest.show_formspec(player:get_player_name(), "", player:get_inventory_formspec())
|
||||||
|
|
Loading…
Reference in a new issue