Add cable former machine

This commit is contained in:
mrkubax10 2023-11-19 19:59:33 +01:00
parent 286f95596f
commit fb51d07f70
6 changed files with 92 additions and 2 deletions

15
api.lua
View File

@ -20,6 +20,7 @@ industrialtest.api={}
industrialtest.api.maceratorRecipes={}
industrialtest.api.compressorRecipes={}
industrialtest.api.extractorRecipes={}
industrialtest.api.cableFormerRecipes={}
industrialtest.api.geothermalGeneratorFuels={}
industrialtest.api.waterMillFuels={}
industrialtest.api.storageCells={}
@ -676,6 +677,20 @@ end
industrialtest.api.getExtractorRecipeResult=function(recipe)
return industrialtest.api.extractorRecipes[recipe]
end
industrialtest.api.registerCableFormerRecipe=function(config)
local definition={
output=config.output or "",
recipe=config.recipe or "",
time=config.time or 2
}
industrialtest.api.cableFormerRecipes[definition.recipe]=definition
end
industrialtest.api.getCableFormerRecipeResult=function(recipe)
return industrialtest.api.cableFormerRecipes[recipe]
end
-- \brief Registers fuel that can be used in geothermal generator
-- \param fuel Table with following keys: <name>, <calorificValue>, <storageItems>
-- which is a table containing items which are tables with following keys: <name>, <leftover>

View File

@ -171,6 +171,11 @@ minetest.register_craft({
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
}
})
industrialtest.api.registerCableFormerRecipe({
output="industrialtest:tin_cable 12",
recipe=industrialtest.elementKeys.tinIngot,
time=1
})
registerCable("copper","Copper",0.15,industrialtest.api.mvPowerFlow,true)
minetest.register_craft({
@ -197,6 +202,10 @@ minetest.register_craft({
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
}
})
industrialtest.api.registerCableFormerRecipe({
output="industrialtest:copper_cable 12",
recipe=industrialtest.elementKeys.copperIngot
})
registerCable("gold","Gold",0.15,industrialtest.api.hvPowerFlow,true)
minetest.register_craft({
@ -223,6 +232,10 @@ minetest.register_craft({
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
}
})
industrialtest.api.registerCableFormerRecipe({
output="industrialtest:gold_cable 12",
recipe=industrialtest.elementKeys.goldIngot
})
registerCable("iron","Iron",0.15,industrialtest.api.evPowerFlow,true)
minetest.register_craft({
@ -249,6 +262,11 @@ minetest.register_craft({
{"industrialtest:rubber","industrialtest:rubber","industrialtest:rubber"}
}
})
industrialtest.api.registerCableFormerRecipe({
output="industrialtest:iron_cable 12",
recipe="industrialtest:refined_iron_ingot",
time=3
})
registerCable("glass_fibre","Glass Fibre",0.15,industrialtest.api.ivPowerFlow,false)
minetest.register_craft({

View File

@ -16,7 +16,7 @@
local S=minetest.get_translator("industrialtest")
local requiredMtgModules={"default","bucket"}
local requiredMtgModules={"default","bucket","tnt","stairs"}
industrialtest.mtgAvailable=true
for _,mod in ipairs(requiredMtgModules) do
if not minetest.get_modpath(mod) then
@ -24,7 +24,7 @@ for _,mod in ipairs(requiredMtgModules) do
break
end
end
local requiredMclModules={"mcl_core","mcl_copper","mcl_armor","mcl_deepslate","mcl_nether","mcl_buckets"}
local requiredMclModules={"mcl_core","mcl_copper","mcl_armor","mcl_deepslate","mcl_nether","mcl_buckets","mcl_explosions","mcl_stairs"}
industrialtest.mclAvailable=true
for _,mod in ipairs(requiredMclModules) do
if not minetest.get_modpath(mod) then
@ -517,6 +517,7 @@ if industrialtest.mclAvailable then
industrialtest.elementKeys.powerCarrier="mesecons:mesecon"
industrialtest.elementKeys.furnace="mcl_furnaces:furnace"
industrialtest.elementKeys.stone="mcl_core:stone"
industrialtest.elementKeys.stoneSlab="mcl_stairs:slab_stone"
industrialtest.elementKeys.cobble="mcl_core:cobble"
industrialtest.elementKeys.sand="mcl_core:sand"
industrialtest.elementKeys.gravel="mcl_core:gravel"
@ -732,6 +733,7 @@ elseif industrialtest.mtgAvailable then
industrialtest.elementKeys.powerCarrier="default:mese_crystal_fragment"
industrialtest.elementKeys.furnace="default:furnace"
industrialtest.elementKeys.stone="default:stone"
industrialtest.elementKeys.stoneSlab="stairs:slab_stone"
industrialtest.elementKeys.cobble="default:cobble"
industrialtest.elementKeys.sand="default:sand"
industrialtest.elementKeys.gravel="default:gravel"

View File

@ -34,6 +34,7 @@ dofile(modpath.."/minerals.lua")
dofile(modpath.."/machines/common.lua")
dofile(modpath.."/machines/compressor.lua")
dofile(modpath.."/machines/cable_former.lua")
dofile(modpath.."/machines/electric_furnace.lua")
dofile(modpath.."/machines/extractor.lua")
dofile(modpath.."/machines/fluid_generator.lua")

38
machines/cable_former.lua Normal file
View File

@ -0,0 +1,38 @@
-- IndustrialTest
-- Copyright (C) 2023 mrkubax10
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
industrialtest.internal.registerSimpleElectricItemProcessor({
name="cable_former",
displayName=S("Cable Former"),
customFrontTexture=true,
requiresWrench=true,
capacity=1400,
flow=industrialtest.api.lvPowerFlow,
opPower=80,
method="industrialtest.cable_forming",
efficiency=1
})
minetest.register_craft({
type="shaped",
output="industrialtest:cable_former",
recipe={
{"","industrialtest:electronic_circuit",""},
{industrialtest.elementKeys.stoneSlab,industrialtest.elementKeys.stoneSlab,industrialtest.elementKeys.stoneSlab},
{"","industrialtest:machine_block",""}
}
})

View File

@ -377,6 +377,22 @@ local function craftResultProxy(method,item)
time=2,
src=srcAfter
}
elseif method=="industrialtest.cable_forming" then
local output=industrialtest.api.getCableFormerRecipeResult(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