From b9307f11adc7e96622cd4ad757b88c36eec77848 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Sat, 28 Jan 2017 21:51:29 -0500 Subject: [PATCH] Convert curtains to param2 coloring. --- homedecor/textures/homedecor_curtain.png | Bin 465 -> 295 bytes homedecor/textures/homedecor_curtain_open.png | Bin 425 -> 276 bytes homedecor/window_treatments.lua | 156 +++++++++++++----- 3 files changed, 112 insertions(+), 44 deletions(-) diff --git a/homedecor/textures/homedecor_curtain.png b/homedecor/textures/homedecor_curtain.png index 97ef90d06ad39d48b0bf52f176035da416f61769..4274d2b0fda00cd2069e4fab2c99cdc513a4d950 100644 GIT binary patch delta 279 zcmV+y0qFkG1E&Iz8Gi%-006c6H|hWY0PaadK~yNuEzd!2+b{q`(I<+cC>svCDT?0z zR5?I)OF8s>WS6OYL_&dP*u_31twMVKtwbNqfzz} z(fqc#sU`y^uT%41_a7~?RWtXKgV1nQy2aIag1hb}93D2!*3XjdawkL~NmjvtV8`9y dkAemN0a^NB3lR0`N)iA7002ovPDHLkV1nbMfWiO( delta 450 zcmZ3^bdh<2WIZzj1A~Sxe=v}05AX?boiu6ElqplDPMtb!+O+A@r_Y!%W9H16vu4ej zJ$v??IdkUDojY&dy!rFzFIcc(;lhQB7A;!5c=3`YOO`HOx@_69<;$0^Sg~T|%9X2D zty;Z$^_n$n)~;Q(_7CuwmoIjhi-Y+Pr!5mMvShZr!?V+qUi7x7Y93v18}X zox67J+P!=Co;`c^?%lg@-@ZeK4$XRZ{uj_qx+Ot=!8b_(o{mxXfEv$ux;TbNNU|P` z_H#DmVLkBUNTrjeQ-gre?|AX~H33uY@`~nKq_x%Cy*ghbUoUcceeKToM{2~Kr(9q2 zrrORTUhW9H^t7i^2`MM^R>+;z5dxDw=b$)R<(L}Z7#cUkl(4S z=l_<-HHud6{b_y3?)hrf7b-KZC@Ps2G$@sO_2l=1b_3289mKR)o&X+qep{R51C>6Vz$Avh1lrzW;A*bMYW=~ zM(8E2g<`e_nsJOj5wRgM3i1(rf)t?Da@)g#k;G zOOlm@#w4~lNLPmU(;d{u48>BX%4fqS$L}@)f^wCCy+JbT#Db_Yx+b0`3$==kSD6q4jF|0P#>i7&%wLN=l>r`6gN~{5ZrK& z3-G{S^xv3MiZObP-cCA!nVzcZ>KQki&1|>ZS-0D@R;y*J)yi1wbUNnlF`v(^*=$;) z(NHZ}uh%UI0&{7a+H^YArtkZ<*=%gRUaO!2poZdpzi*4hLVp0m;ZW%~yx;G&i3$pq z%jFII9@GFxO&rInNs`3I7!0ItyWQGkGPx<>FbZJk^?Cy0 z{}ljsvM376vP^36#UbZ%xoDGx^Z9JY>xBvhE diff --git a/homedecor/window_treatments.lua b/homedecor/window_treatments.lua index 18e2e82f..8bcb309e 100644 --- a/homedecor/window_treatments.lua +++ b/homedecor/window_treatments.lua @@ -101,65 +101,79 @@ homedecor.register("blinds_thin", { selection_box = wb2_cbox }) -local curtaincolors = { - { N_("red"), "ad2323" }, - { N_("green"), "27a927" }, - { N_("blue"), "2626c6" }, - { N_("white"), "ffffff" }, - { N_("pink"), "ff8fb7" }, - { N_("violet"), "7f29d7" }, -} - -for _, c in ipairs(curtaincolors) do - local color, hue = unpack(c) - - homedecor.register("curtain_"..color, { - description = S("Curtains (@1)", S(color)), - tiles = { { name = "homedecor_curtain.png", color = tonumber("0xff"..hue) } }, - inventory_image = "homedecor_curtain.png^[colorize:#"..hue.."e0:175", - wield_image = "homedecor_curtain.png^[colorize:#"..hue.."e0:175", - drawtype = 'signlike', - use_texture_alpha = true, - walkable = false, - groups = { snappy = 3 }, - sounds = default.node_sound_leaves_defaults(), - paramtype2 = 'wallmounted', - selection_box = { type = "wallmounted" }, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) +minetest.register_node("homedecor:curtain_closed", { + description = S("Curtains"), + tiles = { "homedecor_curtain.png" }, + inventory_image = "homedecor_curtain.png", + drawtype = 'signlike', + use_texture_alpha = true, + walkable = false, + groups = { snappy = 3 }, + sounds = default.node_sound_leaves_defaults(), + paramtype2 = "colorwallmounted", + palette = "unifieddyes_palette_colorwallmounted.png", + selection_box = { type = "wallmounted" }, + after_dig_node = unifieddyes.after_dig_node, + after_place_node = function(pos, placer, itemstack, pointed_thing) + local yaw = placer:get_look_yaw() + local dir = minetest.yaw_to_dir(yaw-1.5) + local fdir = minetest.dir_to_wallmounted(dir) + name = minetest.get_node(pos).name + minetest.swap_node(pos, { name = name, param2 = fdir }) + end, + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + local itemname = itemstack:get_name() + if string.find(itemname, "dye:") or string.find(itemname, "unifieddyes:") then + unifieddyes.on_rightclick(pos, node, clicker, + itemstack, pointed_thing, "homedecor:curtain_closed", "wallmounted") + else local topnode = minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z}) if string.find(topnode.name, "homedecor:curtainrod") then -- Open the curtains local fdir = node.param2 - minetest.set_node(pos, { name = "homedecor:curtain_open_"..color, param2 = fdir }) + minetest.set_node(pos, { name = "homedecor:curtain_open", param2 = fdir }) end return itemstack end - }) + end +}) - homedecor.register("curtain_open_"..color, { - description = S("Curtains (@1)", S(color)), - tiles = { { name = "homedecor_curtain_open.png", color = tonumber("0xff"..hue) } }, - inventory_image = "homedecor_curtain_open.png^[colorize:#"..hue.."e0:175", - wield_image = "homedecor_curtain_open.png^[colorize:#"..hue.."e0:175", - drawtype = 'signlike', - use_texture_alpha = true, - walkable = false, - groups = { snappy = 3 }, - sounds = default.node_sound_leaves_defaults(), - paramtype2 = 'wallmounted', - selection_box = { type = "wallmounted" }, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) +minetest.register_node("homedecor:curtain_open", { + description = S("Curtains"), + tiles = { "homedecor_curtain_open.png" }, + inventory_image = "homedecor_curtain_open.png", + drawtype = 'signlike', + use_texture_alpha = true, + walkable = false, + groups = { snappy = 3 }, + sounds = default.node_sound_leaves_defaults(), + paramtype2 = "colorwallmounted", + palette = "unifieddyes_palette_colorwallmounted.png", + selection_box = { type = "wallmounted" }, + after_dig_node = unifieddyes.after_dig_node, + after_place_node = function(pos, placer, itemstack, pointed_thing) + local yaw = placer:get_look_yaw() + local dir = minetest.yaw_to_dir(yaw-1.5) + local fdir = minetest.dir_to_wallmounted(dir) + name = minetest.get_node(pos).name + minetest.swap_node(pos, { name = name, param2 = fdir }) + end, + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + local itemname = itemstack:get_name() + if string.find(itemname, "dye:") or string.find(itemname, "unifieddyes:") then + unifieddyes.on_rightclick(pos, node, clicker, + itemstack, pointed_thing, "homedecor:curtain_open", "wallmounted") + else local topnode = minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z}) if string.find(topnode.name, "homedecor:curtainrod") then -- Close the curtains local fdir = node.param2 - minetest.set_node(pos, { name = "homedecor:curtain_"..color, param2 = fdir }) + minetest.set_node(pos, { name = "homedecor:curtain_closed", param2 = fdir }) end return itemstack end - }) - -end + end +}) local mats = { { "brass", S("brass"), "homedecor_generic_metal_brass.png" }, @@ -218,3 +232,57 @@ homedecor.register("stained_glass", { fixed = { {-0.5, -0.5, 0.46875, 0.5, 0.5, 0.5} } } }) + +-- Convert old curtain nodes to param2-colorization + +local curtaincolors = { + { N_("red"), "ad2323" }, + { N_("green"), "27a927" }, + { N_("blue"), "2626c6" }, + { N_("white"), "ffffff" }, + { N_("pink"), "ff8fb7" }, + { N_("violet"), "7f29d7" }, +} + +homedecor.old_static_curtain_nodes = {} + +for _, i in ipairs(curtaincolors) do + local color,hue = unpack(i) + table.insert(homedecor.old_static_curtain_nodes, "homedecor:curtain_"..color) + table.insert(homedecor.old_static_curtain_nodes, "homedecor:curtain_open_"..color) +end + +minetest.register_lbm({ + name = "homedecor:convert_curtains", + label = "Convert static curtain nodes to use param2 color", + run_at_every_load = true, + nodenames = homedecor.old_static_curtain_nodes, + action = function(pos, node) + local name = node.name + local color = string.sub(name, 19) + local openclose = "closed" + + if string.find(color, "open") then + color = string.sub(color, 6) + openclose = "open" + end + + local metadye = "medium_"..color + if color == "pink" then + metadye = "light_red" + end + if color == "white" then + metadye = "white" + end + + local newnode = "homedecor:curtain_"..openclose + local paletteidx, _ = unifieddyes.getpaletteidx("unifieddyes:"..metadye, "wallmounted") + local newparam2 = paletteidx + (node.param2 % 8) + + print(node.name.." --> "..newnode..", "..metadye.." ("..paletteidx..")") + + minetest.set_node(pos, { name = newnode, param2 = newparam2 }) + local meta = minetest.get_meta(pos) + meta:set_string("dye", "unifieddyes:"..metadye) + end +})