diff --git a/homedecor/furniture.lua b/homedecor/furniture.lua index 3298ad05..1aa5716f 100644 --- a/homedecor/furniture.lua +++ b/homedecor/furniture.lua @@ -246,14 +246,14 @@ local bedcolors = { "blue", "violet", "brown", - "darkgrey", - "orange", - "yellow", - "pink", + "darkgrey", + "orange", + "yellow", + "pink", } - + for _, color in ipairs(bedcolors) do - + minetest.register_node("homedecor:bed_"..color.."_head", { tiles = { "homedecor_bed_"..color.."_top1.png", @@ -291,14 +291,14 @@ for _, color in ipairs(bedcolors) do fixed = { 0, 0, 0, 0, 0, 0 } } }) - + minetest.register_node("homedecor:bed_"..color.."_foot", { tiles = { "homedecor_bed_"..color.."_top2.png", "homedecor_bed_bottom2.png", "homedecor_bed_"..color.."_side2.png", "homedecor_bed_"..color.."_side2.png^[transformFX", - "homedecor_bed_"..color.."_foot2.png", + "homedecor_bed_foot2.png", "homedecor_bed_"..color.."_foot1.png" }, inventory_image = "homedecor_bed_"..color.."_inv.png", @@ -328,10 +328,27 @@ for _, color in ipairs(bedcolors) do type = "fixed", fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 1.5 } }, + on_construct = function(pos) + local function bed_extension(pos) + fdir = minetest.get_node(pos).param2 + if minetest.get_node({x=pos.x, y=pos.y-1.0, z=pos.z}).name == "homedecor:bed_"..color.."_foot" then + minetest.set_node({x=pos.x, y=pos.y-1.0, z=pos.z}, { name = "homedecor:bed_"..color.."_footext", param2 = fdir}) + end + if minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z}).name == "homedecor:bed_"..color.."_foot" then + minetest.set_node({x=pos.x, y=pos.y, z=pos.z}, { name = "homedecor:bed_"..color.."_footext", param2 = fdir}) + end + if minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z}).name == "homedecor:bed_"..color.."_footext" then + minetest.set_node({x=pos.x, y=pos.y, z=pos.z}, { name = "homedecor:bed_"..color.."_footext", param2 = fdir}) + end + end + bed_extension(pos) + end, + on_place = function(itemstack, placer, pointed_thing) return homedecor.stack_sideways(itemstack, placer, pointed_thing, "homedecor:bed_"..color.."_foot", "homedecor:bed_"..color.."_head", false) end, + after_dig_node = function(pos, oldnode, oldmetadata, digger) local fdir = oldnode.param2 if not fdir or fdir > 3 then return end @@ -339,9 +356,61 @@ for _, color in ipairs(bedcolors) do if minetest.get_node(pos2).name == "homedecor:bed_"..color.."_head" then minetest.remove_node(pos2) end + if minetest.get_node({x=pos.x, y=pos.y-1.0, z=pos.z}).name == "homedecor:bed_"..color.."_footext" + then + minetest.set_node({x=pos.x, y=pos.y-1.0, z=pos.z}, { name = "homedecor:bed_"..color.."_foot", param2 = fdir}) + end + end + }) + + minetest.register_node("homedecor:bed_"..color.."_footext", { + tiles = { + "homedecor_bed_"..color.."_top2.png", + "homedecor_bed_bottom2.png", + "homedecor_bed_"..color.."_side2ext.png", + "homedecor_bed_"..color.."_side2ext.png^[transformFX", + "homedecor_bed_foot2ext.png", + "homedecor_bed_"..color.."_foot1ext.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy=3, not_in_creative_inventory=1}, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, -0.375, 0.5, -0.4375}, -- NodeBox1 + {0.375, -0.5, -0.5, 0.5, 0.5, -0.4375}, -- NodeBox2 + {-0.5, 0, -0.5, 0.5, 0.125, -0.4375}, -- NodeBox3 + {-0.5, -0.375, -0.5, 0.5, -0.125, -0.4375}, -- NodeBox4 + {-0.4375, -0.375, -0.5, -0.375, -0.125, 0.5}, -- NodeBox5 + {0.375, -0.375, -0.5, 0.4375, -0.125, 0.5}, -- NodeBox6 + {-0.375, -0.375, 0.3125, 0.375, -0.3125, 0.4375}, -- NodeBox7 + {-0.375, -0.375, 0.125, 0.375, -0.3125, 0.25}, -- NodeBox8 + {-0.375, -0.375, -0.0625, 0.375, -0.3125, 0.0625}, -- NodeBox9 + {-0.375, -0.375, -0.25, 0.375, -0.3125, -0.125}, -- NodeBox10 + {-0.375, -0.375, -0.4375, 0.375, -0.3125, -0.3125}, -- NodeBox11 + {-0.375, -0.3125, -0.4375, 0.375, -0.0625, 0.5}, -- NodeBox12 + } + }, + selection_box = { + type = "fixed", + fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 1.5 } + }, + after_dig_node = function(pos, oldnode, oldmetadata, digger) + local fdir = oldnode.param2 + if not fdir or fdir > 3 then return end + local pos2 = { x = pos.x + homedecor.fdir_to_fwd[fdir+1][1], y=pos.y, z = pos.z + homedecor.fdir_to_fwd[fdir+1][2] } + if minetest.get_node(pos2).name == "homedecor:bed_"..color.."_head" then + minetest.remove_node(pos2) + end + if minetest.get_node({x=pos.x, y=pos.y-1.0, z=pos.z}).name == "homedecor:bed_"..color.."_footext" + then + minetest.set_node({x=pos.x, y=pos.y-1.0, z=pos.z}, { name = "homedecor:bed_"..color.."_foot", param2 = fdir}) + end end }) - + end minetest.register_node("homedecor:wardrobe_top", { diff --git a/homedecor/textures/homedecor_bed_blue_foot1ext.png b/homedecor/textures/homedecor_bed_blue_foot1ext.png new file mode 100644 index 00000000..26ae73ca Binary files /dev/null and b/homedecor/textures/homedecor_bed_blue_foot1ext.png differ diff --git a/homedecor/textures/homedecor_bed_blue_side2ext.png b/homedecor/textures/homedecor_bed_blue_side2ext.png new file mode 100644 index 00000000..b472c6b6 Binary files /dev/null and b/homedecor/textures/homedecor_bed_blue_side2ext.png differ diff --git a/homedecor/textures/homedecor_bed_brown_foot1ext.png b/homedecor/textures/homedecor_bed_brown_foot1ext.png new file mode 100644 index 00000000..5ccb72a6 Binary files /dev/null and b/homedecor/textures/homedecor_bed_brown_foot1ext.png differ diff --git a/homedecor/textures/homedecor_bed_brown_side2ext.png b/homedecor/textures/homedecor_bed_brown_side2ext.png new file mode 100644 index 00000000..48a02897 Binary files /dev/null and b/homedecor/textures/homedecor_bed_brown_side2ext.png differ diff --git a/homedecor/textures/homedecor_bed_darkgrey_side2ext.png b/homedecor/textures/homedecor_bed_darkgrey_side2ext.png new file mode 100644 index 00000000..5b1b2e14 Binary files /dev/null and b/homedecor/textures/homedecor_bed_darkgrey_side2ext.png differ diff --git a/homedecor/textures/homedecor_bed_foot2.png b/homedecor/textures/homedecor_bed_foot2.png new file mode 100644 index 00000000..f8da3f03 Binary files /dev/null and b/homedecor/textures/homedecor_bed_foot2.png differ diff --git a/homedecor/textures/homedecor_bed_foot2ext.png b/homedecor/textures/homedecor_bed_foot2ext.png new file mode 100644 index 00000000..1afeb97a Binary files /dev/null and b/homedecor/textures/homedecor_bed_foot2ext.png differ diff --git a/homedecor/textures/homedecor_bed_green_foot1ext.png b/homedecor/textures/homedecor_bed_green_foot1ext.png new file mode 100644 index 00000000..7f8358e6 Binary files /dev/null and b/homedecor/textures/homedecor_bed_green_foot1ext.png differ diff --git a/homedecor/textures/homedecor_bed_green_side2ext.png b/homedecor/textures/homedecor_bed_green_side2ext.png new file mode 100644 index 00000000..1e33f288 Binary files /dev/null and b/homedecor/textures/homedecor_bed_green_side2ext.png differ diff --git a/homedecor/textures/homedecor_bed_orange_foot1ext.png b/homedecor/textures/homedecor_bed_orange_foot1ext.png new file mode 100644 index 00000000..15ad22d9 Binary files /dev/null and b/homedecor/textures/homedecor_bed_orange_foot1ext.png differ diff --git a/homedecor/textures/homedecor_bed_orange_side2ext.png b/homedecor/textures/homedecor_bed_orange_side2ext.png new file mode 100644 index 00000000..696401d6 Binary files /dev/null and b/homedecor/textures/homedecor_bed_orange_side2ext.png differ diff --git a/homedecor/textures/homedecor_bed_pink_foot1ext.png b/homedecor/textures/homedecor_bed_pink_foot1ext.png new file mode 100644 index 00000000..92f65951 Binary files /dev/null and b/homedecor/textures/homedecor_bed_pink_foot1ext.png differ diff --git a/homedecor/textures/homedecor_bed_pink_side2ext.png b/homedecor/textures/homedecor_bed_pink_side2ext.png new file mode 100644 index 00000000..c1bb6ee1 Binary files /dev/null and b/homedecor/textures/homedecor_bed_pink_side2ext.png differ diff --git a/homedecor/textures/homedecor_bed_red_foot1ext.png b/homedecor/textures/homedecor_bed_red_foot1ext.png new file mode 100644 index 00000000..d62fe469 Binary files /dev/null and b/homedecor/textures/homedecor_bed_red_foot1ext.png differ diff --git a/homedecor/textures/homedecor_bed_red_side2ext.png b/homedecor/textures/homedecor_bed_red_side2ext.png new file mode 100644 index 00000000..cfadea80 Binary files /dev/null and b/homedecor/textures/homedecor_bed_red_side2ext.png differ diff --git a/homedecor/textures/homedecor_bed_violet_foot1ext.png b/homedecor/textures/homedecor_bed_violet_foot1ext.png new file mode 100644 index 00000000..5169b9f9 Binary files /dev/null and b/homedecor/textures/homedecor_bed_violet_foot1ext.png differ diff --git a/homedecor/textures/homedecor_bed_violet_side2ext.png b/homedecor/textures/homedecor_bed_violet_side2ext.png new file mode 100644 index 00000000..a518a9e0 Binary files /dev/null and b/homedecor/textures/homedecor_bed_violet_side2ext.png differ diff --git a/homedecor/textures/homedecor_bed_yellow_foot1ext.png b/homedecor/textures/homedecor_bed_yellow_foot1ext.png new file mode 100644 index 00000000..fd27b689 Binary files /dev/null and b/homedecor/textures/homedecor_bed_yellow_foot1ext.png differ diff --git a/homedecor/textures/homedecor_bed_yellow_side2ext.png b/homedecor/textures/homedecor_bed_yellow_side2ext.png new file mode 100644 index 00000000..9b1e07b6 Binary files /dev/null and b/homedecor/textures/homedecor_bed_yellow_side2ext.png differ