feat: support for simple machines

This commit is contained in:
Handful of Frogs 2024-05-11 12:06:27 +03:00
parent a6bbc0d1d8
commit af03d0e831
6 changed files with 72 additions and 11 deletions

43
api.lua
View File

@ -32,6 +32,15 @@ industrialtest.api.hvPowerFlow=10200
industrialtest.api.evPowerFlow=40800
industrialtest.api.ivPowerFlow=163800
industrialtest.api.craftingMethods={
macerating="industrialtest.macerating",
compressing="industrialtest.compressing",
extracting="industrialtest.extracting",
recycling="industrialtest.recycling",
cableForming="industrialtest.cable_forming",
massFabricating="industrialtest.mass_fabricating",
}
industrialtest.internal.clamp=function(num,min,max)
return math.max(math.min(num,max),min)
end
@ -750,14 +759,16 @@ industrialtest.api.registerMaceratorRecipe=function(config)
recipe=config.recipe or "",
time=config.time or 2
}
if mcl_craftguide ~= nil then
mcl_craftguide.register_craft({
type = "industrialtest.macerating",
type = industrialtest.api.craftingMethods.macerating,
width = 1,
output = definition.output,
items = {definition.recipe}
})
end
industrialtest.api.maceratorRecipes[definition.recipe]=definition
end
-- \brief Returns macerator recipe result
@ -776,6 +787,16 @@ industrialtest.api.registerCompressorRecipe=function(config)
time=config.time or 2,
count=config.count or 1
}
if mcl_craftguide ~= nil then
mcl_craftguide.register_craft({
type = industrialtest.api.craftingMethods.compressing,
width = 1,
output = definition.output,
items = {definition.recipe}
})
end
industrialtest.api.compressorRecipes[definition.recipe]=definition
end
-- \brief Returns macerator recipe result
@ -790,6 +811,16 @@ industrialtest.api.registerExtractorRecipe=function(config)
recipe=config.recipe or "",
time=config.time or 2
}
if mcl_craftguide ~= nil then
mcl_craftguide.register_craft({
type = industrialtest.api.craftingMethods.extracting,
width = 1,
output = definition.output,
items = {definition.recipe}
})
end
industrialtest.api.extractorRecipes[definition.recipe]=definition
end
industrialtest.api.getExtractorRecipeResult=function(recipe)
@ -802,6 +833,16 @@ industrialtest.api.registerCableFormerRecipe=function(config)
recipe=config.recipe or "",
time=config.time or 2
}
if mcl_craftguide ~= nil then
mcl_craftguide.register_craft({
type = industrialtest.api.craftingMethods.cableForming,
width = 1,
output = definition.output,
items = {definition.recipe}
})
end
industrialtest.api.cableFormerRecipes[definition.recipe]=definition
end

View File

@ -611,10 +611,30 @@ if industrialtest.mclAvailable then
y_min=mcl_vars.mg_overworld_min
})
mcl_craftguide.register_craft_type("industrialtest.macerating", {
mcl_craftguide.register_craft_type(industrialtest.api.craftingMethods.macerating, {
description = S("Macerating"),
icon = "industrialtest_machine_block.png^industrialtest_macerator_front_active.png"
})
mcl_craftguide.register_craft_type(industrialtest.api.craftingMethods.compressing, {
description = S("Compressing"),
icon = "industrialtest_machine_block.png^industrialtest_compressor_front_active.png"
})
mcl_craftguide.register_craft_type(industrialtest.api.craftingMethods.extracting, {
description = S("Extracting"),
icon = "industrialtest_machine_block.png^industrialtest_extractor_front_active.png"
})
mcl_craftguide.register_craft_type(industrialtest.api.craftingMethods.recycling, {
description = S("Recycling"),
icon = "industrialtest_machine_block.png^industrialtest_recycler_top_active.png"
})
mcl_craftguide.register_craft_type(industrialtest.api.craftingMethods.cableForming, {
description = S("Cable Forming"),
icon = "industrialtest_machine_block.png^industrialtest_cable_former_front_active.png"
})
mcl_craftguide.register_craft_type(industrialtest.api.craftingMethods.massFabricating, {
description = S("Mass Fabricating"),
icon = "industrialtest_machine_block.png^industrialtest_mass_fabricator_front_active.png"
})
elseif industrialtest.mtgAvailable then
industrialtest.internal.explode=function(pos,radius)

View File

@ -24,7 +24,7 @@ industrialtest.internal.registerSimpleElectricItemProcessor({
capacity=1400,
flow=industrialtest.api.lvPowerFlow,
opPower=80,
method="industrialtest.cable_forming",
method=industrialtest.api.craftingMethods.cableForming,
efficiency=1
})
minetest.register_craft({

View File

@ -453,7 +453,7 @@ local function craftResultProxy(method,item)
time=output.time,
src=after.items[1]
}
elseif method=="industrialtest.macerating" then
elseif method==industrialtest.api.craftingMethods.macerating then
local output=industrialtest.api.getMaceratorRecipeResult(item:get_name())
if not output then
return {
@ -469,7 +469,7 @@ local function craftResultProxy(method,item)
time=output.time,
src=srcAfter
}
elseif method=="industrialtest.compressing" then
elseif method==industrialtest.api.craftingMethods.compressing then
local output=industrialtest.api.getCompressorRecipeResult(item:get_name())
if not output or item:get_count()<output.count then
return {
@ -485,7 +485,7 @@ local function craftResultProxy(method,item)
time=output.time,
src=srcAfter
}
elseif method=="industrialtest.extracting" then
elseif method==industrialtest.api.craftingMethods.extracting then
local output=industrialtest.api.getExtractorRecipeResult(item:get_name())
if not output then
return {
@ -501,7 +501,7 @@ local function craftResultProxy(method,item)
time=output.time,
src=srcAfter
}
elseif method=="industrialtest.recycling" then
elseif method==industrialtest.api.craftingMethods.recycling then
local srcAfter=ItemStack(item:get_name())
srcAfter:set_count(item:get_count()-1)
return {
@ -509,7 +509,7 @@ local function craftResultProxy(method,item)
time=2,
src=srcAfter
}
elseif method=="industrialtest.cable_forming" then
elseif method==industrialtest.api.craftingMethods.cableForming then
local output=industrialtest.api.getCableFormerRecipeResult(item:get_name())
if not output then
return {
@ -525,7 +525,7 @@ local function craftResultProxy(method,item)
time=output.time,
src=srcAfter
}
elseif method=="industrialtest.mass_fabricating" then
elseif method==industrialtest.api.craftingMethods.massFabricating then
if item:get_count()<34 then
return {
item=ItemStack(),

View File

@ -24,7 +24,7 @@ industrialtest.internal.registerSimpleElectricItemProcessor({
capacity=1400,
flow=industrialtest.api.lvPowerFlow,
opPower=120,
method="industrialtest.compressing",
method=industrialtest.api.craftingMethods.compressing,
efficiency=1
})
minetest.register_craft({

View File

@ -24,7 +24,7 @@ industrialtest.internal.registerSimpleElectricItemProcessor({
capacity=1200,
flow=industrialtest.api.lvPowerFlow,
opPower=100,
method="industrialtest.macerating",
method=industrialtest.api.craftingMethods.macerating,
efficiency=1
})
minetest.register_craft({