From 60af80866142d94e1e1e5e05631b21f2a1e1b443 Mon Sep 17 00:00:00 2001 From: Brevven Date: Mon, 16 Jan 2023 19:03:19 -0800 Subject: [PATCH] crafting efficiency --- changelog.txt | 5 +++++ compatibility/crafting-efficiency.lua | 26 ++++++++++++++++++++++++++ data-updates.lua | 1 + info.json | 2 +- lead-recipe-modules.lua | 16 ++-------------- me.lua | 1 + 6 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 compatibility/crafting-efficiency.lua diff --git a/changelog.txt b/changelog.txt index 42f15b1..cb2afb9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 1.2.17 +Date: 2022-01-17 + Features: + - (Beta) Crafting efficiency compatibility +--------------------------------------------------------------------------------------------------- Version: 1.2.16 Date: 2022-12-24 Localization: diff --git a/compatibility/crafting-efficiency.lua b/compatibility/crafting-efficiency.lua new file mode 100644 index 0000000..282f6e5 --- /dev/null +++ b/compatibility/crafting-efficiency.lua @@ -0,0 +1,26 @@ +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] or data.raw.fluid[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] and data.raw.item[recipe].icon or data.raw.fluid[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 e924f24..c0a3e0e 100644 --- a/data-updates.lua +++ b/data-updates.lua @@ -5,5 +5,6 @@ require("map-gen-preset-updates") require("strange-matter") require("compatibility/248k") require("compatibility/sciencecosttweakerm") +require("compatibility/crafting-efficiency") require("lead-recipe-modules") diff --git a/info.json b/info.json index aeb2ef3..39f479e 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "bzlead", - "version": "1.2.16", + "version": "1.2.17", "factorio_version": "1.1", "title": "Lead", "author": "Brevven", diff --git a/lead-recipe-modules.lua b/lead-recipe-modules.lua index 559bd68..24208bb 100644 --- a/lead-recipe-modules.lua +++ b/lead-recipe-modules.lua @@ -1,19 +1,7 @@ +local util = require("data-util"); -- Enable prod modules for all lead plate and ore recipes -recipes = {"lead-plate"} -if mods["Krastorio2"] then - table.insert(recipes, "enriched-lead-plate") - table.insert(recipes, "enriched-lead") -end -if mods["space-exploration"] then - table.insert(recipes, "lead-smelting-vulcanite") - table.insert(recipes, "molten-lead") - if mods["Krastorio2"] then - table.insert(recipes, "enriched-lead-smelting-vulcanite") - end -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 diff --git a/me.lua b/me.lua index b83122f..6863168 100644 --- a/me.lua +++ b/me.lua @@ -3,6 +3,7 @@ local me = {} me.name = "bzlead" me.lead_ore = "lead-ore" me.lead_plate = "lead-plate" +me.recipes = {me.lead_plate, "enriched-lead-plate", "enriched-lead", "lead-smelting-vulcanite", "molten-lead", "enriched-lead-smelting-vulcanite"} function me.byproduct() return me.get_setting("bzlead-byproduct") and not me.get_setting("bz-no-byproduct")