From fac1717a4355a7075c1ce171840c0a80ea94c456 Mon Sep 17 00:00:00 2001 From: Brevven Date: Mon, 16 Jan 2023 18:05:11 -0800 Subject: [PATCH] crafting efficiency --- changelog.txt | 5 +++++ compatibility/crafting-efficiency.lua | 25 +++++++++++++++++++++++++ data-updates.lua | 1 + info.json | 2 +- me.lua | 8 +++++++- modules.lua | 18 ++---------------- 6 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 compatibility/crafting-efficiency.lua diff --git a/changelog.txt b/changelog.txt index 8c2d5a0..4515b70 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 0.7.7 +Date: 2022-12-17 + Features: + - (Beta) Crafting Efficiency compatibility +--------------------------------------------------------------------------------------------------- Version: 0.7.6 Date: 2022-12-24 Fixes: diff --git a/compatibility/crafting-efficiency.lua b/compatibility/crafting-efficiency.lua new file mode 100644 index 0000000..82ee49f --- /dev/null +++ b/compatibility/crafting-efficiency.lua @@ -0,0 +1,25 @@ +local util = require("data-util"); + +if mods["crafting-efficiency-2"] then + + local eff_data = { + } + + for i, recipe in pairs(util.me.recipes) do + -- add remaining recipes with direct items to find the icons + if data.raw.recipe[recipe] and data.raw.item[recipe] and not eff_data[recipe] and + (data.raw.recipe[recipe].main_product or util.get_result_count(recipe) == 1) then + eff_data[recipe] = { + max = 15, + icon = data.raw.item[recipe].icon, + crafting = { efficiency = 10 }, + research = { level = 6 }, + } + end + end + for recipe, d in pairs(eff_data) do + log("Adding "..recipe.." crafting efficiency") + d.name = recipe:gsub("^%l", string.upper).." efficiency" + CE_Add_Recipe(d, recipe) + end +end diff --git a/data-updates.lua b/data-updates.lua index 63689af..0fb22de 100644 --- a/data-updates.lua +++ b/data-updates.lua @@ -5,6 +5,7 @@ require("map-gen-preset-updates") require("tungsten-recipe-5d") require("strange-matter") require("compatibility/248k") +require("compatibility/crafting-efficiency") local util = require("data-util"); diff --git a/info.json b/info.json index b0489c5..b4e110a 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "bztungsten", - "version": "0.7.6", + "version": "0.7.7", "factorio_version": "1.1", "title": "Tungsten", "author": "Brevven", diff --git a/me.lua b/me.lua index 7672bb1..12eac1e 100644 --- a/me.lua +++ b/me.lua @@ -4,6 +4,13 @@ me.name = "bztungsten" me.tungsten_ore = "tungsten-ore" me.tungsten_plate = "tungsten-plate" me.tungsten_carbide_recipe = "tungsten-carbide" +me.recipes = {me.tungsten_plate, me.tungsten_carbide_recipe, "rocket-engine-nozzle", + "enriched-tungsten-plate", + "enriched-tungsten", + "tungsten-smelting-vulcanite", + "molten-tungsten", + "enriched-tungsten-smelting-vulcanite", + "tungsten-carbide-coal",} me.tungsten_processing = "tungsten-processing" if mods.bobplates then @@ -41,7 +48,6 @@ function me.get_setting(name) end return settings.startup[name].value end - me.bypass = {} if me.get_setting(me.name.."-recipe-bypass") then for recipe in string.gmatch(me.get_setting(me.name.."-recipe-bypass"), '[^",%s]+') do diff --git a/modules.lua b/modules.lua index 5adf686..b67161a 100644 --- a/modules.lua +++ b/modules.lua @@ -1,22 +1,8 @@ -- Enable prod modules for all tungsten plate and ore recipes +local util = require("data-util"); -recipes = {"tungsten-plate", "tungsten-carbide", "rocket-engine-nozzle"} -if mods["Krastorio2"] then - table.insert(recipes, "enriched-tungsten-plate") - table.insert(recipes, "enriched-tungsten") -end -if mods["space-exploration"] then - table.insert(recipes, "tungsten-smelting-vulcanite") - table.insert(recipes, "molten-tungsten") - if mods["Krastorio2"] then - table.insert(recipes, "enriched-tungsten-smelting-vulcanite") - end -end -if data.raw.recipe["tungsten-carbide-coal"] then - table.insert(recipes, "tungsten-carbide-coal") -end -for i, recipe in pairs(recipes) do +for i, recipe in pairs(util.me.recipes) do if data.raw.recipe[recipe] then for j, module in pairs(data.raw.module) do if module.effect then