diff --git a/changelog.txt b/changelog.txt index 3e5de9f..35abcb2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 0.9.4 +Date: 2020-12-29 + Changes: + - Base "naive" compatibility with Pyanodon's Raw Ores (pyrawores) - we just use their plates an remove our ore/plates. +--------------------------------------------------------------------------------------------------- Version: 0.9.3 Date: 2020-12-22 Changes: diff --git a/data-util.lua b/data-util.lua index 4de89f7..312f33c 100644 --- a/data-util.lua +++ b/data-util.lua @@ -1,6 +1,7 @@ local data_util = {} data_util.titanium_plate = "" +data_util.titanium_processing = "" if mods["FactorioExtended-Plus-Core"] then data_util.titanium_plate = "titanium-alloy" @@ -8,6 +9,13 @@ else data_util.titanium_plate = "titanium-plate" end +if mods["pyrawores"] then + data_util.titanium_processing = "titanium-mk01" +else + data_util.titanium_processing = "titanium-processing" +end + + -- Remove an element of type t and name from data.raw function data_util.remove_raw(t, name) for i, elem in pairs(data.raw[t]) do @@ -18,17 +26,34 @@ function data_util.remove_raw(t, name) end end +function data_util.check_for_ingredient(recipe, name) + if recipe ~= nil and recipe.ingredients ~= nil then + log(serpent.dump(recipe)) + for i, ingredient in pairs(recipe.ingredients) do + if ingredient.name == name then + return true + end + end + end + return false +end --- Add a given quantity of titanium plates to a given recipe function data_util.add_titanium_ingredient(quantity, recipe) if recipe ~= nil and recipe.ingredients ~= nil then + if data_util.check_for_ingredient(recipe, data_util.titanium_plate) then + return + end table.insert(recipe.ingredients, {data_util.titanium_plate, quantity}) end end --- Add titanium processing as a prerequisite to a given technology function data_util.add_titanium_prerequisite(technology) - table.insert(technology.prerequisites, "titanium-processing") + if mods["pyrawores"] then + return + end + table.insert(technology.prerequisites, data_util.titanium_processing) end --- Change all occurances of steel plates to titanium plates in a given recipe @@ -43,6 +68,9 @@ end function data_util.replace_ingredient(recipe, old, new) if recipe ~= nil and recipe.ingredients ~= nil then + if data_util.check_for_ingredient(recipe, new) then + return + end for i, ingredient in pairs(recipe.ingredients) do -- For final fixes if ingredient.name == old then ingredient.name = new end diff --git a/info.json b/info.json index 7f3a508..cb224f8 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "bztitanium", - "version": "0.9.3", + "version": "0.9.4", "factorio_version": "1.1", "title": "Titanium", "author": "Brevven", diff --git a/titanium-data-final-settings.lua b/titanium-data-final-settings.lua index d6a4e1e..f8a6dcf 100644 --- a/titanium-data-final-settings.lua +++ b/titanium-data-final-settings.lua @@ -1,21 +1,23 @@ -- Settings, etc. -- -- Finalize tech tree based on settings and other dependent mods. +local util = require("__bztitanium__.data-util"); + local mining_fluid if settings.startup["bztitanium-mining-fluid"] then mining_fluid = settings.startup["bztitanium-mining-fluid"].value end if mining_fluid == "chlorine" and data.raw.fluid["chlorine"] and mods["Krastorio2"] then - data.raw.technology["titanium-processing"].prerequisites = {"kr-fluids-chemistry"} - data.raw.technology["titanium-processing"].unit.ingredients = { + data.raw.technology[util.titanium_processing].prerequisites = {"kr-fluids-chemistry"} + data.raw.technology[util.titanium_processing].unit.ingredients = { {"basic-tech-card", 1}, {"automation-science-pack", 1}, {"logistic-science-pack", 1}} elseif mining_fluid == "sulfuric-acid" then - data.raw.technology["titanium-processing"].prerequisites = {"sulfur-processing"} - data.raw.technology["titanium-processing"].unit.ingredients = { + data.raw.technology[util.titanium_processing].prerequisites = {"sulfur-processing"} + data.raw.technology[util.titanium_processing].unit.ingredients = { {"automation-science-pack", 1}, {"logistic-science-pack", 1}} else - data.raw.technology["titanium-processing"].prerequisites = {"lubricant"} + data.raw.technology[util.titanium_processing].prerequisites = {"lubricant"} if not mods["Pre0-17-60Oil"] then data.raw.technology["solar-panel-equipment"].unit.ingredients = { {"automation-science-pack", 1}, {"logistic-science-pack", 1}, {"chemical-science-pack", 1}} diff --git a/titanium-enriched.lua b/titanium-enriched.lua index 7fead1d..9a2d767 100644 --- a/titanium-enriched.lua +++ b/titanium-enriched.lua @@ -1,4 +1,6 @@ -- Enriched Titanium for Krastorio2 +local util = require("__bztitanium__.data-util"); + if mods["Krastorio2"] then data:extend( { @@ -103,7 +105,7 @@ data:extend( recipe = "dirty-water-filtration-titanium", } }, - prerequisites = {"kr-enriched-ores", "titanium-processing"}, + prerequisites = {"kr-enriched-ores", util.titanium_processing}, unit = { count = 150, diff --git a/titanium-recipe-final-5d.lua b/titanium-recipe-final-5d.lua index 50cccdb..7a8baf1 100644 --- a/titanium-recipe-final-5d.lua +++ b/titanium-recipe-final-5d.lua @@ -23,7 +23,7 @@ if mods["5dim_core"] then result_count = 100, } }) - table.insert(data.raw.technology["titanium-processing"].effects, + table.insert(data.raw.technology[util.titanium_processing].effects, {type = "unlock-recipe", recipe="titanium-plate-industrial-ore"}) @@ -83,11 +83,11 @@ if mods["5dim_core"] then result_count = 100, } }) - table.insert(data.raw.technology["titanium-processing"].effects, + table.insert(data.raw.technology[util.titanium_processing].effects, {type = "unlock-recipe", recipe="titanium-dust"}) - table.insert(data.raw.technology["titanium-processing"].effects, + table.insert(data.raw.technology[util.titanium_processing].effects, {type = "unlock-recipe", recipe="titanium-plate-dust"}) - table.insert(data.raw.technology["titanium-processing"].effects, + table.insert(data.raw.technology[util.titanium_processing].effects, {type = "unlock-recipe", recipe="titanium-plate-industrial-dust"}) if mods["5dim_automation"] then diff --git a/titanium-recipe-updates.lua b/titanium-recipe-updates.lua index 11e6200..d9b75ee 100644 --- a/titanium-recipe-updates.lua +++ b/titanium-recipe-updates.lua @@ -16,9 +16,11 @@ end util.add_titanium_prerequisite(data.raw.technology["solar-panel-equipment"]) --- Also add titanium to steam turbines +-- Also add titanium to some nuclear steam-handling stuff util.add_titanium_ingredient(20, data.raw.recipe["steam-turbine"]) -util.add_titanium_ingredient(20, data.raw.recipe["heat-exchanger"]) +if mods["pyrawores"] then + util.add_titanium_ingredient(20, data.raw.recipe["heat-exchanger"]) +end util.add_titanium_prerequisite(data.raw.technology["nuclear-power"]) -- Krastorio 2 changes diff --git a/titanium-recipe.lua b/titanium-recipe.lua index 9aee04a..c7fcac0 100644 --- a/titanium-recipe.lua +++ b/titanium-recipe.lua @@ -14,6 +14,7 @@ if mods["modmashsplinterresources"] then util.remove_raw("recipe", "titanium-extraction-process") end +if not mods["pyrawores"] then data:extend( { { @@ -88,3 +89,5 @@ data:extend( }, } ) +end +