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 = {}
if minetest.get_modpath("xpanes") then
morelights.glass = "xpanes:pane_flat"
else
morelights.glass = "default:glass"
end
function morelights.register_variants(variants, fixedDef)
for _, variant in ipairs(variants) do
local name = variant.name
@ -50,6 +44,34 @@ function morelights.rotate_and_place(itemstack, placer, pointed_thing, lookup)
return itemstack
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")
dofile(path .. "/nodes.lua")
dofile(path .. DIR_DELIM .. "nodes.lua")

@ -132,47 +132,49 @@ morelights.register_variants({
-- Craft recipes
--
local a = morelights.craft_items
minetest.register_craft({
output = "morelights:bulb",
recipe = {
{"", "default:glass", ""},
{"", "default:copper_ingot", ""},
{"", "default:steel_ingot", ""}
{"", a.glass, ""},
{"", a.copper, ""},
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights:pole_d 2",
recipe = {
{"dye:dark_grey", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_dark, a.steel, ""},
{"", a.steel, ""},
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights:pole_l 2",
recipe = {
{"dye:white", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_light, a.steel, ""},
{"", a.steel, ""},
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights:chain_d",
recipe = {
{"dye:dark_grey", "default:steel_ingot", ""},
{a.dye_dark, a.steel, ""},
{"", "", ""},
{"", "default:steel_ingot", ""}
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights:chain_l",
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
--
local a = morelights.craft_items
minetest.register_craft({
output = "morelights_extras:f_block",
recipe = {
{"default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment"},
{morelights.glass, "morelights:bulb", morelights.glass},
{"default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment"}
{a.mese_fragment, a.steel, a.mese_fragment},
{a.glass_pane, "morelights:bulb", a.glass_pane},
{a.mese_fragment, a.steel, a.mese_fragment}
}
})
minetest.register_craft({
output = "morelights_extras:dirt_with_grass",
recipe = {
{"", morelights.glass, ""},
{"", a.glass_pane, ""},
{"", "morelights:bulb", ""},
{"default:grass_1", "default:dirt", ""}
{a.grass, a.dirt, ""}
}
})
minetest.register_craft({
output = "morelights_extras:stone_block",
recipe = {
{"", morelights.glass, ""},
{"", a.glass_pane, ""},
{"", "morelights:bulb", ""},
{"", "default:stone_block", ""}
{"", a.stone_block, ""}
}
})
minetest.register_craft({
output = "morelights_extras:sandstone_block",
recipe = {
{"", morelights.glass, ""},
{"", a.glass_pane, ""},
{"", "morelights:bulb", ""},
{"", "default:sandstone_block", ""}
{"", a.sandstone_block, ""}
}
})
minetest.register_craft({
output = "morelights_extras:stairlight",
recipe = {
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"}
{a.steel, "morelights:bulb", a.steel}
}
})

@ -237,64 +237,66 @@ morelights.register_variants({
-- Craft recipes
--
local a = morelights.craft_items
minetest.register_craft({
output = "morelights_modern:block",
recipe = {
{"", "default:steel_ingot", ""},
{morelights.glass, "morelights:bulb", morelights.glass},
{"", "default:steel_ingot", ""}
{"", a.steel, ""},
{a.glass_pane, "morelights:bulb", a.glass_pane},
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights_modern:smallblock",
recipe = {
{"", morelights.glass, ""},
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"}
{"", a.glass_pane, ""},
{a.steel, "morelights:bulb", a.steel}
}
})
minetest.register_craft({
output = "morelights_modern:post_d",
recipe = {
{"dye:dark_grey", "default:steel_ingot", ""},
{a.dye_dark, a.steel, ""},
{"", "morelights:bulb", ""},
{"", "default:steel_ingot", ""}
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights_modern:post_l",
recipe = {
{"dye:white", "default:steel_ingot", ""},
{a.dye_light, a.steel, ""},
{"", "morelights:bulb", ""},
{"", "default:steel_ingot", ""}
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights_modern:streetpost_d 2",
recipe = {
{"dye:dark_grey", "default:steel_ingot", "default:steel_ingot"},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_dark, a.steel, a.steel},
{"", a.steel, ""},
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights_modern:streetpost_l 2",
recipe = {
{"dye:white", "default:steel_ingot", "default:steel_ingot"},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_light, a.steel, a.steel},
{"", a.steel, ""},
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights_modern:barlight_c 4",
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:copper_ingot", "default:glass", "default:copper_ingot"}
{a.steel, a.steel, a.steel},
{a.copper, a.glass, a.copper}
}
})
@ -313,68 +315,68 @@ minetest.register_craft({
minetest.register_craft({
output = "morelights_modern:ceilinglight",
recipe = {
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"},
{"", morelights.glass, ""},
{a.steel, "morelights:bulb", a.steel},
{"", a.glass_pane, ""},
}
})
minetest.register_craft({
output = "morelights_modern:canlight_d",
recipe = {
{"dye:dark_grey", "default:steel_ingot", ""},
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"},
{a.dye_dark, a.steel, ""},
{a.steel, "morelights:bulb", a.steel},
}
})
minetest.register_craft({
output = "morelights_modern:canlight_l",
recipe = {
{"dye:white", "default:steel_ingot", ""},
{"default:steel_ingot", "morelights:bulb", "default:steel_ingot"},
{a.dye_light, a.steel, ""},
{a.steel, "morelights:bulb", a.steel},
}
})
minetest.register_craft({
output = "morelights_modern:walllamp",
recipe = {
{"dye:white", morelights.glass, ""},
{morelights.glass, "morelights:bulb", "default:steel_ingot"},
{"", "dye:dark_grey", "default:steel_ingot"}
{a.dye_light, a.glass_pane, ""},
{a.glass_pane, "morelights:bulb", a.steel},
{"", a.dye_dark, a.steel}
}
})
minetest.register_craft({
output = "morelights_modern:tablelamp_d",
recipe = {
{"wool:dark_grey", "morelights:bulb", "wool:dark_grey"},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.wool_dark, "morelights:bulb", a.wool_dark},
{"", a.steel, ""},
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights_modern:tablelamp_l",
recipe = {
{"wool:white", "morelights:bulb", "wool:white"},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.wool_light, "morelights:bulb", a.wool_light},
{"", a.steel, ""},
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights_modern:pathlight_d",
recipe = {
{"dye:dark_grey", "morelights:bulb", ""},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_dark, "morelights:bulb", ""},
{"", a.steel, ""},
{"", a.steel, ""}
}
})
minetest.register_craft({
output = "morelights_modern:pathlight_l",
recipe = {
{"dye:white", "morelights:bulb", ""},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
{a.dye_light, "morelights:bulb", ""},
{"", a.steel, ""},
{"", 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", {
description = "Brass Ingot",
inventory_image = "default_steel_ingot.png^[multiply:#FFCE69"
@ -19,8 +14,6 @@ else
"default:copper_ingot", "default:tin_ingot"
}
})
brass_ingot_name = "morelights_vintage:brass_ingot"
end
minetest.register_node("morelights_vintage:chain_b", {
@ -246,46 +239,48 @@ minetest.register_node("morelights_vintage:chandelier", {
-- Craft recipes
--
local a = morelights.craft_items
minetest.register_craft({
output = "morelights_vintage:chain_b",
recipe = {
{"", brass_ingot_name, ""},
{"", a.brass, ""},
{"", "", ""},
{"", brass_ingot_name, ""}
{"", a.brass, ""}
}
})
minetest.register_craft({
output = "morelights_vintage:block",
recipe = {
{"", "default:junglewood", ""},
{morelights.glass, "morelights:bulb", morelights.glass},
{"", "default:junglewood", ""}
{"", a.wood_dark, ""},
{a.glass_pane, "morelights:bulb", a.glass_pane},
{"", a.wood_dark, ""}
}
})
minetest.register_craft({
output = "morelights_vintage:smallblock",
recipe = {
{"", morelights.glass, ""},
{"default:junglewood", "morelights:bulb", "default:junglewood"}
{"", a.glass_pane, ""},
{a.wood_dark, "morelights:bulb", a.wood_dark}
}
})
minetest.register_craft({
output = "morelights_vintage:lantern_f",
recipe = {
{"", "default:steel_ingot", ""},
{morelights.glass, "morelights:bulb", morelights.glass},
{"default:stick", "default:steel_ingot", "default:stick"}
{"", a.steel, ""},
{a.glass_pane, "morelights:bulb", a.glass_pane},
{"default:stick", a.steel, "default:stick"}
}
})
minetest.register_craft({
output = "morelights_vintage:hangingbulb",
recipe = {
{"", "default:steel_ingot", ""},
{"", "default:copper_ingot", ""},
{"", a.steel, ""},
{"", a.copper, ""},
{"", "morelights:bulb", ""}
}
})
@ -293,17 +288,17 @@ minetest.register_craft({
minetest.register_craft({
output = "morelights_vintage:oillamp",
recipe = {
{"", "default:glass", ""},
{"farming:cotton", brass_ingot_name, ""},
{"", "default:glass", ""}
{"", a.glass, ""},
{a.cotton, a.brass, ""},
{"", a.glass, ""}
}
})
minetest.register_craft({
output = "morelights_vintage:chandelier",
recipe = {
{"", brass_ingot_name, ""},
{"morelights:bulb", brass_ingot_name, "morelights:bulb"},
{"default:steel_ingot", brass_ingot_name, "default:steel_ingot"}
{"", a.brass, ""},
{"morelights:bulb", a.brass, "morelights:bulb"},
{a.steel, a.brass, a.steel}
}
})