Centralize craft item names

This commit is contained in:
random-geek 2020-09-18 15:16:40 -07:00
parent 544e93f4b6
commit ca10fb0b40
5 changed files with 119 additions and 96 deletions

@ -1,11 +1,5 @@
morelights = {} morelights = {}
if minetest.get_modpath("xpanes") then
morelights.glass = "xpanes:pane_flat"
else
morelights.glass = "default:glass"
end
function morelights.register_variants(variants, fixedDef) function morelights.register_variants(variants, fixedDef)
for _, variant in ipairs(variants) do for _, variant in ipairs(variants) do
local name = variant.name local name = variant.name
@ -50,6 +44,34 @@ function morelights.rotate_and_place(itemstack, placer, pointed_thing, lookup)
return itemstack return itemstack
end end
morelights.craft_items = {
glass = "default:glass",
glass_pane = "default:glass",
steel = "default:steel_ingot",
copper = "default:copper_ingot",
mese_fragment = "default:mese_crystal_fragment",
dye_dark = "dye:dark_grey",
dye_light = "dye:white",
wool_dark = "wool:dark_grey",
wool_light = "wool:white",
wood_dark = "default:junglewood",
cotton = "farming:cotton",
dirt = "default:dirt",
stone_block = "default:stone_block",
sandstone_block = "default:sandstone_block",
grass = "default:grass_1",
}
if minetest.get_modpath("xpanes") then
morelights.craft_items.glass_pane = "xpanes:pane_flat"
end
-- Use basic_materials brass if available, otherwise register our own.
if minetest.get_modpath("basic_materials") then
morelights.craft_items.brass = "basic_materials:brass_ingot"
end
local path = minetest.get_modpath("morelights") local path = minetest.get_modpath("morelights")
dofile(path .. "/nodes.lua") dofile(path .. DIR_DELIM .. "nodes.lua")

@ -132,47 +132,49 @@ morelights.register_variants({
-- Craft recipes -- Craft recipes
-- --
local a = morelights.craft_items
minetest.register_craft({ minetest.register_craft({
output = "morelights:bulb", output = "morelights:bulb",
recipe = { recipe = {
{"", "default:glass", ""}, {"", a.glass, ""},
{"", "default:copper_ingot", ""}, {"", a.copper, ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights:pole_d 2", output = "morelights:pole_d 2",
recipe = { recipe = {
{"dye:dark_grey", "default:steel_ingot", ""}, {a.dye_dark, a.steel, ""},
{"", "default:steel_ingot", ""}, {"", a.steel, ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights:pole_l 2", output = "morelights:pole_l 2",
recipe = { recipe = {
{"dye:white", "default:steel_ingot", ""}, {a.dye_light, a.steel, ""},
{"", "default:steel_ingot", ""}, {"", a.steel, ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights:chain_d", output = "morelights:chain_d",
recipe = { recipe = {
{"dye:dark_grey", "default:steel_ingot", ""}, {a.dye_dark, a.steel, ""},
{"", "", ""}, {"", "", ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights:chain_l", output = "morelights:chain_l",
recipe = { recipe = {
{"dye:white", "default:steel_ingot", ""}, {a.dye_light, a.steel, ""},
{"", "", ""}, {"", "", ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })

@ -80,45 +80,47 @@ minetest.register_node("morelights_extras:stairlight", {
-- Craft recipes -- Craft recipes
-- --
local a = morelights.craft_items
minetest.register_craft({ minetest.register_craft({
output = "morelights_extras:f_block", output = "morelights_extras:f_block",
recipe = { recipe = {
{"default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment"}, {a.mese_fragment, a.steel, a.mese_fragment},
{morelights.glass, "morelights:bulb", morelights.glass}, {a.glass_pane, "morelights:bulb", a.glass_pane},
{"default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment"} {a.mese_fragment, a.steel, a.mese_fragment}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_extras:dirt_with_grass", output = "morelights_extras:dirt_with_grass",
recipe = { recipe = {
{"", morelights.glass, ""}, {"", a.glass_pane, ""},
{"", "morelights:bulb", ""}, {"", "morelights:bulb", ""},
{"default:grass_1", "default:dirt", ""} {a.grass, a.dirt, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_extras:stone_block", output = "morelights_extras:stone_block",
recipe = { recipe = {
{"", morelights.glass, ""}, {"", a.glass_pane, ""},
{"", "morelights:bulb", ""}, {"", "morelights:bulb", ""},
{"", "default:stone_block", ""} {"", a.stone_block, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_extras:sandstone_block", output = "morelights_extras:sandstone_block",
recipe = { recipe = {
{"", morelights.glass, ""}, {"", a.glass_pane, ""},
{"", "morelights:bulb", ""}, {"", "morelights:bulb", ""},
{"", "default:sandstone_block", ""} {"", a.sandstone_block, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_extras:stairlight", output = "morelights_extras:stairlight",
recipe = { recipe = {
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"} {a.steel, "morelights:bulb", a.steel}
} }
}) })

@ -237,64 +237,66 @@ morelights.register_variants({
-- Craft recipes -- Craft recipes
-- --
local a = morelights.craft_items
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:block", output = "morelights_modern:block",
recipe = { recipe = {
{"", "default:steel_ingot", ""}, {"", a.steel, ""},
{morelights.glass, "morelights:bulb", morelights.glass}, {a.glass_pane, "morelights:bulb", a.glass_pane},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:smallblock", output = "morelights_modern:smallblock",
recipe = { recipe = {
{"", morelights.glass, ""}, {"", a.glass_pane, ""},
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"} {a.steel, "morelights:bulb", a.steel}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:post_d", output = "morelights_modern:post_d",
recipe = { recipe = {
{"dye:dark_grey", "default:steel_ingot", ""}, {a.dye_dark, a.steel, ""},
{"", "morelights:bulb", ""}, {"", "morelights:bulb", ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:post_l", output = "morelights_modern:post_l",
recipe = { recipe = {
{"dye:white", "default:steel_ingot", ""}, {a.dye_light, a.steel, ""},
{"", "morelights:bulb", ""}, {"", "morelights:bulb", ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:streetpost_d 2", output = "morelights_modern:streetpost_d 2",
recipe = { recipe = {
{"dye:dark_grey", "default:steel_ingot", "default:steel_ingot"}, {a.dye_dark, a.steel, a.steel},
{"", "default:steel_ingot", ""}, {"", a.steel, ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:streetpost_l 2", output = "morelights_modern:streetpost_l 2",
recipe = { recipe = {
{"dye:white", "default:steel_ingot", "default:steel_ingot"}, {a.dye_light, a.steel, a.steel},
{"", "default:steel_ingot", ""}, {"", a.steel, ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:barlight_c 4", output = "morelights_modern:barlight_c 4",
recipe = { recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}, {a.steel, a.steel, a.steel},
{"default:copper_ingot", "default:glass", "default:copper_ingot"} {a.copper, a.glass, a.copper}
} }
}) })
@ -313,68 +315,68 @@ minetest.register_craft({
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:ceilinglight", output = "morelights_modern:ceilinglight",
recipe = { recipe = {
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"}, {a.steel, "morelights:bulb", a.steel},
{"", morelights.glass, ""}, {"", a.glass_pane, ""},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:canlight_d", output = "morelights_modern:canlight_d",
recipe = { recipe = {
{"dye:dark_grey", "default:steel_ingot", ""}, {a.dye_dark, a.steel, ""},
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"}, {a.steel, "morelights:bulb", a.steel},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:canlight_l", output = "morelights_modern:canlight_l",
recipe = { recipe = {
{"dye:white", "default:steel_ingot", ""}, {a.dye_light, a.steel, ""},
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"}, {a.steel, "morelights:bulb", a.steel},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:walllamp", output = "morelights_modern:walllamp",
recipe = { recipe = {
{"dye:white", morelights.glass, ""}, {a.dye_light, a.glass_pane, ""},
{morelights.glass, "morelights:bulb", "default:steel_ingot"}, {a.glass_pane, "morelights:bulb", a.steel},
{"", "dye:dark_grey", "default:steel_ingot"} {"", a.dye_dark, a.steel}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:tablelamp_d", output = "morelights_modern:tablelamp_d",
recipe = { recipe = {
{"wool:dark_grey", "morelights:bulb", "wool:dark_grey"}, {a.wool_dark, "morelights:bulb", a.wool_dark},
{"", "default:steel_ingot", ""}, {"", a.steel, ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:tablelamp_l", output = "morelights_modern:tablelamp_l",
recipe = { recipe = {
{"wool:white", "morelights:bulb", "wool:white"}, {a.wool_light, "morelights:bulb", a.wool_light},
{"", "default:steel_ingot", ""}, {"", a.steel, ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:pathlight_d", output = "morelights_modern:pathlight_d",
recipe = { recipe = {
{"dye:dark_grey", "morelights:bulb", ""}, {a.dye_dark, "morelights:bulb", ""},
{"", "default:steel_ingot", ""}, {"", a.steel, ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_modern:pathlight_l", output = "morelights_modern:pathlight_l",
recipe = { recipe = {
{"dye:white", "morelights:bulb", ""}, {a.dye_light, "morelights:bulb", ""},
{"", "default:steel_ingot", ""}, {"", a.steel, ""},
{"", "default:steel_ingot", ""} {"", a.steel, ""}
} }
}) })

@ -1,12 +1,7 @@
-- basic_materials compatibility -- Register custom brass ingot if a suitable replacement doesn't exist.
if morelights.craft_items.brass == nil then
morelights.craft_items.brass = "morelights_vintage:brass_ingot"
local brass_ingot_name
if minetest.get_modpath("basic_materials") then
-- Use basic materials brass ingot
brass_ingot_name = "basic_materials:brass_ingot"
else
-- Register and use morelights brass ingot
minetest.register_craftitem("morelights_vintage:brass_ingot", { minetest.register_craftitem("morelights_vintage:brass_ingot", {
description = "Brass Ingot", description = "Brass Ingot",
inventory_image = "default_steel_ingot.png^[multiply:#FFCE69" inventory_image = "default_steel_ingot.png^[multiply:#FFCE69"
@ -19,8 +14,6 @@ else
"default:copper_ingot", "default:tin_ingot" "default:copper_ingot", "default:tin_ingot"
} }
}) })
brass_ingot_name = "morelights_vintage:brass_ingot"
end end
minetest.register_node("morelights_vintage:chain_b", { minetest.register_node("morelights_vintage:chain_b", {
@ -246,46 +239,48 @@ minetest.register_node("morelights_vintage:chandelier", {
-- Craft recipes -- Craft recipes
-- --
local a = morelights.craft_items
minetest.register_craft({ minetest.register_craft({
output = "morelights_vintage:chain_b", output = "morelights_vintage:chain_b",
recipe = { recipe = {
{"", brass_ingot_name, ""}, {"", a.brass, ""},
{"", "", ""}, {"", "", ""},
{"", brass_ingot_name, ""} {"", a.brass, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_vintage:block", output = "morelights_vintage:block",
recipe = { recipe = {
{"", "default:junglewood", ""}, {"", a.wood_dark, ""},
{morelights.glass, "morelights:bulb", morelights.glass}, {a.glass_pane, "morelights:bulb", a.glass_pane},
{"", "default:junglewood", ""} {"", a.wood_dark, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_vintage:smallblock", output = "morelights_vintage:smallblock",
recipe = { recipe = {
{"", morelights.glass, ""}, {"", a.glass_pane, ""},
{"default:junglewood", "morelights:bulb", "default:junglewood"} {a.wood_dark, "morelights:bulb", a.wood_dark}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_vintage:lantern_f", output = "morelights_vintage:lantern_f",
recipe = { recipe = {
{"", "default:steel_ingot", ""}, {"", a.steel, ""},
{morelights.glass, "morelights:bulb", morelights.glass}, {a.glass_pane, "morelights:bulb", a.glass_pane},
{"default:stick", "default:steel_ingot", "default:stick"} {"default:stick", a.steel, "default:stick"}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_vintage:hangingbulb", output = "morelights_vintage:hangingbulb",
recipe = { recipe = {
{"", "default:steel_ingot", ""}, {"", a.steel, ""},
{"", "default:copper_ingot", ""}, {"", a.copper, ""},
{"", "morelights:bulb", ""} {"", "morelights:bulb", ""}
} }
}) })
@ -293,17 +288,17 @@ minetest.register_craft({
minetest.register_craft({ minetest.register_craft({
output = "morelights_vintage:oillamp", output = "morelights_vintage:oillamp",
recipe = { recipe = {
{"", "default:glass", ""}, {"", a.glass, ""},
{"farming:cotton", brass_ingot_name, ""}, {a.cotton, a.brass, ""},
{"", "default:glass", ""} {"", a.glass, ""}
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "morelights_vintage:chandelier", output = "morelights_vintage:chandelier",
recipe = { recipe = {
{"", brass_ingot_name, ""}, {"", a.brass, ""},
{"morelights:bulb", brass_ingot_name, "morelights:bulb"}, {"morelights:bulb", a.brass, "morelights:bulb"},
{"default:steel_ingot", brass_ingot_name, "default:steel_ingot"} {a.steel, a.brass, a.steel}
} }
}) })