From fb51d07f706e72f5986ec9009f21999b14023675 Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Sun, 19 Nov 2023 19:59:33 +0100 Subject: [PATCH] Add cable former machine --- api.lua | 15 +++++++++++++++ cables.lua | 18 ++++++++++++++++++ compatibility.lua | 6 ++++-- init.lua | 1 + machines/cable_former.lua | 38 ++++++++++++++++++++++++++++++++++++++ machines/common.lua | 16 ++++++++++++++++ 6 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 machines/cable_former.lua diff --git a/api.lua b/api.lua index 74d2406..d4f17e9 100644 --- a/api.lua +++ b/api.lua @@ -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: , , -- which is a table containing items which are tables with following keys: , diff --git a/cables.lua b/cables.lua index bf864be..aa73a49 100644 --- a/cables.lua +++ b/cables.lua @@ -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({ diff --git a/compatibility.lua b/compatibility.lua index 7aa154e..6ec3c06 100644 --- a/compatibility.lua +++ b/compatibility.lua @@ -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" diff --git a/init.lua b/init.lua index 909c644..9b2e682 100644 --- a/init.lua +++ b/init.lua @@ -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") diff --git a/machines/cable_former.lua b/machines/cable_former.lua new file mode 100644 index 0000000..0d88718 --- /dev/null +++ b/machines/cable_former.lua @@ -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 . + +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",""} + } +}) diff --git a/machines/common.lua b/machines/common.lua index 0cc2f59..99f345b 100644 --- a/machines/common.lua +++ b/machines/common.lua @@ -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