mirror of
https://github.com/mt-mods/homedecor_modpack.git
synced 2024-11-08 11:20:26 +01:00
6cadc7cf26
To maximize the palette, this uses the colorwallmounted param2 style, which necessitated modifying the models to make wallmounted look like normal facedir. This means couches and chairs can now only ever be placed upright, facing one of N/S/E/W like a couch or chair normally would, but since the screwdriver was already disabled, it was basically impossible to rotate them to any other orientation anyway. Since this is colorwallmounted, it uses the 32-color abridged Unified Dyes palette.
116 lines
2.9 KiB
Lua
116 lines
2.9 KiB
Lua
|
|
local S = homedecor_i18n.gettext
|
|
local armchair_cbox = {
|
|
type = "fixed",
|
|
fixed = {
|
|
{-0.5, -0.5, -0.5, 0.5, 0, 0.5 },
|
|
{-0.5, -0.5, 0.4, 0.5, 0.5, 0.5 }
|
|
}
|
|
}
|
|
|
|
minetest.register_node("lrfurn:armchair", {
|
|
description = "Armchair",
|
|
drawtype = "mesh",
|
|
mesh = "lrfurn_armchair.obj",
|
|
tiles = {
|
|
"lrfurn_upholstery.png",
|
|
{ name = "lrfurn_sofa_bottom.png", color = 0xffffffff }
|
|
},
|
|
paramtype = "light",
|
|
paramtype2 = "colorwallmounted",
|
|
palette = "unifieddyes_palette_colorwallmounted.png",
|
|
inventory_image = "lrfurn_armchair_inv.png",
|
|
groups = {snappy=3},
|
|
sounds = default.node_sound_wood_defaults(),
|
|
node_box = armchair_cbox,
|
|
after_place_node = lrfurn.fix_rotation,
|
|
after_dig_node = unifieddyes.after_dig_node,
|
|
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, "lrfurn:armchair", "wallmounted")
|
|
else
|
|
if not clicker:is_player() then
|
|
return itemstack
|
|
end
|
|
pos.y = pos.y-0.5
|
|
clicker:setpos(pos)
|
|
clicker:set_hp(20)
|
|
return itemstack
|
|
end
|
|
end
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = "lrfurn:armchair",
|
|
recipe = {
|
|
{"wool:white", "", "", },
|
|
{"stairs:slab_wood", "", "", },
|
|
{"group:stick", "", "", }
|
|
}
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = "lrfurn:armchair",
|
|
recipe = {
|
|
{"wool:white", "", "", },
|
|
{"moreblocks:slab_wood", "", "", },
|
|
{"group:stick", "", "", }
|
|
}
|
|
})
|
|
|
|
-- convert old static nodes to param2 color
|
|
|
|
lrfurn.old_static_armchairs = {}
|
|
|
|
for _, color in ipairs(lrfurn.colors) do
|
|
table.insert(lrfurn.old_static_armchairs, "lrfurn:armchair_"..color)
|
|
print("lrfurn:armchair_"..color)
|
|
end
|
|
|
|
minetest.register_lbm({
|
|
name = "lrfurn:convert_armchairs",
|
|
label = "Convert lrfurn armchairs to use param2 color",
|
|
run_at_every_load = true,
|
|
nodenames = lrfurn.old_static_armchairs,
|
|
action = function(pos, node)
|
|
local name = node.name
|
|
local color = string.sub(name, string.find(name, "_")+1)
|
|
|
|
if color == "red" then
|
|
color = "medium_red"
|
|
elseif color == "dark_green" then
|
|
color = "medium_green"
|
|
elseif color == "magenta" then
|
|
color = "medium_magenta"
|
|
elseif color == "cyan" then
|
|
color = "medium_cyan"
|
|
end
|
|
|
|
local paletteidx, _ = unifieddyes.getpaletteidx("unifieddyes:"..color, "wallmounted")
|
|
local old_fdir = math.floor(node.param2 % 32)
|
|
local new_fdir = 3
|
|
|
|
if old_fdir == 0 then
|
|
new_fdir = 3
|
|
elseif old_fdir == 1 then
|
|
new_fdir = 4
|
|
elseif old_fdir == 2 then
|
|
new_fdir = 2
|
|
elseif old_fdir == 3 then
|
|
new_fdir = 5
|
|
end
|
|
|
|
local param2 = paletteidx + new_fdir
|
|
|
|
minetest.set_node(pos, { name = "lrfurn:armchair", param2 = param2 })
|
|
local meta = minetest.get_meta(pos)
|
|
meta:set_string("dye", "unifieddyes:"..color)
|
|
end
|
|
})
|
|
|
|
if minetest.setting_get("log_mods") then
|
|
minetest.log("action", "[lrfurn/armchairs] "..S("Loaded!"))
|
|
end
|