feat: support for simple machines
This commit is contained in:
parent
a6bbc0d1d8
commit
af03d0e831
43
api.lua
43
api.lua
@ -32,6 +32,15 @@ industrialtest.api.hvPowerFlow=10200
|
|||||||
industrialtest.api.evPowerFlow=40800
|
industrialtest.api.evPowerFlow=40800
|
||||||
industrialtest.api.ivPowerFlow=163800
|
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)
|
industrialtest.internal.clamp=function(num,min,max)
|
||||||
return math.max(math.min(num,max),min)
|
return math.max(math.min(num,max),min)
|
||||||
end
|
end
|
||||||
@ -750,14 +759,16 @@ industrialtest.api.registerMaceratorRecipe=function(config)
|
|||||||
recipe=config.recipe or "",
|
recipe=config.recipe or "",
|
||||||
time=config.time or 2
|
time=config.time or 2
|
||||||
}
|
}
|
||||||
|
|
||||||
if mcl_craftguide ~= nil then
|
if mcl_craftguide ~= nil then
|
||||||
mcl_craftguide.register_craft({
|
mcl_craftguide.register_craft({
|
||||||
type = "industrialtest.macerating",
|
type = industrialtest.api.craftingMethods.macerating,
|
||||||
width = 1,
|
width = 1,
|
||||||
output = definition.output,
|
output = definition.output,
|
||||||
items = {definition.recipe}
|
items = {definition.recipe}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
industrialtest.api.maceratorRecipes[definition.recipe]=definition
|
industrialtest.api.maceratorRecipes[definition.recipe]=definition
|
||||||
end
|
end
|
||||||
-- \brief Returns macerator recipe result
|
-- \brief Returns macerator recipe result
|
||||||
@ -776,6 +787,16 @@ industrialtest.api.registerCompressorRecipe=function(config)
|
|||||||
time=config.time or 2,
|
time=config.time or 2,
|
||||||
count=config.count or 1
|
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
|
industrialtest.api.compressorRecipes[definition.recipe]=definition
|
||||||
end
|
end
|
||||||
-- \brief Returns macerator recipe result
|
-- \brief Returns macerator recipe result
|
||||||
@ -790,6 +811,16 @@ industrialtest.api.registerExtractorRecipe=function(config)
|
|||||||
recipe=config.recipe or "",
|
recipe=config.recipe or "",
|
||||||
time=config.time or 2
|
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
|
industrialtest.api.extractorRecipes[definition.recipe]=definition
|
||||||
end
|
end
|
||||||
industrialtest.api.getExtractorRecipeResult=function(recipe)
|
industrialtest.api.getExtractorRecipeResult=function(recipe)
|
||||||
@ -802,6 +833,16 @@ industrialtest.api.registerCableFormerRecipe=function(config)
|
|||||||
recipe=config.recipe or "",
|
recipe=config.recipe or "",
|
||||||
time=config.time or 2
|
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
|
industrialtest.api.cableFormerRecipes[definition.recipe]=definition
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -611,10 +611,30 @@ if industrialtest.mclAvailable then
|
|||||||
y_min=mcl_vars.mg_overworld_min
|
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"),
|
description = S("Macerating"),
|
||||||
icon = "industrialtest_machine_block.png^industrialtest_macerator_front_active.png"
|
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
|
elseif industrialtest.mtgAvailable then
|
||||||
industrialtest.internal.explode=function(pos,radius)
|
industrialtest.internal.explode=function(pos,radius)
|
||||||
|
@ -24,7 +24,7 @@ industrialtest.internal.registerSimpleElectricItemProcessor({
|
|||||||
capacity=1400,
|
capacity=1400,
|
||||||
flow=industrialtest.api.lvPowerFlow,
|
flow=industrialtest.api.lvPowerFlow,
|
||||||
opPower=80,
|
opPower=80,
|
||||||
method="industrialtest.cable_forming",
|
method=industrialtest.api.craftingMethods.cableForming,
|
||||||
efficiency=1
|
efficiency=1
|
||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -453,7 +453,7 @@ local function craftResultProxy(method,item)
|
|||||||
time=output.time,
|
time=output.time,
|
||||||
src=after.items[1]
|
src=after.items[1]
|
||||||
}
|
}
|
||||||
elseif method=="industrialtest.macerating" then
|
elseif method==industrialtest.api.craftingMethods.macerating then
|
||||||
local output=industrialtest.api.getMaceratorRecipeResult(item:get_name())
|
local output=industrialtest.api.getMaceratorRecipeResult(item:get_name())
|
||||||
if not output then
|
if not output then
|
||||||
return {
|
return {
|
||||||
@ -469,7 +469,7 @@ local function craftResultProxy(method,item)
|
|||||||
time=output.time,
|
time=output.time,
|
||||||
src=srcAfter
|
src=srcAfter
|
||||||
}
|
}
|
||||||
elseif method=="industrialtest.compressing" then
|
elseif method==industrialtest.api.craftingMethods.compressing then
|
||||||
local output=industrialtest.api.getCompressorRecipeResult(item:get_name())
|
local output=industrialtest.api.getCompressorRecipeResult(item:get_name())
|
||||||
if not output or item:get_count()<output.count then
|
if not output or item:get_count()<output.count then
|
||||||
return {
|
return {
|
||||||
@ -485,7 +485,7 @@ local function craftResultProxy(method,item)
|
|||||||
time=output.time,
|
time=output.time,
|
||||||
src=srcAfter
|
src=srcAfter
|
||||||
}
|
}
|
||||||
elseif method=="industrialtest.extracting" then
|
elseif method==industrialtest.api.craftingMethods.extracting then
|
||||||
local output=industrialtest.api.getExtractorRecipeResult(item:get_name())
|
local output=industrialtest.api.getExtractorRecipeResult(item:get_name())
|
||||||
if not output then
|
if not output then
|
||||||
return {
|
return {
|
||||||
@ -501,7 +501,7 @@ local function craftResultProxy(method,item)
|
|||||||
time=output.time,
|
time=output.time,
|
||||||
src=srcAfter
|
src=srcAfter
|
||||||
}
|
}
|
||||||
elseif method=="industrialtest.recycling" then
|
elseif method==industrialtest.api.craftingMethods.recycling then
|
||||||
local srcAfter=ItemStack(item:get_name())
|
local srcAfter=ItemStack(item:get_name())
|
||||||
srcAfter:set_count(item:get_count()-1)
|
srcAfter:set_count(item:get_count()-1)
|
||||||
return {
|
return {
|
||||||
@ -509,7 +509,7 @@ local function craftResultProxy(method,item)
|
|||||||
time=2,
|
time=2,
|
||||||
src=srcAfter
|
src=srcAfter
|
||||||
}
|
}
|
||||||
elseif method=="industrialtest.cable_forming" then
|
elseif method==industrialtest.api.craftingMethods.cableForming then
|
||||||
local output=industrialtest.api.getCableFormerRecipeResult(item:get_name())
|
local output=industrialtest.api.getCableFormerRecipeResult(item:get_name())
|
||||||
if not output then
|
if not output then
|
||||||
return {
|
return {
|
||||||
@ -525,7 +525,7 @@ local function craftResultProxy(method,item)
|
|||||||
time=output.time,
|
time=output.time,
|
||||||
src=srcAfter
|
src=srcAfter
|
||||||
}
|
}
|
||||||
elseif method=="industrialtest.mass_fabricating" then
|
elseif method==industrialtest.api.craftingMethods.massFabricating then
|
||||||
if item:get_count()<34 then
|
if item:get_count()<34 then
|
||||||
return {
|
return {
|
||||||
item=ItemStack(),
|
item=ItemStack(),
|
||||||
|
@ -24,7 +24,7 @@ industrialtest.internal.registerSimpleElectricItemProcessor({
|
|||||||
capacity=1400,
|
capacity=1400,
|
||||||
flow=industrialtest.api.lvPowerFlow,
|
flow=industrialtest.api.lvPowerFlow,
|
||||||
opPower=120,
|
opPower=120,
|
||||||
method="industrialtest.compressing",
|
method=industrialtest.api.craftingMethods.compressing,
|
||||||
efficiency=1
|
efficiency=1
|
||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -24,7 +24,7 @@ industrialtest.internal.registerSimpleElectricItemProcessor({
|
|||||||
capacity=1200,
|
capacity=1200,
|
||||||
flow=industrialtest.api.lvPowerFlow,
|
flow=industrialtest.api.lvPowerFlow,
|
||||||
opPower=100,
|
opPower=100,
|
||||||
method="industrialtest.macerating",
|
method=industrialtest.api.craftingMethods.macerating,
|
||||||
efficiency=1
|
efficiency=1
|
||||||
})
|
})
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
Loading…
Reference in New Issue
Block a user