Fix crash and outdated Mesecons API code in mcl_comparators
[MineClone/MineClone2.git] / mods / ITEMS / mcl_beds / beds.lua
blob40deac70a7166fd8f45b6865745d0a2aa6018e91
1 -- 3D bed
3 local nodebox = {
4 bottom = {
5 {-0.5, -5/16, -0.5, 0.5, 0.06, 0.5},
6 {-0.5, -0.5, -0.5, -5/16, -5/16, -5/16},
7 {0.5, -0.5, -0.5, 5/16, -5/16, -5/16},
8 },
9 top = {
10 {-0.5, -5/16, -0.5, 0.5, 0.06, 0.5},
11 {-0.5, -0.5, 0.5, -5/16, -5/16, 5/16},
12 {0.5, -0.5, 0.5, 5/16, -5/16, 5/16},
16 local colors = {
17 -- { ID, decription, wool, dye }
18 { "red", "Red Bed", "mcl_wool:red", "mcl_dye:red" },
19 { "blue", "Blue Bed", "mcl_wool:blue", "mcl_dye:blue" },
20 { "cyan", "Cyan Bed", "mcl_wool:cyan", "mcl_dye:cyan" },
21 { "grey", "Grey Bed", "mcl_wool:grey", "mcl_dye:dark_grey" },
22 { "silver", "Light Grey Bed", "mcl_wool:silver", "mcl_dye:grey" },
23 { "black", "Black Bed", "mcl_wool:black", "mcl_dye:black" },
24 { "yellow", "Yellow Bed", "mcl_wool:yellow", "mcl_dye:yellow" },
25 { "green", "Green Bed", "mcl_wool:green", "mcl_dye:dark_green" },
26 { "magenta", "Magenta Bed", "mcl_wool:magenta", "mcl_dye:magenta" },
27 { "orange", "Orange Bed", "mcl_wool:orange", "mcl_dye:orange" },
28 { "purple", "Purple Bed", "mcl_wool:purple", "mcl_dye:violet" },
29 { "brown", "Brown Bed", "mcl_wool:brown", "mcl_dye:brown" },
30 { "pink", "Pink Bed", "mcl_wool:pink", "mcl_dye:pink" },
31 { "lime", "Lime Bed", "mcl_wool:lime", "mcl_dye:green" },
32 { "light_blue", "Light Blue Bed", "mcl_wool:light_blue", "mcl_dye:lightblue" },
33 { "white", "White Bed", "mcl_wool:white", "mcl_dye:white" },
36 for c=1, #colors do
37 local colorid = colors[c][1]
39 -- Recoloring recipe for white bed
40 if minetest.get_modpath("mcl_dye") then
41 minetest.register_craft({
42 type = "shapeless",
43 output = "mcl_beds:bed_"..colorid.."_bottom",
44 recipe = { "mcl_beds:bed_white_bottom", colors[c][4] },
46 end
48 -- Main bed recipe
49 local main_recipe
50 if minetest.get_modpath("mcl_wool") then
51 main_recipe = {
52 {colors[c][3], colors[c][3], colors[c][3]},
53 {"group:wood", "group:wood", "group:wood"}
55 end
57 -- Register bed
58 mcl_beds.register_bed("mcl_beds:bed_"..colorid, {
59 description = colors[c][2],
60 inventory_image = "mcl_beds_bed_"..colorid..".png",
61 wield_image = "mcl_beds_bed_"..colorid..".png",
62 tiles = {
63 bottom = {
64 "mcl_beds_bed_top_bottom_"..colorid..".png^[transformR90",
65 "default_wood.png^mcl_beds_bed_bottom_bottom.png",
66 "mcl_beds_bed_side_bottom_r_"..colorid..".png",
67 "mcl_beds_bed_side_bottom_r_"..colorid..".png^[transformfx",
68 "mcl_beds_bed_side_top_"..colorid..".png",
69 "mcl_beds_bed_side_bottom_"..colorid..".png"
71 top = {
72 "mcl_beds_bed_top_top_"..colorid..".png^[transformR90",
73 "default_wood.png^mcl_beds_bed_bottom_top.png",
74 "mcl_beds_bed_side_top_r_"..colorid..".png",
75 "mcl_beds_bed_side_top_r_"..colorid..".png^[transformfx",
76 "mcl_beds_bed_side_top_"..colorid..".png",
77 "mcl_beds_bed_side_bottom_"..colorid..".png"
80 nodebox = nodebox,
81 selectionbox = {
82 bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
83 top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
85 -- Simplified collision box because Minetest acts weird if we use the nodebox one
86 collisionbox = {
87 bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
88 top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5},
90 recipe = main_recipe,
93 end
95 minetest.register_alias("beds:bed_bottom", "mcl_beds:bed_red_bottom")
96 minetest.register_alias("beds:bed_top", "mcl_beds:bed_red_top")