diff options
Diffstat (limited to 'homedecor/handlers')
-rw-r--r-- | homedecor/handlers/expansion.lua | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/homedecor/handlers/expansion.lua b/homedecor/handlers/expansion.lua index e9d2ec5..779e077 100644 --- a/homedecor/handlers/expansion.lua +++ b/homedecor/handlers/expansion.lua @@ -211,22 +211,21 @@ function homedecor.bed_expansion(pos, placer, itemstack, pointed_thing, trybunks local rightnode = minetest.get_node(rightpos) local inv = placer:get_inventory() - local lastdye = unifieddyes.last_used_dye[placer_name] if leftnode.name == "homedecor:bed_regular" then local newname = string.gsub(thisnode.name, "_regular", "_kingsize") - local meta = minetest.get_meta(leftpos) + local meta = minetest.get_meta(pos) + local leftmeta = minetest.get_meta(leftpos) + minetest.set_node(pos, {name = "air"}) - minetest.set_node(leftpos, { name = newname, param2 = param2}) - meta:set_string("dye", lastdye) - inv:add_item("main", lastdye) + minetest.swap_node(leftpos, { name = newname, param2 = param2}) elseif rightnode.name == "homedecor:bed_regular" then local newname = string.gsub(thisnode.name, "_regular", "_kingsize") - local meta = minetest.get_meta(rightpos) + local meta = minetest.get_meta(pos) + local rightmeta = minetest.get_meta(rightpos) + minetest.set_node(rightpos, {name = "air"}) - minetest.set_node(pos, { name = newname, param2 = param2}) - meta:set_string("dye", lastdye) - inv:add_item("main", lastdye) + minetest.swap_node(pos, { name = newname, param2 = param2}) end local toppos = {x=pos.x, y=pos.y+1.0, z=pos.z} @@ -235,14 +234,7 @@ function homedecor.bed_expansion(pos, placer, itemstack, pointed_thing, trybunks if trybunks and is_buildable_to(placer_name, toppos, topposfwd) then local newname = string.gsub(thisnode.name, "_regular", "_extended") local newparam2 = param2 % 8 - if inv:contains_item("main", lastdye) then - minetest.set_node(toppos, { name = thisnode.name, param2 = param2}) - if lastdye then inv:remove_item("main", lastdye.." 1") end - else - minetest.set_node(toppos, { name = thisnode.name, param2 = newparam2}) - minetest.chat_send_player(placer_name, "Ran out of "..lastdye..", using neutral color.") - unifieddyes.last_used_dye[placer_name] = nil - end + minetest.swap_node(toppos, { name = thisnode.name, param2 = param2}) minetest.swap_node(pos, { name = newname, param2 = param2}) itemstack:take_item() end |