mirror of
https://github.com/mt-mods/homedecor_modpack.git
synced 2025-07-23 15:40:18 +02:00
Version MFF.
This commit is contained in:
115
homedecor/shutters.lua
Normal file → Executable file
115
homedecor/shutters.lua
Normal file → Executable file
@ -1,18 +1,19 @@
|
||||
-- Various kinds of window shutters
|
||||
|
||||
local S = homedecor_i18n.gettext
|
||||
local S = homedecor.gettext
|
||||
|
||||
local shutters = {
|
||||
"mahogany",
|
||||
"red",
|
||||
"yellow",
|
||||
"forest_green",
|
||||
"light_blue",
|
||||
"violet",
|
||||
"black",
|
||||
"dark_grey",
|
||||
"grey",
|
||||
"white",
|
||||
{"oak", "Unpainted oak", "#bf8a51:200" },
|
||||
{"mahogany", "Mahogany", "#822606:200" },
|
||||
{"red", "Red", "#d00000:150" },
|
||||
{"yellow", "Yellow", "#ffff00:150" },
|
||||
{"forest_green", "Forest green", "#006000:150" },
|
||||
{"light_blue", "Light blue", "#1963c7:150" },
|
||||
{"violet", "Violet", "#6000ff:150" },
|
||||
{"black", "Black", "#000000:200" },
|
||||
{"dark_grey", "Dark grey", "#202020:200" },
|
||||
{"grey", "Grey", "#c0c0c0:150" },
|
||||
{"white", "White", "#ffffff:150" },
|
||||
}
|
||||
|
||||
local shutter_cbox = {
|
||||
@ -22,78 +23,30 @@ local shutter_cbox = {
|
||||
wall_side = { -0.5, -0.5, -0.5, -0.4375, 0.5, 0.5 }
|
||||
}
|
||||
|
||||
local inv = "homedecor_window_shutter_inv.png^[colorize:#a87034:150"
|
||||
for i in ipairs(shutters) do
|
||||
local name = shutters[i][1]
|
||||
local desc = shutters[i][2]
|
||||
local hue = shutters[i][3]
|
||||
|
||||
homedecor.register("shutter", {
|
||||
mesh = "homedecor_window_shutter.obj",
|
||||
tiles = {
|
||||
{ name = "homedecor_window_shutter.png", color = 0xffa87034 }
|
||||
},
|
||||
description = S("Wooden Shutter"),
|
||||
inventory_image = inv,
|
||||
wield_image = inv,
|
||||
paramtype2 = "wallmounted",
|
||||
ud_replacement_node = "homedecor:shutter_colored",
|
||||
groups = { snappy = 3, ud_param2_colorable = 1 },
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
selection_box = shutter_cbox,
|
||||
node_box = shutter_cbox,
|
||||
after_place_node = unifieddyes.fix_rotation,
|
||||
after_dig_node = unifieddyes.after_dig_node
|
||||
})
|
||||
local tile = "homedecor_window_shutter.png^[colorize:"..hue
|
||||
local inv = "homedecor_window_shutter_inv.png^[colorize:"..hue
|
||||
|
||||
homedecor.register("shutter_colored", {
|
||||
mesh = "homedecor_window_shutter.obj",
|
||||
tiles = { "homedecor_window_shutter.png" },
|
||||
description = S("Wooden Shutter"),
|
||||
inventory_image = "homedecor_window_shutter_inv.png",
|
||||
wield_image = "homedecor_window_shutter_inv.png",
|
||||
paramtype2 = "colorwallmounted",
|
||||
palette = "unifieddyes_palette_colorwallmounted.png",
|
||||
groups = { snappy = 3 , not_in_creative_inventory = 1, ud_param2_colorable = 1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
selection_box = shutter_cbox,
|
||||
node_box = shutter_cbox,
|
||||
after_place_node = unifieddyes.fix_rotation,
|
||||
after_dig_node = unifieddyes.after_dig_node,
|
||||
drop = "homedecor:shutter"
|
||||
})
|
||||
|
||||
minetest.register_alias("homedecor:shutter_purple", "homedecor:shutter_violet")
|
||||
minetest.register_alias("homedecor:shutter_oak", "homedecor:shutter")
|
||||
|
||||
-- convert to param2 coloring
|
||||
|
||||
homedecor.old_shutter_nodes = {}
|
||||
|
||||
for _, color in ipairs(shutters) do
|
||||
table.insert(homedecor.old_shutter_nodes, "homedecor:shutter_"..color)
|
||||
homedecor.register("shutter_"..name, {
|
||||
mesh = "homedecor_window_shutter.obj",
|
||||
tiles = { tile },
|
||||
description = S("Wooden Shutter ("..desc..")"),
|
||||
inventory_image = inv,
|
||||
wield_image = inv,
|
||||
paramtype2 = "wallmounted",
|
||||
groups = { snappy = 3 },
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
selection_box = shutter_cbox,
|
||||
node_box = shutter_cbox,
|
||||
-- collision_box doesn't accept type="wallmounted", but node_box
|
||||
-- does. Said nodeboxes create a custom collision box but are
|
||||
-- invisible themselves because drawtype="mesh".
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_lbm({
|
||||
name = "homedecor:convert_shutters",
|
||||
label = "Convert shutter static nodes to use param2 color",
|
||||
run_at_every_load = false,
|
||||
nodenames = homedecor.old_shutter_nodes,
|
||||
action = function(pos, node)
|
||||
local name = node.name
|
||||
local color = string.sub(name, string.find(name, "_") + 1)
|
||||
minetest.register_alias("homedecor:shutter_purple", "homedecor:shutter_violet")
|
||||
|
||||
if color == "mahogany" then
|
||||
color = "dark_red"
|
||||
elseif color == "forest_green" then
|
||||
color = "dark_green"
|
||||
elseif color == "light_blue" then
|
||||
color = "medium_cyan"
|
||||
elseif color == "red" then
|
||||
color = "medium_red"
|
||||
end
|
||||
|
||||
local paletteidx = unifieddyes.getpaletteidx("unifieddyes:"..color, "wallmounted")
|
||||
local param2 = paletteidx + node.param2
|
||||
|
||||
minetest.set_node(pos, { name = "homedecor:shutter_colored", param2 = param2 })
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("dye", "unifieddyes:"..color)
|
||||
end
|
||||
})
|
||||
|
Reference in New Issue
Block a user