forked from nalc/homedecor_modpack
Convert curtains to param2 coloring.
This commit is contained in:
parent
d35ebe8c00
commit
b9307f11ad
Binary file not shown.
Before Width: | Height: | Size: 465 B After Width: | Height: | Size: 295 B |
Binary file not shown.
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 276 B |
@ -101,65 +101,79 @@ homedecor.register("blinds_thin", {
|
|||||||
selection_box = wb2_cbox
|
selection_box = wb2_cbox
|
||||||
})
|
})
|
||||||
|
|
||||||
local curtaincolors = {
|
minetest.register_node("homedecor:curtain_closed", {
|
||||||
{ N_("red"), "ad2323" },
|
description = S("Curtains"),
|
||||||
{ N_("green"), "27a927" },
|
tiles = { "homedecor_curtain.png" },
|
||||||
{ N_("blue"), "2626c6" },
|
inventory_image = "homedecor_curtain.png",
|
||||||
{ N_("white"), "ffffff" },
|
drawtype = 'signlike',
|
||||||
{ N_("pink"), "ff8fb7" },
|
use_texture_alpha = true,
|
||||||
{ N_("violet"), "7f29d7" },
|
walkable = false,
|
||||||
}
|
groups = { snappy = 3 },
|
||||||
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
for _, c in ipairs(curtaincolors) do
|
paramtype2 = "colorwallmounted",
|
||||||
local color, hue = unpack(c)
|
palette = "unifieddyes_palette_colorwallmounted.png",
|
||||||
|
selection_box = { type = "wallmounted" },
|
||||||
homedecor.register("curtain_"..color, {
|
after_dig_node = unifieddyes.after_dig_node,
|
||||||
description = S("Curtains (@1)", S(color)),
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
tiles = { { name = "homedecor_curtain.png", color = tonumber("0xff"..hue) } },
|
local yaw = placer:get_look_yaw()
|
||||||
inventory_image = "homedecor_curtain.png^[colorize:#"..hue.."e0:175",
|
local dir = minetest.yaw_to_dir(yaw-1.5)
|
||||||
wield_image = "homedecor_curtain.png^[colorize:#"..hue.."e0:175",
|
local fdir = minetest.dir_to_wallmounted(dir)
|
||||||
drawtype = 'signlike',
|
name = minetest.get_node(pos).name
|
||||||
use_texture_alpha = true,
|
minetest.swap_node(pos, { name = name, param2 = fdir })
|
||||||
walkable = false,
|
end,
|
||||||
groups = { snappy = 3 },
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
local itemname = itemstack:get_name()
|
||||||
paramtype2 = 'wallmounted',
|
if string.find(itemname, "dye:") or string.find(itemname, "unifieddyes:") then
|
||||||
selection_box = { type = "wallmounted" },
|
unifieddyes.on_rightclick(pos, node, clicker,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
itemstack, pointed_thing, "homedecor:curtain_closed", "wallmounted")
|
||||||
|
else
|
||||||
local topnode = minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z})
|
local topnode = minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z})
|
||||||
if string.find(topnode.name, "homedecor:curtainrod") then
|
if string.find(topnode.name, "homedecor:curtainrod") then
|
||||||
-- Open the curtains
|
-- Open the curtains
|
||||||
local fdir = node.param2
|
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
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
end
|
||||||
|
})
|
||||||
|
|
||||||
homedecor.register("curtain_open_"..color, {
|
minetest.register_node("homedecor:curtain_open", {
|
||||||
description = S("Curtains (@1)", S(color)),
|
description = S("Curtains"),
|
||||||
tiles = { { name = "homedecor_curtain_open.png", color = tonumber("0xff"..hue) } },
|
tiles = { "homedecor_curtain_open.png" },
|
||||||
inventory_image = "homedecor_curtain_open.png^[colorize:#"..hue.."e0:175",
|
inventory_image = "homedecor_curtain_open.png",
|
||||||
wield_image = "homedecor_curtain_open.png^[colorize:#"..hue.."e0:175",
|
drawtype = 'signlike',
|
||||||
drawtype = 'signlike',
|
use_texture_alpha = true,
|
||||||
use_texture_alpha = true,
|
walkable = false,
|
||||||
walkable = false,
|
groups = { snappy = 3 },
|
||||||
groups = { snappy = 3 },
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
paramtype2 = "colorwallmounted",
|
||||||
paramtype2 = 'wallmounted',
|
palette = "unifieddyes_palette_colorwallmounted.png",
|
||||||
selection_box = { type = "wallmounted" },
|
selection_box = { type = "wallmounted" },
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
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})
|
local topnode = minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z})
|
||||||
if string.find(topnode.name, "homedecor:curtainrod") then
|
if string.find(topnode.name, "homedecor:curtainrod") then
|
||||||
-- Close the curtains
|
-- Close the curtains
|
||||||
local fdir = node.param2
|
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
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
end
|
||||||
|
})
|
||||||
end
|
|
||||||
|
|
||||||
local mats = {
|
local mats = {
|
||||||
{ "brass", S("brass"), "homedecor_generic_metal_brass.png" },
|
{ "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} }
|
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
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user