From 8f400f32c67cca79d9cc7f1ccdc628ffe35d8fa1 Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Wed, 22 Mar 2023 10:34:14 +0100 Subject: [PATCH] Move registerResourceDust to api --- api.lua | 15 +++++++++++++++ compatibility.lua | 2 ++ craftitems.lua | 45 ++++++++++++++++++--------------------------- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/api.lua b/api.lua index cab5f23..61de155 100644 --- a/api.lua +++ b/api.lua @@ -244,6 +244,21 @@ industrialtest.api.isPowerOutput=function(meta,side) local mode=string.sub(ioConfig,side,side) return (mode=="o" or mode=="a") end +industrialtest.api.registerResourceDust=function(name,displayName,resources,color,registerMaceratorRecipe) + minetest.register_craftitem("industrialtest:"..name.."_dust",{ + description=S(displayName.." Dust"), + inventory_image="industrialtest_dust.png", + color=color + }) + if registerMaceratorRecipe then + for _,value in ipairs(resources) do + industrialtest.api.registerMaceratorRecipe({ + output="industrialtest:"..name.."_dust "..(value.count or 1), + recipe=value.resource + }) + end + end +end industrialtest.api.registerMaceratorRecipe=function(config) local definition={ output=config.output or "", diff --git a/compatibility.lua b/compatibility.lua index 7cf39e1..80514a0 100644 --- a/compatibility.lua +++ b/compatibility.lua @@ -591,6 +591,7 @@ if industrialtest.mclAvailable then _mcl_blast_resistance=3, _mcl_hardness=3, }) + industrialtest.elementKeys.bronzeBlock="industrialtest:bronze_block" minetest.register_craft({ type="shaped", output="industrialtest:bronze_block", @@ -715,6 +716,7 @@ elseif industrialtest.mtgAvailable then industrialtest.elementKeys.stoneWithCopper="default:stone_with_copper" industrialtest.elementKeys.tinBlock="default:tinblock" industrialtest.elementKeys.stoneWithTin="default:stone_with_tin" + industrialtest.elementKeys.bronzeBlock="default:bronzeblock" else error("No compatible games found!") end diff --git a/craftitems.lua b/craftitems.lua index d847ade..0acb912 100644 --- a/craftitems.lua +++ b/craftitems.lua @@ -69,21 +69,6 @@ minetest.register_craft({ -- TODO: add rubber crafts using extractor -- Dust -local function registerResourceDust(name,displayName,resources,color,registerMaceratorRecipe) - minetest.register_craftitem("industrialtest:"..name.."_dust",{ - description=S(displayName.." Dust"), - inventory_image="industrialtest_dust.png", - color=color - }) - if registerMaceratorRecipe then - for _,value in ipairs(resources) do - industrialtest.api.registerMaceratorRecipe({ - output="industrialtest:"..name.."_dust "..(value.count or 1), - recipe=value.resource - }) - end - end -end local resources={ { resource=industrialtest.elementKeys.coalBlock, @@ -101,8 +86,8 @@ if industrialtest.mclAvailable then count=2 }) end -registerResourceDust("coal","Coal",resources,"#101010ff",true) -registerResourceDust("clay","Clay",{ +industrialtest.api.registerResourceDust("coal","Coal",resources,"#101010ff",true) +industrialtest.api.registerResourceDust("clay","Clay",{ { resource=industrialtest.elementKeys.clayBlock, count=2 @@ -125,7 +110,7 @@ if industrialtest.mclAvailable then count=2 }) end -registerResourceDust("diamond","Diamond",resources,"#90e2c9ff",true) +industrialtest.api.registerResourceDust("diamond","Diamond",resources,"#90e2c9ff",true) minetest.register_craft({ type="cooking", output=industrialtest.elementKeys.diamond, @@ -152,14 +137,14 @@ if industrialtest.mclAvailable then count=2 }) end -registerResourceDust("iron","Iron",resources,"#b5b5b5ff",true) +industrialtest.api.registerResourceDust("iron","Iron",resources,"#b5b5b5ff",true) minetest.register_craft({ type="cooking", output=industrialtest.elementKeys.ironIngot, recipe="industrialtest:iron_dust" }) if industrialtest.mclAvailable then - registerResourceDust("lapis_lazuli","Lapis Lazuli",{ + industrialtest.api.registerResourceDust("lapis_lazuli","Lapis Lazuli",{ { resource="mcl_core:lapislazuliblock", count=9 @@ -175,7 +160,7 @@ if industrialtest.mclAvailable then {resource="mcl_core:lapis_lazuli"} },"#292d76ff",true) end -registerResourceDust("obsidian","Obsidian",{{resource=industrialtest.elementKeys.obsidian}},"#292843ff",true) +industrialtest.api.registerResourceDust("obsidian","Obsidian",{{resource=industrialtest.elementKeys.obsidian}},"#292843ff",true) resources={ { resource=industrialtest.elementKeys.goldBlock, @@ -197,7 +182,7 @@ if industrialtest.mclAvailable then count=2 }) end -registerResourceDust("gold","Gold",resources,"#e4e526ff",true) +industrialtest.api.registerResourceDust("gold","Gold",resources,"#e4e526ff",true) minetest.register_craft({ type="cooking", output=industrialtest.elementKeys.goldIngot, @@ -224,7 +209,7 @@ if industrialtest.mclAvailable then count=2 }) end -registerResourceDust("copper","Copper",resources,"#a45e25ff",true) +industrialtest.api.registerResourceDust("copper","Copper",resources,"#a45e25ff",true) minetest.register_craft({ type="cooking", output=industrialtest.elementKeys.copperIngot, @@ -251,7 +236,7 @@ if industrialtest.mclAvailable then count=2 }) end -registerResourceDust("tin","Tin",resources,"#f1f1f1ff",true) +industrialtest.api.registerResourceDust("tin","Tin",resources,"#f1f1f1ff",true) minetest.register_craft({ type="cooking", output=industrialtest.elementKeys.tinIngot, @@ -278,14 +263,14 @@ if industrialtest.mclAvailable then count=2 }) end -registerResourceDust("uranium","Uranium",resources,"#3b8c09ff",true) +industrialtest.api.registerResourceDust("uranium","Uranium",resources,"#3b8c09ff",true) minetest.register_craft({ type="cooking", output="industrialtest:uranium_ingot", recipe="industrialtest:uranium_dust" }) if industrialtest.mtgAvailable then - registerResourceDust("mese","Mese",{ + industrialtest.api.registerResourceDust("mese","Mese",{ { resource="default:mese", count=9 @@ -302,7 +287,13 @@ if industrialtest.mtgAvailable then recipe="industrialtest:mese_dust" }) end -registerResourceDust("bronze","Bronze",{},"#e48e88ff",false) +industrialtest.api.registerResourceDust("bronze","Bronze",{ + { + resource=industrialtest.elementKeys.bronzeBlock, + count=9 + }, + {resource=industrialtest.elementKeys.bronzeIngot} +},"#e48e88ff",true) minetest.register_craft({ type="shaped", output="industrialtest:bronze_dust 9",