MineClone2/mods/ITEMS/mcl_beds/beds.lua

79 lines
2.7 KiB
Lua
Raw Permalink Normal View History

local S = minetest.get_translator(minetest.get_current_modname())
2019-03-24 09:06:35 +01:00
local mod_doc = minetest.get_modpath("doc")
2017-05-07 20:21:37 +02:00
2017-05-07 20:35:22 +02:00
local colors = {
2017-07-25 16:45:45 +02:00
-- { ID, decription, wool, dye }
{ "red", S("Red Bed"), "mcl_wool:red", "mcl_dye:red" },
{ "blue", S("Blue Bed"), "mcl_wool:blue", "mcl_dye:blue" },
{ "cyan", S("Cyan Bed"), "mcl_wool:cyan", "mcl_dye:cyan" },
{ "grey", S("Grey Bed"), "mcl_wool:grey", "mcl_dye:dark_grey" },
{ "silver", S("Light Grey Bed"), "mcl_wool:silver", "mcl_dye:grey" },
{ "black", S("Black Bed"), "mcl_wool:black", "mcl_dye:black" },
{ "yellow", S("Yellow Bed"), "mcl_wool:yellow", "mcl_dye:yellow" },
{ "green", S("Green Bed"), "mcl_wool:green", "mcl_dye:dark_green" },
{ "magenta", S("Magenta Bed"), "mcl_wool:magenta", "mcl_dye:magenta" },
{ "orange", S("Orange Bed"), "mcl_wool:orange", "mcl_dye:orange" },
{ "purple", S("Purple Bed"), "mcl_wool:purple", "mcl_dye:violet" },
{ "brown", S("Brown Bed"), "mcl_wool:brown", "mcl_dye:brown" },
{ "pink", S("Pink Bed"), "mcl_wool:pink", "mcl_dye:pink" },
{ "lime", S("Lime Bed"), "mcl_wool:lime", "mcl_dye:green" },
{ "light_blue", S("Light Blue Bed"), "mcl_wool:light_blue", "mcl_dye:lightblue" },
{ "white", S("White Bed"), "mcl_wool:white", "mcl_dye:white" },
2017-05-07 20:35:22 +02:00
}
2019-03-24 09:06:35 +01:00
local canonical_color = "red"
2017-05-07 20:35:22 +02:00
for c=1, #colors do
local colorid = colors[c][1]
2019-03-24 09:06:35 +01:00
local is_canonical = colorid == canonical_color
2017-05-07 20:35:22 +02:00
2017-07-25 16:45:45 +02:00
-- Recoloring recipe for white bed
2017-07-26 19:07:57 +02:00
if minetest.get_modpath("mcl_dye") then
minetest.register_craft({
type = "shapeless",
output = "mcl_beds:bed_"..colorid.."_bottom",
recipe = { "mcl_beds:bed_white_bottom", colors[c][4] },
})
end
-- Main bed recipe
local main_recipe
if minetest.get_modpath("mcl_wool") then
main_recipe = {
{colors[c][3], colors[c][3], colors[c][3]},
{"group:wood", "group:wood", "group:wood"}
}
end
2017-07-25 16:45:45 +02:00
2019-03-24 09:06:35 +01:00
local entry_name, create_entry
if mod_doc then
if is_canonical then
entry_name = S("Bed")
else
create_entry = false
end
end
2017-07-25 16:45:45 +02:00
-- Register bed
2017-05-07 20:35:22 +02:00
mcl_beds.register_bed("mcl_beds:bed_"..colorid, {
description = colors[c][2],
2019-03-24 09:06:35 +01:00
_doc_items_entry_name = entry_name,
_doc_items_create_entry = create_entry,
2022-10-06 18:36:51 +02:00
inventory_image = "mcl_beds_bed_"..colorid.."_inv.png",
wield_image = "mcl_beds_bed_"..colorid.."_inv.png",
2017-05-07 20:35:22 +02:00
tiles = {
2022-10-06 18:36:51 +02:00
"mcl_beds_bed_"..colorid..".png"
2017-05-09 19:02:24 +02:00
},
2022-10-06 18:36:51 +02:00
2017-07-26 19:07:57 +02:00
recipe = main_recipe,
2017-05-07 20:35:22 +02:00
})
2019-03-24 09:06:35 +01:00
if mod_doc and not is_canonical then
doc.add_entry_alias("nodes", "mcl_beds:bed_"..canonical_color.."_bottom", "nodes", "mcl_beds:bed_"..colorid.."_bottom")
doc.add_entry_alias("nodes", "mcl_beds:bed_"..canonical_color.."_bottom", "nodes", "mcl_beds:bed_"..colorid.."_top")
end
2017-07-25 16:45:45 +02:00
2017-05-07 20:35:22 +02:00
end
2017-05-07 20:21:37 +02:00
minetest.register_alias("beds:bed_bottom", "mcl_beds:bed_red_bottom")
minetest.register_alias("beds:bed_top", "mcl_beds:bed_red_top")