Implement Extractor
This commit is contained in:
parent
2bda4febb9
commit
84014b9d9b
12
api.lua
12
api.lua
|
@ -19,6 +19,7 @@ local S=minetest.get_translator("industrialtest")
|
|||
industrialtest.api={}
|
||||
industrialtest.api.maceratorRecipes={}
|
||||
industrialtest.api.compressorRecipes={}
|
||||
industrialtest.api.extractorRecipes={}
|
||||
|
||||
local function clamp(num,min,max)
|
||||
return math.max(math.min(num,max),min)
|
||||
|
@ -363,3 +364,14 @@ end
|
|||
industrialtest.api.getCompressorRecipeResult=function(recipe)
|
||||
return industrialtest.api.compressorRecipes[recipe]
|
||||
end
|
||||
industrialtest.api.registerExtractorRecipe=function(config)
|
||||
local definition={
|
||||
output=config.output or "",
|
||||
recipe=config.recipe or "",
|
||||
time=config.time or 2
|
||||
}
|
||||
industrialtest.api.extractorRecipes[definition.recipe]=definition
|
||||
end
|
||||
industrialtest.api.getExtractorRecipeResult=function(recipe)
|
||||
return industrialtest.api.extractorRecipes[recipe]
|
||||
end
|
||||
|
|
|
@ -66,7 +66,18 @@ minetest.register_craft({
|
|||
output="industrialtest:rubber",
|
||||
recipe="industrialtest:sticky_resin"
|
||||
})
|
||||
-- TODO: add rubber crafts using extractor
|
||||
industrialtest.api.registerExtractorRecipe({
|
||||
output="industrialtest:rubber",
|
||||
recipe="industrialtest:rubber_wood"
|
||||
})
|
||||
industrialtest.api.registerExtractorRecipe({
|
||||
output="industrialtest:rubber",
|
||||
recipe="industrialtest:rubber_sapling"
|
||||
})
|
||||
industrialtest.api.registerExtractorRecipe({
|
||||
output="industrialtest:rubber 3",
|
||||
recipe="industrialtest:sticky_resin"
|
||||
})
|
||||
|
||||
-- Dust
|
||||
local resources={
|
||||
|
|
34
machines.lua
34
machines.lua
|
@ -313,6 +313,22 @@ local function registerSimpleElectricItemProcessor(config)
|
|||
time=output.time,
|
||||
src=srcAfter
|
||||
}
|
||||
elseif method=="industrialtest.extracting" then
|
||||
local output=industrialtest.api.getExtractorRecipeResult(item:get_name())
|
||||
if not output then
|
||||
return {
|
||||
item=ItemStack(),
|
||||
time=0,
|
||||
src=item
|
||||
}
|
||||
end
|
||||
local srcAfter=ItemStack(item:get_name())
|
||||
srcAfter:set_count(item:get_count()-1)
|
||||
return {
|
||||
item=ItemStack(output.output),
|
||||
time=output.time,
|
||||
src=srcAfter
|
||||
}
|
||||
end
|
||||
error("Unknown craft method passed to craftResultProxy")
|
||||
end
|
||||
|
@ -779,3 +795,21 @@ minetest.register_craft({
|
|||
{industrialtest.elementKeys.stone,"industrialtest:electronic_circuit",industrialtest.elementKeys.stone}
|
||||
}
|
||||
})
|
||||
|
||||
registerSimpleElectricItemProcessor({
|
||||
name="extractor",
|
||||
displayName="Extractor",
|
||||
capacity=900,
|
||||
flow=600,
|
||||
opPower=100,
|
||||
method="industrialtest.extracting",
|
||||
efficiency=1
|
||||
})
|
||||
minetest.register_craft({
|
||||
type="shaped",
|
||||
output="industrialtest:extractor",
|
||||
recipe={
|
||||
{"industrialtest:treetap","industrialtest:machine_block","industrialtest:treetap"},
|
||||
{"industrialtest:treetap","industrialtest:electronic_circuit","industrialtest:treetap"}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue