From ca10fb0b40368a4bd12a8fdf814eb57fd87b6be7 Mon Sep 17 00:00:00 2001 From: random-geek <35757396+random-geek@users.noreply.github.com> Date: Fri, 18 Sep 2020 15:16:40 -0700 Subject: [PATCH] Centralize craft item names --- morelights/init.lua | 36 +++++++++++++---- morelights/nodes.lua | 28 ++++++------- morelights_extras/init.lua | 22 ++++++----- morelights_modern/init.lua | 78 +++++++++++++++++++------------------ morelights_vintage/init.lua | 51 +++++++++++------------- 5 files changed, 119 insertions(+), 96 deletions(-) diff --git a/morelights/init.lua b/morelights/init.lua index 61f8301..ee6ecc2 100644 --- a/morelights/init.lua +++ b/morelights/init.lua @@ -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") diff --git a/morelights/nodes.lua b/morelights/nodes.lua index 4852cf3..83f4f9d 100644 --- a/morelights/nodes.lua +++ b/morelights/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, ""} } }) diff --git a/morelights_extras/init.lua b/morelights_extras/init.lua index 9b8c2f0..76c5024 100644 --- a/morelights_extras/init.lua +++ b/morelights_extras/init.lua @@ -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} } }) diff --git a/morelights_modern/init.lua b/morelights_modern/init.lua index c5eb09a..31ab8cd 100644 --- a/morelights_modern/init.lua +++ b/morelights_modern/init.lua @@ -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, ""} } }) diff --git a/morelights_vintage/init.lua b/morelights_vintage/init.lua index 8951838..016a913 100644 --- a/morelights_vintage/init.lua +++ b/morelights_vintage/init.lua @@ -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} } })