WIP: Craft guide support (#20) #21

Closed
HandfulOfFrogs wants to merge 5 commits from HandfulOfFrogs/industrialtest:craftguide into master
6 changed files with 84 additions and 9 deletions

49
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,6 +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.api.craftingMethods.macerating,
width = 1,
output = definition.output,
items = {definition.recipe}
})
end
industrialtest.api.maceratorRecipes[definition.recipe]=definition
end
-- \brief Returns macerator recipe result
@ -768,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
@ -782,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)
@ -794,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

@ -618,6 +618,32 @@ if industrialtest.mclAvailable then
y_max=mcl_worlds.layer_to_y(16),
y_min=mcl_vars.mg_overworld_min
})
mcl_craftguide.register_craft_type("industrialtest.macerating", {
description = S("Macerating"),
icon = "industrialtest_machine_block.png^industrialtest_macerator_front_active.png"
})
mcl_craftguide.register_craft_type("industrialtest.compressing", {
description = S("Compressing"),
icon = "industrialtest_machine_block.png^industrialtest_compressor_front_active.png"
})
mcl_craftguide.register_craft_type("industrialtest.extracting", {
description = S("Extracting"),
icon = "industrialtest_machine_block.png^industrialtest_extractor_front_active.png"
})
mcl_craftguide.register_craft_type("industrialtest.recycling", {
description = S("Recycling"),
icon = "industrialtest_machine_block.png^industrialtest_recycler_top_active.png"
})
mcl_craftguide.register_craft_type("industrialtest.cable_forming", {
description = S("Cable Forming"),
icon = "industrialtest_machine_block.png^industrialtest_cable_former_front_active.png"
})
mcl_craftguide.register_craft_type("industrialtest.mass_fabricating", {
description = S("Mass Fabricating"),
icon = "industrialtest_machine_block.png^industrialtest_mass_fabricator_front_active.png"
})
elseif industrialtest.mtgAvailable then
industrialtest.internal.registerMetal=function(name,displayName,hardness)
minetest.register_craftitem("industrialtest:"..name.."_lump",{

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

@ -455,7 +455,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 {
@ -471,7 +471,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 {
@ -487,7 +487,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 {
@ -503,7 +503,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 {
@ -511,7 +511,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 {
@ -527,7 +527,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({