diff --git a/changelog.txt b/changelog.txt index 0c7d431..4c38c69 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,14 @@ --------------------------------------------------------------------------------------------------- +Version: 1.2.5 +Date: 2022-07-03 + Fixes: + - Compatibility with AutoTrainDepot & EndgameCombat +--------------------------------------------------------------------------------------------------- +Version: 1.2.4 +Date: 2022-07-03 + Fixes: + - Compatibility between all of Titanium/EndgameCombat/Krastorio2 +--------------------------------------------------------------------------------------------------- Version: 1.2.3 Date: 2022-07-03 Fixes: diff --git a/compatibility/titanium-auto-train-depot-final.lua b/compatibility/titanium-auto-train-depot-final.lua new file mode 100644 index 0000000..96689f1 --- /dev/null +++ b/compatibility/titanium-auto-train-depot-final.lua @@ -0,0 +1,5 @@ +local util = require("data-util"); + +if mods.AutoTrainDepot then + util.remove_prerequisite("depot-fluid", "nickel-processing") +end diff --git a/compatibility/titanium-endgame-combat-final.lua b/compatibility/titanium-endgame-combat-final.lua index d03c28a..666886b 100644 --- a/compatibility/titanium-endgame-combat-final.lua +++ b/compatibility/titanium-endgame-combat-final.lua @@ -1,7 +1,8 @@ -- Second part of hack for endgame combat -if mods["EndgameCombat"] and not mods["pyrawores"] and not mods["bobplates"] and not mods["angelssmelting"] then -local util = require("__bztitanium__.data-util"); +if mods.EndgameCombat and not mods["pyrawores"] and not mods["bobplates"] and not mods["angelssmelting"] then + +local util = require("data-util"); local dummy_items = {"cobalt-steel", "nickel", "aluminium"} if not mods.bztungsten then @@ -37,4 +38,13 @@ if not mods.bztungsten then util.remove_ingredient("lightning-turret", "tungsten") util.remove_prerequisite("lightning-turrets", "tungsten-processing") end + +if mods.Krastorio2 then + -- remove K2 recipes that are created when our dummy items are detected + util.remove_raw("recipe", "kr-vc-cobalt-steel") + util.remove_raw("recipe", "kr-vc-nickel") + util.remove_raw("recipe", "kr-vc-aluminium") end +end + + diff --git a/data-final-fixes.lua b/data-final-fixes.lua index 8000929..95982af 100644 --- a/data-final-fixes.lua +++ b/data-final-fixes.lua @@ -30,3 +30,5 @@ require("titanium-data-final-settings") -- Second part of hack for endgame combat require("compatibility/titanium-endgame-combat-final") +-- Hack for AutoTrainDepot +require("compatibility/titanium-auto-train-depot-final") diff --git a/data-util.lua b/data-util.lua index 0994028..37f09b8 100644 --- a/data-util.lua +++ b/data-util.lua @@ -183,7 +183,6 @@ function add_ingredient(recipe, ingredient, quantity, is_fluid) if recipe ~= nil and recipe.ingredients ~= nil then for i, existing in pairs(recipe.ingredients) do if existing[1] == ingredient or existing.name == ingredient then - log("Not adding "..ingredient.." -- duplicate") return end end @@ -271,27 +270,32 @@ function add_product(recipe, product) end -- Replace one ingredient with another in a recipe -function util.replace_ingredient(recipe_name, old, new) +function util.replace_ingredient(recipe_name, old, new, amount) if me.bypass[recipe_name] then return end if data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) then me.add_modified(recipe_name) - replace_ingredient(data.raw.recipe[recipe_name], old, new) - replace_ingredient(data.raw.recipe[recipe_name].normal, old, new) - replace_ingredient(data.raw.recipe[recipe_name].expensive, old, new) + replace_ingredient(data.raw.recipe[recipe_name], old, new, amount) + replace_ingredient(data.raw.recipe[recipe_name].normal, old, new, amount) + replace_ingredient(data.raw.recipe[recipe_name].expensive, old, new, amount) end end -function replace_ingredient(recipe, old, new) +function replace_ingredient(recipe, old, new, amount) if recipe ~= nil and recipe.ingredients ~= nil then for i, existing in pairs(recipe.ingredients) do if existing[1] == new or existing.name == new then - log("Not adding "..new.." -- duplicate") return end end for i, ingredient in pairs(recipe.ingredients) do - if ingredient.name == old then ingredient.name = new end - if ingredient[1] == old then ingredient[1] = new end + if ingredient.name == old then + ingredient.name = new + if amount then ingredient.amount = amount end + end + if ingredient[1] == old then + ingredient[1] = new + if amount then ingredient[2] = amount end + end end end end @@ -338,7 +342,6 @@ function replace_some_ingredient(recipe, old, old_amount, new, new_amount, is_fl if recipe ~= nil and recipe.ingredients ~= nil then for i, existing in pairs(recipe.ingredients) do if existing[1] == new or existing.name == new then - log("Not adding "..new.." -- duplicate") return end end @@ -551,7 +554,7 @@ end -- Set recipe category function util.set_category(recipe_name, category) if me.bypass[recipe_name] then return end - if data.raw.recipe[recipe_name] then + if data.raw.recipe[recipe_name] and data.raw["recipe-category"][category] then me.add_modified(recipe_name) data.raw.recipe[recipe_name].category = category end @@ -601,10 +604,9 @@ end -- Add crafting category to an entity function util.add_crafting_category(entity_type, entity, category) - if data.raw[entity_type][entity] then + if data.raw[entity_type][entity] and data.raw["recipe-category"][category] then for i, existing in pairs(data.raw[entity_type][entity].crafting_categories) do if existing == category then - log(entity.." not adding "..category.." -- duplicate") return end end diff --git a/info.json b/info.json index 5117e97..b7d0f7f 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "bztitanium", - "version": "1.2.3", + "version": "1.2.5", "factorio_version": "1.1", "title": "Titanium", "author": "Brevven",