Put door registration into a loop to have less lines of code

This commit is contained in:
3raven 2022-04-20 03:37:28 +00:00
parent df8dab3fac
commit c3ef5e93af
1 changed files with 75 additions and 215 deletions

View File

@ -5,232 +5,87 @@ local S = minetest.get_translator(minetest.get_current_modname())
local wood_longdesc = S("Wooden doors are 2-block high barriers which can be opened or closed by hand and by a redstone signal.") local wood_longdesc = S("Wooden doors are 2-block high barriers which can be opened or closed by hand and by a redstone signal.")
local wood_usagehelp = S("To open or close a wooden door, rightclick it or supply its lower half with a redstone signal.") local wood_usagehelp = S("To open or close a wooden door, rightclick it or supply its lower half with a redstone signal.")
--- Oak Door --- --Register flammable doors--
mcl_doors:register_door("mcl_doors:wooden_door", {
description = S("Oak Door"),
_doc_items_longdesc = wood_longdesc,
_doc_items_usagehelp = wood_usagehelp,
inventory_image = "doors_item_wood.png",
groups = {handy=1,axey=1, material_wood=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
tiles_bottom = {"mcl_doors_door_wood_lower.png", "mcl_doors_door_wood_side_lower.png"},
tiles_top = {"mcl_doors_door_wood_upper.png", "mcl_doors_door_wood_side_upper.png"},
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({ local woods = {
output = "mcl_doors:wooden_door 3", --id, desc, textures, craftitem
recipe = { {"wooden_door",S("Oak Door"),"doors_item_wood.png",{"mcl_doors_door_wood_lower.png", "mcl_doors_door_wood_side_lower.png"},{"mcl_doors_door_wood_upper.png", "mcl_doors_door_wood_side_upper.png"},"mcl_core:wood"},
{"mcl_core:wood", "mcl_core:wood"}, {"acacia_door",S("Acacia Door"),"mcl_doors_door_acacia.png",{"mcl_doors_door_acacia_lower.png", "mcl_doors_door_acacia_side_lower.png"},{"mcl_doors_door_acacia_upper.png", "mcl_doors_door_acacia_side_upper.png"},"mcl_core:acaciawood"},
{"mcl_core:wood", "mcl_core:wood"}, {"birch_door",S("Birch Door"),"mcl_doors_door_birch.png",{"mcl_doors_door_birch_lower.png", "mcl_doors_door_birch_side_lower.png"},{"mcl_doors_door_birch_upper.png", "mcl_doors_door_birch_side_upper.png"},"mcl_core:birchwood"},
{"mcl_core:wood", "mcl_core:wood"} {"dark_oak_door",S("Dark Oak Door"),"mcl_doors_door_dark_oak.png",{"mcl_doors_door_dark_oak_lower.png", "mcl_doors_door_dark_oak_side_lower.png"},{"mcl_doors_door_dark_oak_upper.png", "mcl_doors_door_dark_oak_side_upper.png"},"mcl_core:darkwood"},
} {"jungle_door",S("Jungle Door"),"mcl_doors_door_jungle.png",{"mcl_doors_door_jungle_lower.png", "mcl_doors_door_jungle_side_lower.png"},{"mcl_doors_door_jungle_upper.png", "mcl_doors_door_jungle_side_upper.png"},"mcl_core:junglewood"},
}) {"spruce_door",S("Spruce Door"),"mcl_doors_door_spruce.png",{"mcl_doors_door_spruce_lower.png", "mcl_doors_door_spruce_side_lower.png"},{"mcl_doors_door_spruce_upper.png", "mcl_doors_door_spruce_side_upper.png"},"mcl_core:sprucewood"},
}
--- Acacia Door -- for w=1 #woods do
mcl_doors:register_door("mcl_doors:acacia_door", { mcl_doors:register_door("mcl_doors:"..woods[w][1], {
description = S("Acacia Door"), description = woods[w][2],
_doc_items_longdesc = wood_longdesc, _doc_items_longdesc = wood_longdesc,
_doc_items_usagehelp = wood_usagehelp, _doc_items_usagehelp = wood_usagehelp,
inventory_image = "mcl_doors_door_acacia.png", inventory_image = woods[w][3],
groups = {handy=1,axey=1, material_wood=1, flammable=-1}, groups = {handy=1,axey=1, material_wood=1, flammable=-1},
_mcl_hardness = 3, _mcl_hardness = 3,
_mcl_blast_resistance = 3, _mcl_blast_resistance = 3,
tiles_bottom = {"mcl_doors_door_acacia_lower.png", "mcl_doors_door_acacia_side_lower.png"}, tiles_bottom = woods[w][4],
tiles_top = {"mcl_doors_door_acacia_upper.png", "mcl_doors_door_acacia_side_upper.png"}, tiles_top = woods[w][5],
sounds = mcl_sounds.node_sound_wood_defaults(), sounds = mcl_sounds.node_sound_wood_defaults(),
}) })
minetest.register_craft({ minetest.register_craft({
output = "mcl_doors:acacia_door 3", output = "mcl_doors:"..woods[w][1].." 3",
recipe = { recipe = {
{"mcl_core:acaciawood", "mcl_core:acaciawood"}, {woods[w][6], woods[w][6]},
{"mcl_core:acaciawood", "mcl_core:acaciawood"}, {woods[w][6], woods[w][6]},
{"mcl_core:acaciawood", "mcl_core:acaciawood"} {woods[w][6], woods[w][6]}
} }
}) })
--- Birch Door -- minetest.register_craft({
mcl_doors:register_door("mcl_doors:birch_door", { type = "fuel",
description = S("Birch Door"), recipe = "mcl_doors:"..woods[w][1],
_doc_items_longdesc = wood_longdesc, burntime = 10,
_doc_items_usagehelp = wood_usagehelp, })
inventory_image = "mcl_doors_door_birch.png",
groups = {handy=1,axey=1, material_wood=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
tiles_bottom = {"mcl_doors_door_birch_lower.png", "mcl_doors_door_birch_side_lower.png"},
tiles_top = {"mcl_doors_door_birch_upper.png", "mcl_doors_door_birch_side_upper.png"},
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({ end
output = "mcl_doors:birch_door 3",
recipe = {
{"mcl_core:birchwood", "mcl_core:birchwood"},
{"mcl_core:birchwood", "mcl_core:birchwood"},
{"mcl_core:birchwood", "mcl_core:birchwood"},
}
})
--- Dark Oak Door -- --Register non-flammable doors--
mcl_doors:register_door("mcl_doors:dark_oak_door", {
description = S("Dark Oak Door"),
_doc_items_longdesc = wood_longdesc,
_doc_items_usagehelp = wood_usagehelp,
inventory_image = "mcl_doors_door_dark_oak.png",
groups = {handy=1,axey=1, material_wood=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
tiles_bottom = {"mcl_doors_door_dark_oak_lower.png", "mcl_doors_door_dark_oak_side_lower.png"},
tiles_top = {"mcl_doors_door_dark_oak_upper.png", "mcl_doors_door_dark_oak_side_upper.png"},
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({ local woods_nether = {
output = "mcl_doors:dark_oak_door 3", --id, desc, textures, craftitem
recipe = { {"crimson_door",S("Crimson Door"),"mcl_doors_door_crimson.png",{"mcl_doors_door_crimson_lower.png", "mcl_doors_door_crimson_side_lower.png"},{"mcl_doors_door_crimson_upper.png", "mcl_doors_door_crimson_side_upper.png"},"mcl_mushroom:crimson_hyphae_wood"},
{"mcl_core:darkwood", "mcl_core:darkwood"}, {"warped_door",S("Warped Door"),"mcl_doors_door_warped.png",{"mcl_doors_door_warped_lower.png", "mcl_doors_door_warped_side_lower.png"},{"mcl_doors_door_warped_upper.png", "mcl_doors_door_warped_side_upper.png"},"mcl_mushroom:warped_hyphae_wood"},
{"mcl_core:darkwood", "mcl_core:darkwood"}, }
{"mcl_core:darkwood", "mcl_core:darkwood"},
}
})
--- Jungle Door -- for w=1 #woods_nether do
mcl_doors:register_door("mcl_doors:jungle_door", { mcl_doors:register_door("mcl_doors:"..woods[w][1], {
description = S("Jungle Door"), description = woods[w][2],
_doc_items_longdesc = wood_longdesc, _doc_items_longdesc = wood_longdesc,
_doc_items_usagehelp = wood_usagehelp, _doc_items_usagehelp = wood_usagehelp,
inventory_image = "mcl_doors_door_jungle.png", inventory_image = woods[w][3],
groups = {handy=1,axey=1, material_wood=1, flammable=-1}, groups = {handy=1,axey=1, material_wood=1},
_mcl_hardness = 3, _mcl_hardness = 3,
_mcl_blast_resistance = 3, _mcl_blast_resistance = 3,
tiles_bottom = {"mcl_doors_door_jungle_lower.png", "mcl_doors_door_jungle_side_lower.png"}, tiles_bottom = woods[w][4],
tiles_top = {"mcl_doors_door_jungle_upper.png", "mcl_doors_door_jungle_side_upper.png"}, tiles_top = woods[w][5],
sounds = mcl_sounds.node_sound_wood_defaults(), sounds = mcl_sounds.node_sound_wood_defaults(),
}) })
minetest.register_craft({ minetest.register_craft({
output = "mcl_doors:jungle_door 3", output = "mcl_doors:"..woods[w][1].." 3",
recipe = { recipe = {
{"mcl_core:junglewood", "mcl_core:junglewood"}, {woods[w][6], woods[w][6]},
{"mcl_core:junglewood", "mcl_core:junglewood"}, {woods[w][6], woods[w][6]},
{"mcl_core:junglewood", "mcl_core:junglewood"} {woods[w][6], woods[w][6]}
} }
}) })
--- Spruce Door -- minetest.register_craft({
mcl_doors:register_door("mcl_doors:spruce_door", { type = "fuel",
description = S("Spruce Door"), recipe = "mcl_doors:"..woods[w][1],
_doc_items_longdesc = wood_longdesc, burntime = 10,
_doc_items_usagehelp = wood_usagehelp, })
inventory_image = "mcl_doors_door_spruce.png",
groups = {handy=1,axey=1, material_wood=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
tiles_bottom = {"mcl_doors_door_spruce_lower.png", "mcl_doors_door_spruce_side_lower.png"},
tiles_top = {"mcl_doors_door_spruce_upper.png", "mcl_doors_door_spruce_side_upper.png"},
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({ end
output = "mcl_doors:spruce_door 3",
recipe = {
{"mcl_core:sprucewood", "mcl_core:sprucewood"},
{"mcl_core:sprucewood", "mcl_core:sprucewood"},
{"mcl_core:sprucewood", "mcl_core:sprucewood"}
}
})
--- Crimson Door --
mcl_doors:register_door("mcl_doors:crimson_door", {
description = S("Crimson Door"),
_doc_items_longdesc = wood_longdesc,
_doc_items_usagehelp = wood_usagehelp,
inventory_image = "mcl_doors_door_crimson.png",
groups = {handy=1,axey=1, material_wood=1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
tiles_bottom = {"mcl_doors_door_crimson_lower.png", "mcl_doors_door_crimson_side_lower.png"},
tiles_top = {"mcl_doors_door_crimson_upper.png", "mcl_doors_door_crimson_side_upper.png"},
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_doors:crimson_door 3",
recipe = {
{"mcl_mushroom:crimson_hyphae_wood", "mcl_mushroom:crimson_hyphae_wood"},
{"mcl_mushroom:crimson_hyphae_wood", "mcl_mushroom:crimson_hyphae_wood"},
{"mcl_mushroom:crimson_hyphae_wood", "mcl_mushroom:crimson_hyphae_wood"}
}
})
--- Warped Door --
mcl_doors:register_door("mcl_doors:warped_door", {
description = S("Warped Door"),
_doc_items_longdesc = wood_longdesc,
_doc_items_usagehelp = wood_usagehelp,
inventory_image = "mcl_doors_door_warped.png",
groups = {handy=1,axey=1, material_wood=1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
tiles_bottom = {"mcl_doors_door_warped_lower.png", "mcl_doors_door_warped_side_lower.png"},
tiles_top = {"mcl_doors_door_warped_upper.png", "mcl_doors_door_warped_side_upper.png"},
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_doors:warped_door 3",
recipe = {
{"mcl_mushroom:warped_hyphae_wood", "mcl_mushroom:warped_hyphae_wood"},
{"mcl_mushroom:warped_hyphae_wood", "mcl_mushroom:warped_hyphae_wood"},
{"mcl_mushroom:warped_hyphae_wood", "mcl_mushroom:warped_hyphae_wood"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_doors:wooden_door",
burntime = 10,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_doors:jungle_door",
burntime = 10,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_doors:dark_oak_door",
burntime = 10,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_doors:birch_door",
burntime = 10,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_doors:acacia_door",
burntime = 10,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_doors:spruce_door",
burntime = 10,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_doors:crimson_door",
burntime = 10,
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_doors:warped_door",
burntime = 10,
})
--- Iron Door --- --- Iron Door ---
mcl_doors:register_door("mcl_doors:iron_door", { mcl_doors:register_door("mcl_doors:iron_door", {
@ -262,6 +117,9 @@ minetest.register_craft({
--[[ Trapdoors ]] --[[ Trapdoors ]]
--Register flammable trapdoors--
local woods = { local woods = {
-- id, desc, texture, craftitem -- id, desc, texture, craftitem
{ "trapdoor", S("Oak Trapdoor"), "doors_trapdoor.png", "doors_trapdoor_side.png", "mcl_core:wood" }, { "trapdoor", S("Oak Trapdoor"), "doors_trapdoor.png", "doors_trapdoor_side.png", "mcl_core:wood" },
@ -301,6 +159,8 @@ for w=1, #woods do
}) })
end end
--Register non-flammable trapdoors--
local woods_nether = { local woods_nether = {
-- id, desc, texture, craftitem -- id, desc, texture, craftitem
{ "crimson_trapdoor", S("Crimson Trapdoor"), "mcl_doors_trapdoor_crimson.png", "mcl_doors_trapdoor_crimson_side.png", "mcl_mushroom:crimson_hyphae_wood" }, { "crimson_trapdoor", S("Crimson Trapdoor"), "mcl_doors_trapdoor_crimson.png", "mcl_doors_trapdoor_crimson_side.png", "mcl_mushroom:crimson_hyphae_wood" },