From ccc6627bf34601c03b076063daedc8fe50a13a3f Mon Sep 17 00:00:00 2001 From: ezhh Date: Sun, 2 Jul 2017 15:11:14 +0100 Subject: [PATCH] Tidy up recipes --- crafting.lua | 60 +++++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/crafting.lua b/crafting.lua index 0d91b46..682d889 100644 --- a/crafting.lua +++ b/crafting.lua @@ -1,55 +1,39 @@ +local recipe_list +local modname + -- recipes when caverealms is present if minetest.get_modpath("caverealms") then - - local recipe_list = { + recipe_list = { {"black", "spike",}, {"blue", "glow_crystal",}, {"cyan", "glow_gem",}, {"green", "glow_emerald",}, {"magenta", "salt_gem",}, {"orange", "fire_vine",}, {"purple", "glow_amethyst",}, {"red", "glow_ruby",}, {"yellow", "glow_mese",}, {"white", "glow_ore",}, } - - for _, item in pairs(recipe_list) do - - local colour = item[1] - local ingredient = item[2] - - minetest.register_craft({ - output = "abritorch:torch_"..colour.." 4", - recipe = { - {"default:torch", "", "default:torch" }, - {"", "caverealms:"..ingredient, "" }, - {"default:torch", "", "default:torch" }, - } - }) - end - + modname = "caverealms" +-- recipes when caverealms not present else - -- recipes when caverealms not present - - local recipe_list = { + recipe_list = { {"black", "black",}, {"blue", "blue",}, {"cyan", "cyan",}, {"green", "green",}, {"magenta", "magenta",}, {"orange", "orange",}, {"purple", "violet",}, {"red", "red",}, {"yellow", "yellow",}, {"white", "white",}, } - - for _, item in pairs(recipe_list) do - - local colour = item[1] - local ingredient = item[2] - - minetest.register_craft({ - output = "abritorch:torch_"..colour.." 4", - recipe = { - {"default:torch", "", "default:torch" }, - {"", "dye:"..ingredient, "" }, - {"default:torch", "", "default:torch" }, - } - }) - end - - + modname = "dye" +end + +for i in ipairs(recipe_list) do + local colour = recipe_list[i][1] + local ingredient = recipe_list[i][2] + + minetest.register_craft({ + output = "abritorch:torch_"..colour.." 4", + recipe = { + {"default:torch", "", "default:torch" }, + {"", modname..":"..ingredient, "" }, + {"default:torch", "", "default:torch" }, + } + }) end