homedecor_modpack/homedecor/furniture.lua

408 lines
11 KiB
Lua
Raw Normal View History

2014-03-25 14:16:47 +01:00
local S = homedecor.gettext
2013-03-26 12:05:22 +01:00
2015-03-31 18:35:51 +02:00
-- Sitting functions disabled for now because of buggyness.
--[[
2015-02-25 11:17:42 +01:00
function homedecor.sit(pos, node, clicker)
2015-01-24 20:10:54 +01:00
local name = clicker:get_player_name()
local meta = minetest:get_meta(pos)
local param2 = node.param2
if clicker:get_player_name() == meta:get_string("player") then
meta:set_string("player", "")
pos.y = pos.y-0.5
clicker:setpos(pos)
clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
clicker:set_physics_override(1, 1, 1)
default.player_attached[name] = false
default.player_set_animation(clicker, "stand", 30)
else
meta:set_string("player", clicker:get_player_name())
clicker:set_eye_offset({x=0,y=-7,z=2}, {x=0,y=0,z=0})
clicker:set_physics_override(0, 0, 0)
default.player_attached[name] = true
if param2 == 1 then
clicker:set_look_yaw(7.9)
elseif param2 == 3 then
clicker:set_look_yaw(4.75)
elseif param2 == 0 then
clicker:set_look_yaw(3.15)
else
clicker:set_look_yaw(6.28)
end
end
end
2015-02-25 11:17:42 +01:00
function homedecor.sit_exec(pos, node, clicker) -- don't move these functions inside sit()
2015-01-27 19:43:12 +01:00
if not clicker or not clicker:is_player()
or clicker:get_player_control().up == true or clicker:get_player_control().down == true
or clicker:get_player_control().left == true or clicker:get_player_control().right == true
or clicker:get_player_control().jump == true then -- make sure that the player is immobile.
return end
2015-02-25 11:17:42 +01:00
homedecor.sit(pos, node, clicker)
2015-01-27 19:43:12 +01:00
clicker:setpos(pos)
default.player_set_animation(clicker, "sit", 30)
end
2015-03-31 18:35:51 +02:00
--]]
2015-01-27 19:43:12 +01:00
2015-02-25 10:35:29 +01:00
local table_colors = { "", "mahogany", "white" }
for _, i in ipairs(table_colors) do
local color = "_"..i
local color2 = "_"..i
2015-02-25 10:35:29 +01:00
local desc = S("Table ("..i..")")
if i == "" then
color = ""
color2 = "_beech"
2015-02-25 10:35:29 +01:00
desc = S("Table")
end
homedecor.register("table"..color, {
description = desc,
tiles = { "homedecor_generic_wood"..color2..".png" },
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},
})
end
local chaircolors = {
{ "", "plain" },
{ "black", "Black" },
{ "red", "Red" },
{ "pink", "Pink" },
{ "violet", "Violet" },
{ "blue", "Blue" },
{ "dark_green", "Dark Green" },
}
local kc_cbox = {
type = "fixed",
fixed = { -0.3125, -0.5, -0.3125, 0.3125, 0.5, 0.3125 },
}
for i in ipairs(chaircolors) do
local color = "_"..chaircolors[i][1]
local color2 = chaircolors[i][1]
2014-03-25 14:16:47 +01:00
local name = S(chaircolors[i][2])
local chairtiles = {
"homedecor_generic_wood_beech.png",
"wool"..color..".png",
}
if chaircolors[i][1] == "" then
color = ""
chairtiles = {
"homedecor_generic_wood_beech.png",
"homedecor_generic_wood_beech.png"
}
end
homedecor.register("chair"..color, {
description = S("Kitchen chair (%s)"):format(name),
mesh = "homedecor_kitchen_chair.obj",
tiles = chairtiles,
selection_box = kc_cbox,
collision_box = kc_cbox,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
2015-03-31 18:35:51 +02:00
--[[
2015-01-27 19:43:12 +01:00
on_rightclick = function(pos, node, clicker)
2015-01-24 20:10:54 +01:00
pos.y = pos.y-0 -- player's sit position.
2015-02-25 11:17:42 +01:00
homedecor.sit_exec(pos, node, clicker)
2015-01-24 20:10:54 +01:00
end,
2015-03-31 18:35:51 +02:00
--]]
})
if color ~= "" then
homedecor.register("armchair"..color, {
description = S("Armchair (%s)"):format(name),
mesh = "forniture_armchair.obj",
tiles = {
"wool"..color..".png",
"wool_dark_grey.png",
"default_wood.png"
},
sunlight_propagates = true,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
2015-03-31 18:35:51 +02:00
--[[
2015-01-27 19:43:12 +01:00
on_rightclick = function(pos, node, clicker)
2015-01-24 20:10:54 +01:00
pos.y = pos.y-0.1 -- player's sit position.
2015-02-25 11:17:42 +01:00
homedecor.sit_exec(pos, node, clicker)
2015-01-24 20:10:54 +01:00
clicker:set_hp(20)
end,
2015-03-31 18:35:51 +02:00
--]]
})
minetest.register_craft({
output = "homedecor:armchair"..color.." 2",
recipe = {
{ "wool:"..color2,""},
{ "group:wood","group:wood" },
{ "wool:"..color2,"wool:"..color2 },
},
})
end
end
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", {
description = "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"
},
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
groups = {choppy=3,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
selection_box = ob_cbox,
collision_box = ob_cbox,
})
local bedcolors = {
"red",
"green",
"blue",
"violet",
"brown",
2014-09-16 20:39:21 +02:00
"darkgrey",
"orange",
"yellow",
"pink",
}
local bed_sbox = {
2015-03-30 05:26:59 +02:00
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 1.5 }
}
local bed_cbox = {
type = "fixed",
fixed = {
{ -0.5, -0.5, -0.5, 0.5, -0.05, 1.5 },
{ -0.5, -0.5, 1.44, 0.5, 0.5, 1.5 },
{ -0.5, -0.5, -0.5, 0.5, 0.18, -0.44 },
}
}
local kbed_sbox = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 1.5, 0.5, 1.5 }
}
local kbed_cbox = {
type = "fixed",
fixed = {
{ -0.5, -0.5, -0.5, 1.5, -0.05, 1.5 },
{ -0.5, -0.5, 1.44, 1.5, 0.5, 1.5 },
{ -0.5, -0.5, -0.5, 1.5, 0.18, -0.44 },
}
}
2015-03-30 05:26:59 +02:00
for _, color in ipairs(bedcolors) do
local color2=color
if color == "darkgrey" then
color2 = "dark_grey"
end
homedecor.register("bed_"..color.."_regular", {
mesh = "homedecor_bed_regular.obj",
tiles = {
2015-03-30 05:26:59 +02:00
"homedecor_bed_frame.png",
"default_wood.png",
"wool_white.png",
"wool_"..color2..".png",
"homedecor_bed_bottom.png",
"wool_"..color2..".png^[brighten", -- pillow
},
inventory_image = "homedecor_bed_"..color.."_inv.png",
description = S("Bed (%s)"):format(color),
groups = {snappy=3},
selection_box = bed_sbox,
2015-03-30 05:26:59 +02:00
collision_box = bed_cbox,
after_place_node = function(pos, placer, itemstack, pointed_thing)
if not placer:get_player_control().sneak then
return homedecor.bed_expansion(pos, placer, itemstack, pointed_thing, color)
end
2014-09-16 20:39:21 +02:00
end,
after_dig_node = function(pos)
homedecor.unextend_bed(pos, color)
end,
on_rightclick = function(pos, node, clicker)
if minetest.get_modpath("beds") then
beds.on_rightclick(pos, clicker)
else return end
end
2014-09-16 20:39:21 +02:00
})
2015-03-30 05:26:59 +02:00
homedecor.register("bed_"..color.."_extended", {
mesh = "homedecor_bed_extended.obj",
2014-09-16 20:39:21 +02:00
tiles = {
2015-03-30 05:26:59 +02:00
"homedecor_bed_frame.png",
"default_wood.png",
"wool_white.png",
"wool_"..color2..".png",
"homedecor_bed_bottom.png",
"wool_"..color2..".png^[brighten",
2014-09-16 20:39:21 +02:00
},
groups = {snappy=3, not_in_creative_inventory=1},
selection_box = bed_sbox,
2015-03-30 05:26:59 +02:00
collision_box = bed_cbox,
expand = { forward = "air" },
after_dig_node = function(pos)
homedecor.unextend_bed(pos, color)
2014-09-18 08:23:11 +02:00
end,
on_rightclick = function(pos, node, clicker)
if minetest.get_modpath("beds") then
beds.on_rightclick(pos, clicker)
else return end
end,
2015-03-30 05:26:59 +02:00
drop = "homedecor:bed_"..color.."_regular"
})
homedecor.register("bed_"..color.."_kingsize", {
mesh = "homedecor_bed_kingsize.obj",
tiles = {
"homedecor_bed_frame.png",
"default_wood.png",
"wool_white.png",
"wool_"..color2..".png",
"homedecor_bed_bottom.png",
"wool_"..color2..".png^[brighten",
},
inventory_image = "homedecor_bed_kingsize_"..color.."_inv.png",
description = S("Bed (%s, king sized)"):format(color),
groups = {snappy=3, not_in_creative_inventory=1},
selection_box = kbed_sbox,
collision_box = kbed_cbox,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local inv = digger:get_inventory()
if digger:get_player_control().sneak and inv:room_for_item("main", "bed_"..color.."_regular 1") then
inv:remove_item("main", "homedecor:bed_"..color.."_kingsize 1")
inv:add_item("main", "homedecor:bed_"..color.."_regular 2")
end
end,
on_rightclick = function(pos, node, clicker)
if minetest.get_modpath("beds") then
beds.on_rightclick(pos, clicker)
else return end
end
})
2015-03-30 05:26:59 +02:00
minetest.register_alias("homedecor:bed_"..color.."_foot", "homedecor:bed_"..color.."_regular")
minetest.register_alias("homedecor:bed_"..color.."_footext", "homedecor:bed_"..color.."_extended")
minetest.register_alias("homedecor:bed_"..color.."_head", "air")
end
2014-08-07 20:49:26 +02:00
2015-03-30 02:59:47 +02:00
local wd_cbox = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, 1.5, 0.5 }
}
2014-08-07 20:49:26 +02:00
homedecor.register("wardrobe_bottom", {
2015-03-30 02:59:47 +02:00
mesh = "homedecor_bedroom_wardrobe.obj",
2014-08-07 20:49:26 +02:00
tiles = {
"homedecor_generic_wood_beech.png",
2015-03-30 02:59:47 +02:00
"homedecor_wardrobe_drawers.png",
"homedecor_wardrobe_doors.png"
2014-08-07 20:49:26 +02:00
},
inventory_image = "homedecor_wardrobe_inv.png",
description = "Wardrobe",
2015-02-25 11:17:42 +01:00
groups = {snappy=3},
2015-03-30 02:59:47 +02:00
selection_box = wd_cbox,
collision_box = wd_cbox,
expand = { top="air" },
infotext = S("Wardrobe cabinet"),
inventory = {
size=24,
},
2014-08-07 20:49:26 +02:00
})
2015-03-30 02:59:47 +02:00
minetest.register_alias("homedecor:wardrobe_bottom", "homedecor:wardrobe")
minetest.register_alias("homedecor:wardrobe_top", "air")
homedecor.register("wall_shelf", {
2014-09-10 16:09:06 +02:00
description = "Wall Shelf",
tiles = {
"homedecor_wood_table_large_edges.png",
},
2014-09-10 18:00:51 +02:00
groups = { snappy = 3 },
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}
}
}
})
2015-02-28 10:14:46 +01:00
local ofchairs_sbox = {
2015-01-27 12:01:29 +01:00
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, 29/32, 8/16 }
2015-02-28 10:14:46 +01:00
}
local ofchairs_cbox = {
2015-01-27 12:01:29 +01:00
type = "fixed",
fixed = {
{ -5/16, 1/16, -7/16, 5/16, 4/16, 7/16 }, -- seat
{ -5/16, 4/16, 4/16, 5/16, 29/32, 15/32 }, -- seatback
{ -1/16, -11/32, -1/16, 1/16, 1/16, 1/16 }, -- cylinder
{ -8/16, -8/16, -8/16, 8/16, -11/32, 8/16 } -- legs/wheels
}
2015-02-28 10:14:46 +01:00
}
local ofchairs = {"basic", "upscale"}
2015-01-27 12:01:29 +01:00
2015-02-28 10:14:46 +01:00
for _, c in ipairs(ofchairs) do
homedecor.register("office_chair_"..c, {
description = "Office chair ("..c..")",
2015-01-27 12:01:29 +01:00
drawtype = "mesh",
2015-02-28 10:14:46 +01:00
tiles = { "homedecor_office_chair_"..c..".png" },
mesh = "homedecor_office_chair_"..c..".obj",
2015-01-27 12:01:29 +01:00
groups = { snappy = 3 },
sounds = default.node_sound_wood_defaults(),
2015-02-28 10:14:46 +01:00
selection_box = ofchairs_sbox,
collision_box = ofchairs_cbox,
expand = { top = "air" },
2015-03-31 18:35:51 +02:00
--[[
2015-01-27 19:43:12 +01:00
on_rightclick = function(pos, node, clicker)
pos.y = pos.y+0.14 -- player's sit position.
2015-02-25 11:17:42 +01:00
homedecor.sit_exec(pos, node, clicker)
end,
2015-03-31 18:35:51 +02:00
--]]
2015-01-27 12:01:29 +01:00
})
2015-02-28 10:14:46 +01:00
end
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')