Fix some problems with setting chest metadata

This commit is contained in:
Wuzzy 2017-03-29 20:06:14 +02:00
parent 77ccff7e7d
commit 096de10b1a
1 changed files with 15 additions and 9 deletions

View File

@ -47,17 +47,23 @@ minetest.register_node("mcl_chests:"..basename, {
on_construct = function(pos) on_construct = function(pos)
local param2 = minetest.get_node(pos).param2 local param2 = minetest.get_node(pos).param2
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if minetest.get_node(get_chest_neighborpos(pos, param2, "right")).name == "mcl_chests:"..basename then
minetest.set_node(pos, {name="mcl_chests:"..basename.."_right",param2=param2})
local p = get_chest_neighborpos(pos, param2, "right")
minetest.swap_node(p, { name = "mcl_chests:"..basename.."_left", param2 = param2 })
elseif minetest.get_node(get_chest_neighborpos(pos, param2, "left")).name == "mcl_chests:"..basename then
minetest.set_node(pos, {name="mcl_chests:"..basename.."_left",param2=param2})
local p = get_chest_neighborpos(pos, param2, "left")
minetest.swap_node(p, { name = "mcl_chests:"..basename.."_right", param2 = param2 })
end
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", 9*3) inv:set_size("main", 9*3)
if minetest.get_node(get_chest_neighborpos(pos, param2, "right")).name == "mcl_chests:"..basename then
minetest.swap_node(pos, {name="mcl_chests:"..basename.."_right",param2=param2})
local p = get_chest_neighborpos(pos, param2, "right")
minetest.set_node(p, { name = "mcl_chests:"..basename.."_left", param2 = param2 })
meta = minetest.get_meta(p)
inv = meta:get_inventory()
inv:set_size("main", 9*3)
elseif minetest.get_node(get_chest_neighborpos(pos, param2, "left")).name == "mcl_chests:"..basename then
minetest.swap_node(pos, {name="mcl_chests:"..basename.."_left",param2=param2})
local p = get_chest_neighborpos(pos, param2, "left")
minetest.set_node(p, { name = "mcl_chests:"..basename.."_right", param2 = param2 })
meta = minetest.get_meta(p)
inv = meta:get_inventory()
inv:set_size("main", 9*3)
end
end, end,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)