From 379e0c976a1b5aa23aca229f8d41f0052653b51f Mon Sep 17 00:00:00 2001 From: Peter Date: Sun, 20 Jan 2019 11:03:50 +0800 Subject: [PATCH] fixed some tech tree bugs with some overhaul mods --- 017_science/control.lua | 42 ++++++++-- 017_science/data-final-fixes.lua | 93 +++++++++++++++++++++ 017_science/data-updates.lua | 133 ++++++------------------------- 017_science/data.lua | 6 +- 017_science/info.json | 2 +- 017_science/technology.lua | 102 +++++++++++++----------- 6 files changed, 216 insertions(+), 162 deletions(-) create mode 100644 017_science/data-final-fixes.lua diff --git a/017_science/control.lua b/017_science/control.lua index a1d8e74..248c5f1 100644 --- a/017_science/control.lua +++ b/017_science/control.lua @@ -158,7 +158,7 @@ end if settings.startup["017-rocket-victory"].value then script.on_event(defines.events.on_rocket_launched, function(event) - if game.active_mods["SpaceMod"] then + if game.active_game.active_mods["SpaceMod"] then -- game.print("SpaceMod installed: not enabling victory") else game.set_game_state{game_finished = true, player_won = true, can_continue = true} @@ -237,7 +237,9 @@ script.on_configuration_changed(function() f_recipes["17-low-density-structure"].enabled = true f_recipes["17-utility-science-pack"].enabled = true if old_science then - f_recipes["low-density-structure"].enabled = true + if not game.active_mods["bobrevamp"] then + f_recipes["low-density-structure"].enabled = true + end f_recipes["high-tech-science-pack"].enabled = true end f_print("advanced-electronics-2 researched for this force: utility-science-pack & low-density-structure & rocket-control-unit recipes auto-unlocked") @@ -246,7 +248,9 @@ script.on_configuration_changed(function() end if f_technologies["advanced-material-processing-2"].researched == true then - f_recipes["rocket-fuel"].enabled = true + if not game.active_mods["angelspetrochem"] then + f_recipes["rocket-fuel"].enabled = true + end f_recipes["17-production-science-pack"].enabled = true if old_science then f_recipes["production-science-pack"].enabled = true @@ -363,7 +367,7 @@ script.on_configuration_changed(function() end end - if not f_technologies["rocket-fuel"].researched == true then + if not f_technologies["rocket-fuel"].researched == true and not game.active_mods["angelspetrochem"] then if get_input_count("rocket-fuel") > 0 then f_recipes["rocket-fuel"].enabled = true f_technologies["rocket-fuel"].researched = true @@ -372,10 +376,24 @@ script.on_configuration_changed(function() f_recipes["rocket-fuel"].enabled = false f_technologies["rocket-fuel"].researched = false f_print("No rocket-fuel produced by this force: technology won't be auto-researched.") - end - end + end + elseif game.active_mods["angelspetrochem"] then + if get_input_count("rocket-fuel") > 0 then + f_technologies["angels-rocket-fuel"].researched = true + f_recipes["rocket-oxidizer-capsule"].enabled = true + f_recipes["rocket-fuel-capsule"].enabled = true + f_recipes["rocket-fuel"].enabled = true + f_print("force: " .. force.name .. " | rocket-fuel recipe unlocked | total produced by force: " .. get_input_count("rocket-fuel")) + else + f_technologies["angels-rocket-fuel"].researched = false + f_recipes["rocket-oxidizer-capsule"].enabled = false + f_recipes["rocket-fuel-capsule"].enabled = false + f_recipes["rocket-fuel"].enabled = false + f_print("No rocket-fuel produced by this force: technology won't be auto-researched.") + end + end - if not f_technologies["low-density-structure"].researched == true then + if not f_technologies["low-density-structure"].researched == true and not game.active_mods["bobrevamp"] then if get_input_count("low-density-structure") > 0 then f_recipes["low-density-structure"].enabled = true f_recipes["17-low-density-structure"].enabled = true @@ -387,6 +405,16 @@ script.on_configuration_changed(function() f_technologies["low-density-structure"].researched = false f_print("No low-density-structure produced by this force: technology won't be auto-researched.") end + elseif game.active_mods["bobrevamp"] then + if get_input_count("low-density-structure") > 0 then + f_recipes["low-density-structure"].enabled = true + f_technologies["low-density-structure"].researched = true + f_print("force: " .. force.name .. " | low-density-structure recipe unlocked | total produced by force: " .. get_input_count("low-density-structure")) + else + f_recipes["low-density-structure"].enabled = false + f_technologies["low-density-structure"].researched = false + f_print("No low-density-structure produced by this force: technology won't be auto-researched.") + end end if not f_technologies["rocket-control-unit"].researched == true then diff --git a/017_science/data-final-fixes.lua b/017_science/data-final-fixes.lua new file mode 100644 index 0000000..69327e2 --- /dev/null +++ b/017_science/data-final-fixes.lua @@ -0,0 +1,93 @@ +local function compare(technology, science_pack, pre_tier) + valid = true + if technology and technology.unit then + for l, j in pairs(technology.unit.ingredients) do + if j[1] == pre_tier then + valid = true + break + else + valid = false + end + end + end + if valid == true then + if technology.prerequisites then + for _=1, #technology.prerequisites do + local tech = data.raw["technology"][technology.prerequisites[_]] + if valid == true then + if tech then + if tech.unit then + for i, ingredients in pairs(tech.unit.ingredients) do + if ingredients[1] == pre_tier then + valid = false + break + else + valid = true + end + end + elseif valid == false then + break + end + elseif valid == false then + break + end + end + end + end + end + if technology.prerequisites and valid == true then + technology.prerequisites[#technology.prerequisites+1] = science_pack + return true + else + return false + end +end + +for _, tech in pairs(data.raw["technology"]) do + if tech.name ~= ("logistics-science-pack" or "chemical-science-pack" or "production-science-pack" or "utility-science-pack" or "space-science-pack") then + if tech.effects then + if #tech.effects ~= 0 then + for i, effect in pairs(tech.effects) do + if effect then + if effect.type then + if effect.type == "unlock-recipe" then + whitelisted = true + break + else + whitelisted = false + end + end + end + end + end + if settings.startup["017-rocket-victory"].value then + if whitelisted == false then + if tech.unit then + if tech.unit.ingredients then + for j, nasa in pairs(tech.unit.ingredients) do + if nasa[1] == "space-science-pack" then + compare(tech, "space-science-pack", "space-science-pack") + break + else + whitelisted = false + end + end + end + end + end + end + if whitelisted == true then + local valid = compare(tech, "logistics-science-pack", "science-pack-2") + if valid == false then + local valid = compare(tech, "chemical-science-pack", "science-pack-3") end + if valid == false then + local valid = compare(tech, "production-science-pack", "production-science-pack") end + if valid == false then + local valid = compare(tech, "military-science-pack", "military-science-pack") end + if valid == false then + compare(tech, "utility-science-pack", "high-tech-science-pack") + end + end + end + end +end \ No newline at end of file diff --git a/017_science/data-updates.lua b/017_science/data-updates.lua index 84e3992..6497487 100644 --- a/017_science/data-updates.lua +++ b/017_science/data-updates.lua @@ -47,7 +47,6 @@ end if settings.startup["017-recipes-changes"].value then recipe_change(data.raw["recipe"]["atomic-bomb"].ingredients, "processing-unit", {"rocket-control-unit", 15}) - recipe_change(data.raw["recipe"]["power-armor-mk2"].ingredients, "speed-module-3", {"speed-module-2", 5}) recipe_change(data.raw["recipe"]["power-armor-mk2"].ingredients, "effectivity-module-3", {"effectivity-module-2", 5}) local power_armor = data.raw["technology"]["power-armor-2"].prerequisites @@ -73,14 +72,20 @@ data.raw["technology"]["nuclear-fuel-reprocessing"].unit.count = (1500-settings. if settings.startup["017-pack-type-rebalancing"].value then remove_science(data.raw["technology"]["rocket-silo"].unit.ingredients, "military-science-pack") - remove_science(data.raw["technology"]["kovarex-enrichment-process"].unit.ingredients, "high-tech-science-pack") - remove_science(data.raw["technology"]["speed-module-3"].unit.ingredients, "high-tech-science-pack") - table.insert(data.raw["technology"]["speed-module-3"].unit.ingredients, {"production-science-pack", 1}) - remove_science(data.raw["technology"]["effectivity-module-3"].unit.ingredients, "high-tech-science-pack") - table.insert(data.raw["technology"]["effectivity-module-3"].unit.ingredients, {"production-science-pack", 1}) - remove_science(data.raw["technology"]["effect-transmission"].unit.ingredients, "high-tech-science-pack") - table.insert(data.raw["technology"]["effect-transmission"].unit.ingredients, {"production-science-pack", 1}) - remove_science(data.raw["technology"]["logistic-system"].unit.ingredients, "production-science-pack") + if not mods["Nuclear Fuel"] then + remove_science(data.raw["technology"]["kovarex-enrichment-process"].unit.ingredients, "high-tech-science-pack") + end + if not mods["bobmodules"] then + remove_science(data.raw["technology"]["speed-module-3"].unit.ingredients, "high-tech-science-pack") + table.insert(data.raw["technology"]["speed-module-3"].unit.ingredients, {"production-science-pack", 1}) + remove_science(data.raw["technology"]["effectivity-module-3"].unit.ingredients, "high-tech-science-pack") + table.insert(data.raw["technology"]["effectivity-module-3"].unit.ingredients, {"production-science-pack", 1}) + remove_science(data.raw["technology"]["effect-transmission"].unit.ingredients, "high-tech-science-pack") + table.insert(data.raw["technology"]["effect-transmission"].unit.ingredients, {"production-science-pack", 1}) + end + if not mods["bobslogistics"] then + remove_science(data.raw["technology"]["logistic-system"].unit.ingredients, "production-science-pack") + end end if settings.startup["017-techtree"].value then @@ -127,7 +132,7 @@ if settings.startup["017-techtree"].value then if settings.startup["017-old-science"].value and settings.startup["017-techtree"].value then remove_effect_table = { - {"military-2", "military-science-pack "}, + {"military-2", "military-science-pack"}, {"advanced-electronics", "science-pack-3"}, {"advanced-material-processing-2", "production-science-pack"}, {"advanced-electronics-2", "high-tech-science-pack"} @@ -149,10 +154,12 @@ if settings.startup["017-techtree"].value then {type = "unlock-recipe", recipe = "high-tech-science-pack"}, {type = "unlock-recipe", recipe = "17-utility-science-pack"} } - data_technology["low-density-structure"].effects = { - {type = "unlock-recipe", recipe = "low-density-structure"}, - {type = "unlock-recipe", recipe = "17-low-density-structure"} - } + if not mods["bobrevamp"] then + data_technology["low-density-structure"].effects = { + {type = "unlock-recipe", recipe = "low-density-structure"}, + {type = "unlock-recipe", recipe = "17-low-density-structure"} + } + end for i=1, #remove_effect_table do local effects = data_technology[remove_effect_table[i][1]].effects @@ -164,100 +171,12 @@ if settings.startup["017-techtree"].value then end end end - end - - local function compare(technology, science_pack, pre_tier) - valid = true - if technology and technology.unit then - for l, j in pairs(technology.unit.ingredients) do - if j[1] == pre_tier then - valid = true - break - else - valid = false - end - end - end - if valid == true then - if technology.prerequisites then - for _=1, #technology.prerequisites do - local tech = data.raw["technology"][technology.prerequisites[_]] - if valid == true then - if tech then - if tech.unit then - for i, ingredients in pairs(tech.unit.ingredients) do - if ingredients[1] == pre_tier then - valid = false - break - else - valid = true - end - end - elseif valid == false then - break - end - elseif valid == false then - break - end - end - end - end - end - if technology.prerequisites and valid == true then - technology.prerequisites[#technology.prerequisites+1] = science_pack - return true - else - return false - end end - - for _, tech in pairs(data.raw["technology"]) do - if tech.name ~= ("logistics-science-pack" or "chemical-science-pack" or "production-science-pack" or "utility-science-pack" or "space-science-pack") then - if tech.effects then - if #tech.effects ~= 0 then - for i, effect in pairs(tech.effects) do - if effect then - if effect.type then - if effect.type == "unlock-recipe" then - whitelisted = true - break - else - whitelisted = false - end - end - end - end - end - if settings.startup["017-rocket-victory"].value then - if whitelisted == false then - if tech.unit then - if tech.unit.ingredients then - for j, nasa in pairs(tech.unit.ingredients) do - if nasa[1] == "space-science-pack" then - compare(tech, "space-science-pack", "space-science-pack") - break - else - whitelisted = false - end - end - end - end - end - end - if whitelisted == true then - local valid = compare(tech, "logistics-science-pack", "science-pack-2") - if valid == false then - local valid = compare(tech, "chemical-science-pack", "science-pack-3") end - if valid == false then - local valid = compare(tech, "production-science-pack", "production-science-pack") end - if valid == false then - local valid = compare(tech, "military-science-pack", "military-science-pack") end - if valid == false then - compare(tech, "utility-science-pack", "high-tech-science-pack") - end - end - end - end + if mods["bobrevamp"] then + data_technology["low-density-structure"].effects = { + {type = "unlock-recipe", recipe = "low-density-structure"}, + -- {type = "unlock-recipe", recipe = "17-low-density-structure"} + } end end diff --git a/017_science/data.lua b/017_science/data.lua index 6812ad2..cbcf29b 100644 --- a/017_science/data.lua +++ b/017_science/data.lua @@ -32,8 +32,10 @@ if not settings.startup["017-old-science"].value then hide("production-science-pack", "advanced-material-processing-2") hide("high-tech-science-pack", "advanced-electronics-2") - data.raw["recipe"]["low-density-structure"].normal.hidden = true - data.raw["recipe"]["low-density-structure"].expensive.hidden = true + if not mods["bobrevamp"] then + data.raw["recipe"]["low-density-structure"].normal.hidden = true + data.raw["recipe"]["low-density-structure"].expensive.hidden = true + end elseif settings.startup["017-old-science"].value then data.raw["recipe"]["science-pack-3"].hidden = false data.raw["recipe"]["military-science-pack"].hidden = false diff --git a/017_science/info.json b/017_science/info.json index b289f99..da991a8 100644 --- a/017_science/info.json +++ b/017_science/info.json @@ -1,6 +1,6 @@ { "name": "017_science", - "version": "0.1.1", + "version": "0.1.2", "factorio_version": "0.16", "title": "0.17 science conversion", "author": "npc_strider(morley376)", diff --git a/017_science/technology.lua b/017_science/technology.lua index 8f5e0e3..ca0ec15 100644 --- a/017_science/technology.lua +++ b/017_science/technology.lua @@ -139,51 +139,6 @@ data:extend( }, order = "d-a-a" }, - { - type = "technology", - name = "rocket-fuel", - icon_size = 128, - icon = "__017_science__/graphics/technology/rocketfuel.png", - effects = - { - {type = "unlock-recipe", recipe = "rocket-fuel"} - }, - prerequisites = {"engine", "flammables"}, - unit = - { - count = settings.startup["017-rocket-fuel-cost"].value, - ingredients = - { - {"science-pack-1", 1}, - {"science-pack-2", 1}, - }, - time = settings.startup["017-rocket-fuel-energy"].value - }, - order = "d-a-b" - }, - { - type = "technology", - name = "low-density-structure", - icon_size = 128, - icon = "__017_science__/graphics/technology/rocketstructure.png", - effects = - { - {type = "unlock-recipe", recipe = "17-low-density-structure"} - }, - prerequisites = {"advanced-material-processing"}, - unit = - { - count = settings.startup["017-rocket-structure-cost"].value, - ingredients = - { - {"science-pack-1", 1}, - {"science-pack-2", 1}, - {"science-pack-3", 1}, - }, - time = settings.startup["017-rocket-structure-energy"].value - }, - order = "e-e-e" - }, { type = "technology", name = "rocket-control-unit", @@ -235,6 +190,63 @@ data:extend( }) end +if not mods["angelspetrochem"] and settings.startup["017-techtree"].value then +data:extend( +{ + { + type = "technology", + name = "rocket-fuel", + icon_size = 128, + icon = "__017_science__/graphics/technology/rocketfuel.png", + effects = + { + {type = "unlock-recipe", recipe = "rocket-fuel"} + }, + prerequisites = {"engine", "flammables"}, + unit = + { + count = settings.startup["017-rocket-fuel-cost"].value, + ingredients = + { + {"science-pack-1", 1}, + {"science-pack-2", 1}, + }, + time = settings.startup["017-rocket-fuel-energy"].value + }, + order = "d-a-b" + } +}) +end + +if not mods["bobrevamp"] and settings.startup["017-techtree"].value then +data:extend( +{ + { + type = "technology", + name = "low-density-structure", + icon_size = 128, + icon = "__017_science__/graphics/technology/rocketstructure.png", + effects = + { + {type = "unlock-recipe", recipe = "17-low-density-structure"} + }, + prerequisites = {"advanced-material-processing"}, + unit = + { + count = settings.startup["017-rocket-structure-cost"].value, + ingredients = + { + {"science-pack-1", 1}, + {"science-pack-2", 1}, + {"science-pack-3", 1}, + }, + time = settings.startup["017-rocket-structure-energy"].value + }, + order = "e-e-e" + } +}) +end + if settings.startup["017-techtree"].value and settings.startup["017-rocket-victory"].value then data:extend( {