forked from mrkubax10/industrialtest
Implement Compressor
This commit is contained in:
parent
f74f36aeb3
commit
cb607d334c
13
api.lua
13
api.lua
@ -18,6 +18,7 @@ local S=minetest.get_translator("industrialtest")
|
|||||||
|
|
||||||
industrialtest.api={}
|
industrialtest.api={}
|
||||||
industrialtest.api.maceratorRecipes={}
|
industrialtest.api.maceratorRecipes={}
|
||||||
|
industrialtest.api.compressorRecipes={}
|
||||||
|
|
||||||
local function clamp(num,min,max)
|
local function clamp(num,min,max)
|
||||||
return math.max(math.min(num,max),min)
|
return math.max(math.min(num,max),min)
|
||||||
@ -254,3 +255,15 @@ end
|
|||||||
industrialtest.api.getMaceratorRecipeResult=function(recipe)
|
industrialtest.api.getMaceratorRecipeResult=function(recipe)
|
||||||
return industrialtest.api.maceratorRecipes[recipe]
|
return industrialtest.api.maceratorRecipes[recipe]
|
||||||
end
|
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
|
||||||
|
17
crafts.lua
17
crafts.lua
@ -57,3 +57,20 @@ if industrialtest.mclAvailable then
|
|||||||
recipe="mcl_mobitems:bone"
|
recipe="mcl_mobitems:bone"
|
||||||
})
|
})
|
||||||
end
|
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
|
||||||
|
35
machines.lua
35
machines.lua
@ -297,6 +297,22 @@ local function registerSimpleElectricItemProcessor(config)
|
|||||||
time=output.time,
|
time=output.time,
|
||||||
src=srcAfter
|
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
|
end
|
||||||
error("Unknown craft method passed to craftResultProxy")
|
error("Unknown craft method passed to craftResultProxy")
|
||||||
end
|
end
|
||||||
@ -744,3 +760,22 @@ minetest.register_craft({
|
|||||||
{"","industrialtest:electronic_circuit",""}
|
{"","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}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user