From 30de78fd3ef71d66eb9d64842d75430de57228a4 Mon Sep 17 00:00:00 2001 From: Brevven Date: Tue, 27 Jul 2021 22:51:52 -0700 Subject: [PATCH] refactor, move to updates --- Makefile | 2 +- changelog.txt | 1 + data-util.lua | 54 +++++++++++++++++++++++++- titanium-recipe-final-se.lua | 19 +-------- titanium-recipe-final.lua | 48 ----------------------- titanium-recipe-updates.lua | 74 ++++++++++++++++++++++++++++++++++++ 6 files changed, 130 insertions(+), 68 deletions(-) diff --git a/Makefile b/Makefile index 183a338..11be59f 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ copy: link mkdir -p ../$(v) cp -rf * ../$(v) rm -f ../$(v).zip - cd ..; zip -9 -r -y $(v).zip $(v) -x "*.xcf" -x "*.git*" -x "*.bak" + cd ..; zip -9 -r -y $(v).zip $(v) -x "*.xcf" -x "*.git*" -x "*.bak" -x "*.blend*" install: lint-changelog copy cp -f ../$(v).zip ../../mods/ diff --git a/changelog.txt b/changelog.txt index d302713..6d0c338 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Version: 0.12.4 Date: 2021-07-26 Changes: + - SE: Experimental alloys data recipe - Minor refactor --------------------------------------------------------------------------------------------------- Version: 0.12.3 diff --git a/data-util.lua b/data-util.lua index 36b8f84..60edbfb 100644 --- a/data-util.lua +++ b/data-util.lua @@ -1,4 +1,6 @@ --- WARNING - this file will be overwritten, edit bzlib/data-util.lua +-- WARNING WARNING WARNING +-- This file will be overwritten in mod zipfiles, edit bzlib/data-util.lua +-- WARNING WARNING WARNING local me = require("me") local util = {} @@ -351,4 +353,54 @@ function util.add_crafting_category(entity_type, entity, category) end end +function util.add_to_ingredient(recipe, ingredient, amount) + if data.raw.recipe[recipe] then + add_to_ingredient(data.raw.recipe[recipe], ingredient, amount) + add_to_ingredient(data.raw.recipe[recipe].normal, ingredient, amount) + add_to_ingredient(data.raw.recipe[recipe].expensive, ingredient, amount) + end +end + +function add_to_ingredient(recipe, it, amount) + if recipe ~= nil and recipe.ingredients ~= nil then + for i, ingredient in pairs(recipe.ingredients) do + if ingredient.name == it then + ingredient.amount = ingredient.amount + amount + return + end + if ingredient[1] == it then + ingredient[2] = ingredients[2] + amount + return + end + end + end +end + +function util.add_to_product(recipe, product, amount) + if data.raw.recipe[recipe] then + add_to_product(data.raw.recipe[recipe], product, amount) + add_to_product(data.raw.recipe[recipe].normal, product, amount) + add_to_product(data.raw.recipe[recipe].expensive, product, amount) + end +end + +function add_to_product(recipe, product, amount) + if recipe ~= nil and recipe.results ~= nil then + if recipe.result == product then + recipe.result_count = recipe.result_count + amount + return + end + for i, result in pairs(recipe.results) do + if result.name == product then + result.amount = result.amount + amount + return + end + if result[1] == product then + result[2] = result[2] + amount + return + end + end + end +end + return util diff --git a/titanium-recipe-final-se.lua b/titanium-recipe-final-se.lua index 09214c6..facd0ee 100644 --- a/titanium-recipe-final-se.lua +++ b/titanium-recipe-final-se.lua @@ -1,25 +1,8 @@ -- Additions for Space Exploration mod. local util = require("__bztitanium__.data-util"); + if data.raw.recipe["se-space-pipe"] then - -- Space Exploration space stuff - util.me.steel_to_titanium("se-space-pipe") - util.me.steel_to_titanium("se-space-transport-belt") - util.me.steel_to_titanium("se-space-underground-belt") - util.me.steel_to_titanium("se-space-splitter") - util.me.steel_to_titanium("se-space-rail") - util.me.add_titanium_ingredient(1, "se-space-platform-scaffold") - - -- Space Exploration alternative LDS - util.me.steel_to_titanium("se-low-density-structure-beryllium") - - -- Space Exploration buildings - util.me.add_titanium_ingredient(20, "se-condenser-turbine") - - -- A couple more deeper tech thematic items to use titanium in. - util.me.add_titanium_ingredient(2, "se-lattice-pressure-vessel") - util.me.add_titanium_ingredient(2, "se-aeroframe-bulkhead") - -- Organization data.raw.item["titanium-plate"].subgroup = "plates" diff --git a/titanium-recipe-final.lua b/titanium-recipe-final.lua index 1d0cdf1..7b69c11 100644 --- a/titanium-recipe-final.lua +++ b/titanium-recipe-final.lua @@ -1,50 +1,2 @@ --- Titanium recipe & tech changes --- These are in "final" for compatibility with other mods such as Space Exploration, AAI and Krastorio 2 - local util = require("__bztitanium__.data-util"); -util.me.steel_to_titanium("low-density-structure") -if mods["modmashsplintergold"] then - util.me.steel_to_titanium("low-density-structure-with-gold") -end - -if not mods["bobrevamp"] then - util.me.add_titanium_prerequisite("low-density-structure") -end - -if (not mods["bobplates"]) then - util.me.steel_to_titanium("flying-robot-frame") - util.me.add_titanium_prerequisite("robotics") -end - -if (mods["bobrevamp"] and not mods["bobplates"] and not mods["angelssmelting"]) then - util.me.steel_to_titanium("flying-robot-frame-2") - util.me.steel_to_titanium("flying-robot-frame-3") - util.me.steel_to_titanium("flying-robot-frame-4") -end - - - --- Memory storage changes -if data.raw.item["memory-unit"] then - util.me.steel_to_titanium("memory-unit") -end - --- Underwater pipes changes -if data.raw.item["underwater-pipe"] then - if data.raw.technology["underwater-pipes"] then - local index = -1 - for i, elem in pairs(data.raw.technology["underwater-pipes"].prerequisites) do - if elem == "steel-processing" then - index = i - end - end - if index > -1 then - table.remove(data.raw.technology["underwater-pipes"].prerequisites, index) - end - end - util.me.add_titanium_prerequisite("underwater-pipes") - - util.me.steel_to_titanium("underwater-pipe") -end - diff --git a/titanium-recipe-updates.lua b/titanium-recipe-updates.lua index d9dc478..59f9efc 100644 --- a/titanium-recipe-updates.lua +++ b/titanium-recipe-updates.lua @@ -19,6 +19,56 @@ if (not mods["bobplates"]) then end end +util.me.steel_to_titanium("low-density-structure") +if mods["modmashsplintergold"] then + util.me.steel_to_titanium("low-density-structure-with-gold") +end + +if not mods["bobrevamp"] then + util.me.add_titanium_prerequisite("low-density-structure") +end + + +if (not mods["bobplates"]) then + util.me.steel_to_titanium("flying-robot-frame") + util.me.add_titanium_prerequisite("robotics") +end + +if (mods["bobrevamp"] and not mods["bobplates"] and not mods["angelssmelting"]) then + util.me.steel_to_titanium("flying-robot-frame-2") + util.me.steel_to_titanium("flying-robot-frame-3") + util.me.steel_to_titanium("flying-robot-frame-4") +end + + + + +if data.raw.recipe["se-space-pipe"] then + -- Space Exploration space stuff + util.me.steel_to_titanium("se-space-pipe") + util.me.steel_to_titanium("se-space-transport-belt") + util.me.steel_to_titanium("se-space-underground-belt") + util.me.steel_to_titanium("se-space-splitter") + util.me.steel_to_titanium("se-space-rail") + util.me.add_titanium_ingredient(1, "se-space-platform-scaffold") + + -- Space Exploration alternative LDS + util.me.steel_to_titanium("se-low-density-structure-beryllium") + + -- Space Exploration buildings + util.me.add_titanium_ingredient(20, "se-condenser-turbine") + + -- A couple more deeper tech thematic items to use titanium in. + util.me.add_titanium_ingredient(2, "se-lattice-pressure-vessel") + util.me.add_titanium_ingredient(2, "se-aeroframe-bulkhead") + + util.add_ingredient("se-experimental-alloys-data", "titanium-plate", 1) + util.add_to_product("se-experimental-alloys-data", "se-experimental-alloys-data", 1) + util.add_to_product("se-experimental-alloys-data", "se-scrap", 1) + util.add_to_ingredient("se-experimental-alloys-data", "se-empty-data", 1) + +end + -- Also add titanium to some nuclear steam-handling stuff util.me.add_titanium_ingredient(20, "steam-turbine") @@ -52,3 +102,27 @@ end -- Useful Equipment util.replace_ingredient("craft-assistent", "iron-plate", "titanium-plate") util.replace_ingredient("artificial-organ", "iron-plate", "titanium-plate") + +-- Memory storage changes +if data.raw.item["memory-unit"] then + util.me.steel_to_titanium("memory-unit") +end + +-- Underwater pipes changes +if data.raw.item["underwater-pipe"] then + if data.raw.technology["underwater-pipes"] then + local index = -1 + for i, elem in pairs(data.raw.technology["underwater-pipes"].prerequisites) do + if elem == "steel-processing" then + index = i + end + end + if index > -1 then + table.remove(data.raw.technology["underwater-pipes"].prerequisites, index) + end + end + util.me.add_titanium_prerequisite("underwater-pipes") + + util.me.steel_to_titanium("underwater-pipe") +end +