Implement Compressor

This commit is contained in:
mrkubax10 2023-03-21 14:29:50 +01:00
parent f74f36aeb3
commit cb607d334c
3 changed files with 65 additions and 0 deletions

13
api.lua
View File

@ -18,6 +18,7 @@ local S=minetest.get_translator("industrialtest")
industrialtest.api={}
industrialtest.api.maceratorRecipes={}
industrialtest.api.compressorRecipes={}
local function clamp(num,min,max)
return math.max(math.min(num,max),min)
@ -254,3 +255,15 @@ end
industrialtest.api.getMaceratorRecipeResult=function(recipe)
return industrialtest.api.maceratorRecipes[recipe]
end
industrialtest.api.registerCompressorRecipe=function(config)
local definition={
output=config.output or "",
recipe=config.recipe or "",
time=config.time or 2,
count=config.count or 1
}
industrialtest.api.compressorRecipes[definition.recipe]=definition
end
industrialtest.api.getCompressorRecipeResult=function(recipe)
return industrialtest.api.compressorRecipes[recipe]
end

View File

@ -57,3 +57,20 @@ if industrialtest.mclAvailable then
recipe="mcl_mobitems:bone"
})
end
-- Compressor crafts
industrialtest.api.registerCompressorRecipe({
output=industrialtest.elementKeys.sandstone,
recipe=industrialtest.elementKeys.sand
})
industrialtest.api.registerCompressorRecipe({
output=industrialtest.elementKeys.ice,
recipe=industrialtest.elementKeys.snowball
})
if industrialtest.mclAvailable then
industrialtest.api.registerCompressorRecipe({
output="mcl_nether:nether_brick",
recipe="mcl_nether:netherrack",
count=3
})
end

View File

@ -297,6 +297,22 @@ local function registerSimpleElectricItemProcessor(config)
time=output.time,
src=srcAfter
}
elseif method=="industrialtest.compressing" then
local output=industrialtest.api.getCompressorRecipeResult(item:get_name())
if not output or item:get_count()<output.count then
return {
item=ItemStack(),
time=0,
src=item
}
end
local srcAfter=ItemStack(item:get_name())
srcAfter:set_count(item:get_count()-output.count)
return {
item=ItemStack(output.output),
time=output.time,
src=srcAfter
}
end
error("Unknown craft method passed to craftResultProxy")
end
@ -744,3 +760,22 @@ minetest.register_craft({
{"","industrialtest:electronic_circuit",""}
}
})
registerSimpleElectricItemProcessor({
name="compressor",
displayName="Compressor",
capacity=1400,
flow=600,
opPower=120,
method="industrialtest.compressing",
efficiency=1
})
minetest.register_craft({
type="shaped",
output="industrialtest:compressor",
recipe={
{industrialtest.elementKeys.stone,"",industrialtest.elementKeys.stone},
{industrialtest.elementKeys.stone,"industrialtest:machine_block",industrialtest.elementKeys.stone},
{industrialtest.elementKeys.stone,"industrialtest:electronic_circuit",industrialtest.elementKeys.stone}
}
})