Move registerResourceDust to api

This commit is contained in:
mrkubax10 2023-03-22 10:34:14 +01:00
parent edd9223857
commit 8f400f32c6
3 changed files with 35 additions and 27 deletions

15
api.lua
View File

@ -244,6 +244,21 @@ industrialtest.api.isPowerOutput=function(meta,side)
local mode=string.sub(ioConfig,side,side) local mode=string.sub(ioConfig,side,side)
return (mode=="o" or mode=="a") return (mode=="o" or mode=="a")
end 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) industrialtest.api.registerMaceratorRecipe=function(config)
local definition={ local definition={
output=config.output or "", output=config.output or "",

View File

@ -591,6 +591,7 @@ if industrialtest.mclAvailable then
_mcl_blast_resistance=3, _mcl_blast_resistance=3,
_mcl_hardness=3, _mcl_hardness=3,
}) })
industrialtest.elementKeys.bronzeBlock="industrialtest:bronze_block"
minetest.register_craft({ minetest.register_craft({
type="shaped", type="shaped",
output="industrialtest:bronze_block", output="industrialtest:bronze_block",
@ -715,6 +716,7 @@ elseif industrialtest.mtgAvailable then
industrialtest.elementKeys.stoneWithCopper="default:stone_with_copper" industrialtest.elementKeys.stoneWithCopper="default:stone_with_copper"
industrialtest.elementKeys.tinBlock="default:tinblock" industrialtest.elementKeys.tinBlock="default:tinblock"
industrialtest.elementKeys.stoneWithTin="default:stone_with_tin" industrialtest.elementKeys.stoneWithTin="default:stone_with_tin"
industrialtest.elementKeys.bronzeBlock="default:bronzeblock"
else else
error("No compatible games found!") error("No compatible games found!")
end end

View File

@ -69,21 +69,6 @@ minetest.register_craft({
-- TODO: add rubber crafts using extractor -- TODO: add rubber crafts using extractor
-- Dust -- 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={ local resources={
{ {
resource=industrialtest.elementKeys.coalBlock, resource=industrialtest.elementKeys.coalBlock,
@ -101,8 +86,8 @@ if industrialtest.mclAvailable then
count=2 count=2
}) })
end end
registerResourceDust("coal","Coal",resources,"#101010ff",true) industrialtest.api.registerResourceDust("coal","Coal",resources,"#101010ff",true)
registerResourceDust("clay","Clay",{ industrialtest.api.registerResourceDust("clay","Clay",{
{ {
resource=industrialtest.elementKeys.clayBlock, resource=industrialtest.elementKeys.clayBlock,
count=2 count=2
@ -125,7 +110,7 @@ if industrialtest.mclAvailable then
count=2 count=2
}) })
end end
registerResourceDust("diamond","Diamond",resources,"#90e2c9ff",true) industrialtest.api.registerResourceDust("diamond","Diamond",resources,"#90e2c9ff",true)
minetest.register_craft({ minetest.register_craft({
type="cooking", type="cooking",
output=industrialtest.elementKeys.diamond, output=industrialtest.elementKeys.diamond,
@ -152,14 +137,14 @@ if industrialtest.mclAvailable then
count=2 count=2
}) })
end end
registerResourceDust("iron","Iron",resources,"#b5b5b5ff",true) industrialtest.api.registerResourceDust("iron","Iron",resources,"#b5b5b5ff",true)
minetest.register_craft({ minetest.register_craft({
type="cooking", type="cooking",
output=industrialtest.elementKeys.ironIngot, output=industrialtest.elementKeys.ironIngot,
recipe="industrialtest:iron_dust" recipe="industrialtest:iron_dust"
}) })
if industrialtest.mclAvailable then if industrialtest.mclAvailable then
registerResourceDust("lapis_lazuli","Lapis Lazuli",{ industrialtest.api.registerResourceDust("lapis_lazuli","Lapis Lazuli",{
{ {
resource="mcl_core:lapislazuliblock", resource="mcl_core:lapislazuliblock",
count=9 count=9
@ -175,7 +160,7 @@ if industrialtest.mclAvailable then
{resource="mcl_core:lapis_lazuli"} {resource="mcl_core:lapis_lazuli"}
},"#292d76ff",true) },"#292d76ff",true)
end end
registerResourceDust("obsidian","Obsidian",{{resource=industrialtest.elementKeys.obsidian}},"#292843ff",true) industrialtest.api.registerResourceDust("obsidian","Obsidian",{{resource=industrialtest.elementKeys.obsidian}},"#292843ff",true)
resources={ resources={
{ {
resource=industrialtest.elementKeys.goldBlock, resource=industrialtest.elementKeys.goldBlock,
@ -197,7 +182,7 @@ if industrialtest.mclAvailable then
count=2 count=2
}) })
end end
registerResourceDust("gold","Gold",resources,"#e4e526ff",true) industrialtest.api.registerResourceDust("gold","Gold",resources,"#e4e526ff",true)
minetest.register_craft({ minetest.register_craft({
type="cooking", type="cooking",
output=industrialtest.elementKeys.goldIngot, output=industrialtest.elementKeys.goldIngot,
@ -224,7 +209,7 @@ if industrialtest.mclAvailable then
count=2 count=2
}) })
end end
registerResourceDust("copper","Copper",resources,"#a45e25ff",true) industrialtest.api.registerResourceDust("copper","Copper",resources,"#a45e25ff",true)
minetest.register_craft({ minetest.register_craft({
type="cooking", type="cooking",
output=industrialtest.elementKeys.copperIngot, output=industrialtest.elementKeys.copperIngot,
@ -251,7 +236,7 @@ if industrialtest.mclAvailable then
count=2 count=2
}) })
end end
registerResourceDust("tin","Tin",resources,"#f1f1f1ff",true) industrialtest.api.registerResourceDust("tin","Tin",resources,"#f1f1f1ff",true)
minetest.register_craft({ minetest.register_craft({
type="cooking", type="cooking",
output=industrialtest.elementKeys.tinIngot, output=industrialtest.elementKeys.tinIngot,
@ -278,14 +263,14 @@ if industrialtest.mclAvailable then
count=2 count=2
}) })
end end
registerResourceDust("uranium","Uranium",resources,"#3b8c09ff",true) industrialtest.api.registerResourceDust("uranium","Uranium",resources,"#3b8c09ff",true)
minetest.register_craft({ minetest.register_craft({
type="cooking", type="cooking",
output="industrialtest:uranium_ingot", output="industrialtest:uranium_ingot",
recipe="industrialtest:uranium_dust" recipe="industrialtest:uranium_dust"
}) })
if industrialtest.mtgAvailable then if industrialtest.mtgAvailable then
registerResourceDust("mese","Mese",{ industrialtest.api.registerResourceDust("mese","Mese",{
{ {
resource="default:mese", resource="default:mese",
count=9 count=9
@ -302,7 +287,13 @@ if industrialtest.mtgAvailable then
recipe="industrialtest:mese_dust" recipe="industrialtest:mese_dust"
}) })
end 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({ minetest.register_craft({
type="shaped", type="shaped",
output="industrialtest:bronze_dust 9", output="industrialtest:bronze_dust 9",