homedecor_modpack/homedecor/furniture.lua

226 lines
6.2 KiB
Lua
Raw Normal View History

2017-01-30 00:12:02 +01:00
local S = homedecor_i18n.gettext
2013-03-26 12:05:22 +01:00
local table_colors = {
2017-01-24 21:43:20 +01:00
{ "", S("Table"), homedecor.plain_wood },
{ "_mahogany", S("Mahogany Table"), homedecor.mahogany_wood },
{ "_white", S("White Table"), homedecor.white_wood }
}
2015-02-25 10:35:29 +01:00
2017-01-24 21:43:20 +01:00
for _, t in ipairs(table_colors) do
local suffix, desc, texture = unpack(t)
2015-02-25 10:35:29 +01:00
2017-01-24 21:43:20 +01:00
homedecor.register("table"..suffix, {
2015-02-25 10:35:29 +01:00
description = desc,
2017-01-24 21:43:20 +01:00
tiles = { texture },
2015-02-25 10:35:29 +01:00
node_box = {
type = "fixed",
fixed = {
{ -0.4, -0.5, -0.4, -0.3, 0.4, -0.3 },
{ 0.3, -0.5, -0.4, 0.4, 0.4, -0.3 },
{ -0.4, -0.5, 0.3, -0.3, 0.4, 0.4 },
{ 0.3, -0.5, 0.3, 0.4, 0.4, 0.4 },
{ -0.5, 0.4, -0.5, 0.5, 0.5, 0.5 },
{ -0.4, -0.2, -0.3, -0.3, -0.1, 0.3 },
{ 0.3, -0.2, -0.4, 0.4, -0.1, 0.3 },
{ -0.3, -0.2, -0.4, 0.4, -0.1, -0.3 },
{ -0.3, -0.2, 0.3, 0.3, -0.1, 0.4 },
},
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
2015-04-29 14:14:36 +02:00
sounds = default.node_sound_wood_defaults(),
2015-02-25 10:35:29 +01:00
})
end
local kc_cbox = {
type = "fixed",
fixed = { -0.3125, -0.5, -0.3125, 0.3125, 0.5, 0.3125 },
}
2015-04-30 23:52:23 +02:00
local ac_cbox = {
type = "fixed",
fixed = {
2015-04-30 23:52:23 +02:00
{-0.5, -0.5, -0.5, 0.5, 0, 0.5 },
{-0.5, -0.5, 0.4, 0.5, 0.5, 0.5 }
}
}
homedecor.register("kitchen_chair_wood", {
description = S("Kitchen chair"),
mesh = "homedecor_kitchen_chair.obj",
tiles = {
homedecor.plain_wood,
homedecor.plain_wood
},
inventory_image = "homedecor_chair_wood_inv.png",
paramtype2 = "wallmounted",
selection_box = kc_cbox,
collision_box = kc_cbox,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, ud_param2_colorable = 1},
sounds = default.node_sound_wood_defaults(),
after_place_node = homedecor.fix_rotation_nsew,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
pos.y = pos.y+0 -- where do I put my ass ?
homedecor.sit(pos, node, clicker)
return itemstack
end
})
homedecor.register("kitchen_chair_padded", {
description = S("Kitchen chair"),
mesh = "homedecor_kitchen_chair.obj",
tiles = {
homedecor.plain_wood,
"wool_white.png",
},
inventory_image = "homedecor_chair_padded_inv.png",
paramtype2 = "colorwallmounted",
palette = "unifieddyes_palette_colorwallmounted.png",
selection_box = kc_cbox,
collision_box = kc_cbox,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, ud_param2_colorable = 1},
sounds = default.node_sound_wood_defaults(),
after_place_node = homedecor.fix_rotation_nsew,
after_dig_node = unifieddyes.after_dig_node,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
pos.y = pos.y+0 -- where do I put my ass ?
homedecor.sit(pos, node, clicker)
return itemstack
end
})
homedecor.register("armchair", {
description = S("Armchair"),
mesh = "forniture_armchair.obj",
tiles = {
"wool_white.png",
{ name = "wool_dark_grey.png", color = 0xffffffff },
{ name = "default_wood.png", color = 0xffffffff }
},
inventory_image = "homedecor_armchair_inv.png",
paramtype2 = "colorwallmounted",
palette = "unifieddyes_palette_colorwallmounted.png",
groups = {snappy=3, ud_param2_colorable = 1},
sounds = default.node_sound_wood_defaults(),
node_box = ac_cbox,
after_place_node = homedecor.fix_rotation_nsew,
after_dig_node = unifieddyes.after_dig_node,
})
2013-03-26 12:05:22 +01:00
local ob_cbox = {
type = "fixed",
fixed = { -0.5, -0.5, 0, 0.5, 0.5, 0.5 }
}
minetest.register_node(":homedecor:openframe_bookshelf", {
2017-01-24 21:43:20 +01:00
description = S("Bookshelf (open-frame)"),
drawtype = "mesh",
2014-12-14 07:19:36 +01:00
mesh = "homedecor_openframe_bookshelf.obj",
tiles = {
"homedecor_openframe_bookshelf_books.png",
"default_wood.png"
},
groups = {choppy=3,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
2015-04-30 23:52:23 +02:00
paramtype = "light",
paramtype2 = "facedir",
selection_box = ob_cbox,
collision_box = ob_cbox,
})
homedecor.register("wall_shelf", {
2017-01-24 21:43:20 +01:00
description = S("Wall Shelf"),
2014-09-10 16:09:06 +02:00
tiles = {
"homedecor_wood_table_large_edges.png",
},
2014-09-10 18:00:51 +02:00
groups = { snappy = 3 },
2015-04-29 14:14:36 +02:00
sounds = default.node_sound_wood_defaults(),
2014-09-10 16:09:06 +02:00
node_box = {
type = "fixed",
fixed = {
{-0.5, 0.4, 0.47, 0.5, 0.47, 0.5},
{-0.5, 0.47, -0.1875, 0.5, 0.5, 0.5}
}
}
})
2013-03-26 12:05:22 +01:00
-- Aliases for 3dforniture mod.
2014-08-07 20:49:26 +02:00
2013-03-26 12:05:22 +01:00
minetest.register_alias("3dforniture:table", "homedecor:table")
minetest.register_alias("3dforniture:chair", "homedecor:chair")
minetest.register_alias("3dforniture:armchair", "homedecor:armchair_black")
minetest.register_alias("homedecor:armchair", "homedecor:armchair_black")
2013-03-26 12:05:22 +01:00
minetest.register_alias('table', 'homedecor:table')
minetest.register_alias('chair', 'homedecor:chair')
minetest.register_alias('armchair', 'homedecor:armchair')
-- conversion to param2 colorization
homedecor.old_static_chairs = {}
for _, color in ipairs(lrfurn.colors) do
table.insert(homedecor.old_static_chairs, "homedecor:chair_"..color)
table.insert(homedecor.old_static_chairs, "homedecor:armchair_"..color)
end
table.insert(homedecor.old_static_chairs, "homedecor:chair")
minetest.register_lbm({
name = "homedecor:convert_chairs",
label = "Convert homedecor chairs to use param2 color",
2017-02-16 22:58:48 +01:00
run_at_every_load = false,
nodenames = homedecor.old_static_chairs,
action = function(pos, node)
local name = node.name
local paletteidx = 0
local color
local a,b = string.find(name, "_")
if a then
color = string.sub(name, a+1)
if color == "blue" then
color = "medium_blue"
elseif color == "violet" then
color = "medium_violet"
elseif color == "red" then
color = "medium_red"
elseif color == "black" then
color = "dark_grey"
end
2017-02-16 03:53:52 +01:00
paletteidx = unifieddyes.getpaletteidx("unifieddyes:"..color, "wallmounted")
end
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
local newname = "homedecor:armchair"
print(name, dump(a), dump(b), dump(color).."("..dump(paletteidx)..")", dump(param2))
if node.name == "homedecor:chair" then
newname = "homedecor:kitchen_chair_wood"
elseif string.find(node.name, "homedecor:chair_") then
newname = "homedecor:kitchen_chair_padded"
end
minetest.set_node(pos, { name = newname, param2 = param2 })
local meta = minetest.get_meta(pos)
if color then
meta:set_string("dye", "unifieddyes:"..color)
end
end
})