From 3419fcb6601c7b2c687b5a71b3427c7acd5683e7 Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Wed, 11 Sep 2024 15:29:03 +0200 Subject: [PATCH] Introduce tag system for further usage --- api/common.lua | 20 +++++++++++--------- api/registration.lua | 7 +++++++ compat/pipeworks.lua | 2 +- machines/common.lua | 4 +--- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/api/common.lua b/api/common.lua index 1483684..fb70081 100644 --- a/api/common.lua +++ b/api/common.lua @@ -14,15 +14,17 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -industrialtest.api={} -industrialtest.api.maceratorRecipes={} -industrialtest.api.compressorRecipes={} -industrialtest.api.extractorRecipes={} -industrialtest.api.cableFormerRecipes={} -industrialtest.api.geothermalGeneratorFuels={} -industrialtest.api.waterMillFuels={} -industrialtest.api.rotaryMaceratorModifiers={} -industrialtest.api.storageCells={} +industrialtest.api={ + maceratorRecipes={}, + compressorRecipes={}, + extractorRecipes={}, + cableFormerRecipes={}, + geothermalGeneratorFuels={}, + waterMillFuels={}, + rotaryMaceratorModifiers={}, + storageCells={}, + tags={} +} industrialtest.api.lvPowerFlow=600 industrialtest.api.mvPowerFlow=2400 diff --git a/api/registration.lua b/api/registration.lua index d702e7d..94e6aae 100644 --- a/api/registration.lua +++ b/api/registration.lua @@ -16,6 +16,13 @@ local S=minetest.get_translator("industrialtest") +function industrialtest.api.addTag(name,tag) + if not industrialtest.api.tags[tag] then + industrialtest.api.tags[tag]={} + end + table.insert(industrialtest.api.tags[tag],name) +end + -- \brief Registers dust of certain resource -- \param name Technical name of resource -- \param displayName Display name of resource diff --git a/compat/pipeworks.lua b/compat/pipeworks.lua index 51ca2cb..e10150e 100644 --- a/compat/pipeworks.lua +++ b/compat/pipeworks.lua @@ -344,7 +344,7 @@ addPipeworksCompatibility("industrialtest:induction_furnace",{ },"dst") -- Simple electric item processors -for _,name in ipairs(industrialtest.internal.simpleElectricItemProcessors) do +for _,name in ipairs(industrialtest.api.tags.simpleElectricItemProcessor) do addPipeworksCompatibility(name,{ { y=1, diff --git a/machines/common.lua b/machines/common.lua index f5de182..e3b8114 100644 --- a/machines/common.lua +++ b/machines/common.lua @@ -17,8 +17,6 @@ local machine={} local simpleElectricItemProcessor={} -industrialtest.internal.simpleElectricItemProcessors={} - industrialtest.internal.mclAfterDigNode=function(pos,oldmeta,lists) -- Taken from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_furnaces/init.lua#L538 local meta=minetest.get_meta(pos) @@ -783,5 +781,5 @@ function industrialtest.internal.registerSimpleElectricItemProcessor(config) return simpleElectricItemProcessor.activeOnTimer(pos,elapsed,meta,inv,config) end }) - table.insert(industrialtest.internal.simpleElectricItemProcessors,"industrialtest:"..config.name) + industrialtest.api.addTag("industrialtest:"..config.name,"simpleElectricItemProcessor") end