From d6362bde0e940711f9029b414a90b1dcfcca9da1 Mon Sep 17 00:00:00 2001 From: PreLeyZero Date: Mon, 21 Mar 2022 00:46:47 +0100 Subject: [PATCH] added recursive tech card script --- locale/en/lang_en.cfg | 9 +- prototypes/fu_recipes.lua | 10 +- prototypes/fusion/fu_activator.lua | 2 +- scripts/krastorio2/data-final-fixes.lua | 2 +- scripts/krastorio2/overhaul.lua | 437 +++++++++++++++++++++++- scripts/overhaul.lua | 2 +- 6 files changed, 446 insertions(+), 16 deletions(-) diff --git a/locale/en/lang_en.cfg b/locale/en/lang_en.cfg index f39641b..b995c98 100644 --- a/locale/en/lang_en.cfg +++ b/locale/en/lang_en.cfg @@ -64,10 +64,10 @@ fi_modules_productivity_4_item=Gauss Module "4.Art" fi_modules_productivity_5_item=Gauss Module "5.Art" fi_modules_productivity_6_item=Gauss Module "6.Art" -fi_crushed_glass_item=Crushed glass +fi_crushed_glass_item=Crushed industrial glass fi_crushed_stone_item=Crushed stone fi_crushed_uranium_item=Crushed uranium -fi_materials_glass=Glass +fi_materials_glass=Industrial glass fi_materials_glass_fiber=Fiberglass fi_materials_natural_fiber=Natural fiber fi_materials_gold=Gold @@ -183,7 +183,7 @@ el_arc_pure_aluminum=Molten aluminium fi_crystal_fluid=Crystal matrix (liquid) fi_dirty_water=Rich water fi_strong_acid=Hydrofluoric acid -fi_arc_glass=Molten glass +fi_arc_glass=Molten industrial glass fi_arc_gold=Molten gold fi_arc_titan=Molten titan fi_arc_neodym=Molten neodymium @@ -465,7 +465,8 @@ el_purifier_tech=Ore purification el_caster_tech=Metal casting el_grower_tech=Crystal growing -fi_glass_tech=Glass +fi_castor_tech=Waste storage +fi_glass_tech=Industrial glass fi_flourite_tech=Flourite fi_fiberer_tech=Fiber production fi_purifier_tech=Advanced ore purification diff --git a/prototypes/fu_recipes.lua b/prototypes/fu_recipes.lua index a13b257..b0914bb 100644 --- a/prototypes/fu_recipes.lua +++ b/prototypes/fu_recipes.lua @@ -1465,7 +1465,7 @@ data:extend({ }, results = { {type="item", name="fu_materials_empty_container", amount=1}, - {type="fluid", name="fu_neutron_fluid", amount=1}, + {type="fluid", name="fu_neutron_fluid", amount=2}, }, result_count = 1, energy_required = 1, @@ -1481,7 +1481,7 @@ data:extend({ }, results = { {type="item", name="fi_used_advanced_thorium_fuel_item", amount=1}, - {type="fluid", name="fu_neutron_fluid", amount=20}, + {type="fluid", name="fu_neutron_fluid", amount=30}, }, result_count = 1, energy_required = 4, @@ -1497,7 +1497,7 @@ data:extend({ }, results = { {type="item", name="fi_used_basic_fuel_item", amount=1}, - {type="fluid", name="fu_neutron_fluid", amount=20}, + {type="fluid", name="fu_neutron_fluid", amount=30}, }, result_count = 1, energy_required = 4, @@ -1513,7 +1513,7 @@ data:extend({ }, results = { {type="item", name="fi_used_basic_thorium_fuel_item", amount=1}, - {type="fluid", name="fu_neutron_fluid", amount=12}, + {type="fluid", name="fu_neutron_fluid", amount=18}, }, result_count = 1, energy_required = 4, @@ -1529,7 +1529,7 @@ data:extend({ }, results = { {type="item", name="fi_used_advanced_fuel_item", amount=1}, - {type="fluid", name="fu_neutron_fluid", amount=28}, + {type="fluid", name="fu_neutron_fluid", amount=34}, }, result_count = 1, energy_required = 4, diff --git a/prototypes/fusion/fu_activator.lua b/prototypes/fusion/fu_activator.lua index 287de59..0fc2107 100644 --- a/prototypes/fusion/fu_activator.lua +++ b/prototypes/fusion/fu_activator.lua @@ -54,7 +54,7 @@ data:extend({ 0, 0.8 }, - module_slots = 2 + module_slots = 4 }, --fluids fluid_boxes = { diff --git a/scripts/krastorio2/data-final-fixes.lua b/scripts/krastorio2/data-final-fixes.lua index 0100693..4cd76e4 100644 --- a/scripts/krastorio2/data-final-fixes.lua +++ b/scripts/krastorio2/data-final-fixes.lua @@ -118,7 +118,7 @@ data:extend({ }, results = { {type="fluid", name="fu_lead_fluid_cold", amount=50}, - {type="fluid", name="steam", amount=1000/2, temperature=425}, + {type="fluid", name="steam", amount=1000/2, temperature=415}, }, result_count = 1, energy_required = 1, diff --git a/scripts/krastorio2/overhaul.lua b/scripts/krastorio2/overhaul.lua index 702759b..0aa263f 100644 --- a/scripts/krastorio2/overhaul.lua +++ b/scripts/krastorio2/overhaul.lua @@ -82,13 +82,194 @@ local function remove_tech_cards(table_in) end end +local function remove_pre_tech(tech, pre_tech) + if not data.raw.technology[tech] then + return + end + + for i,v in ipairs(data.raw.technology[tech].prerequisites) do + if v == pre_tech then + v = nil + end + end +end + +local function remove_pre_techs(table_in) + --table structure: {{tech, pre_tech}, ... , ...} + for i,v in pairs(table_in) do + remove_pre_tech(table_in[i].tech, table_in[i].pre_tech) + end +end + +local function add_tech_cards(table_in) + --table structure: {{tech, card}, ... , ...} + for i,v in pairs(table_in) do + add_tech_card(table_in[i].tech, table_in[i].card) + end +end + +local function add_tech_card(tech, card) + if not data.raw.technology[tech] then + return + end + + if contains_tech_card(data.raw.technology[tech].unit.ingredients, card) then + return + end + + table.insert(data.raw.technology[tech].unit.ingredients, {card, 1}) +end + +function contains_tech_card(table_in, card) + for i,v in ipairs(table_in) do + if v[1] == card then + return true + end + end + return false +end + +--[FIND TECHS AFTER GIVEN TECH RECURSIVELY] +--find all techs after given tech in tech tree and elimate doubles from result table + + +function walk_techs(pos, break_con) + --one iteration: + --find all leaves for this tech + --get their lists and add them to own + --return own list + + local leaves = find_following_techs(pos, break_con) + table_out = {} + + if is_table_empty(leaves) then + --meaning this is at end of tech tree + + table.insert(table_out, pos) + return table_out + end + + for i,v in ipairs(leaves) do + --for every leaf tech, i = index, v = tech_pos + + table.insert(table_out, pos) + table_out = append_table(table_out, walk_techs(v, break_con)) + end + + return table_out +end + +function append_table(table_a, table_b) + for i,v in ipairs(table_b) do table.insert(table_a, v) end return table_a +end + +function find_following_techs(tech, break_con) + --finds all techs with given tech as prerequisite and returns them in table form + local return_table = {} + + for i,v in pairs(data.raw.technology) do + --i = techname, v = data.raw.technology[techname] + + for j,w in ipairs(data.raw.technology[i].prerequisites) do + --prerequisites = {'el_energy_tech'} + --j = index, w = techname + + if w == tech then + if not (i == break_con) then + table.insert(return_table, i) + end + end + end + end + + return return_table +end + +function is_table_empty(table_in) + local next_ele = next + if next_ele(table_in) == nil then + return true + else + return false + end +end + +function del_doubles(table_in) + --table_in is keyed table in form of {start_tech, tech_a, tech_b ....} + + table_out = {} + for i,v in ipairs(table_in) do + --i = index, v = tech + + if not is_in_table(table_out, v) then + table.insert(table_out, v) + end + end + + return table_out +end + +function is_in_table(table_in, arg) + --check if arg is an value of indexed table + + for i,v in ipairs(table_in) do + if v == arg then + return true + end + end + + return false +end + +local function add_cards_to_tree(table_in, card) + for i,v in ipairs(table_in) do + add_tech_card(v, card) + end +end + --=================================================================================================================== --- 248k items to Krastorio2 recipes +-- 248k item/tech integration with Krastorio2 --=================================================================================================================== --[BUILDINGS] building_table = { + {"kr-electrolysis-plant", "el_materials_ALK", 10}, + {"kr-filtration-plant", "el_materials_ALK", 10}, + --{"kr-electrolysis-plant", "el_materials_ALK", 10}, + --{"kr-electrolysis-plant", "el_materials_ALK", 10}, + {"kr-fluid-burner", "el_materials_ALK", 2}, + {"kr-atmospheric-condensor", "el_materials_ALK", 6}, + {"el_solar_recipe", "solar-panel", 2}, + {"solar-panel", "el_materials_ALK", 6}, + {"kr-advanced-solar-panel", "el_solar_item", 1}, + {"kr-advanced-solar-panel", "fi_materials_GFK", 2}, + {"kr-fuel-refinery", "el_materials_ALK", 4}, + {"kr-gas-power-station", "el_materials_ALK", 10}, + + {"buisart-lab", "fi_materials_NFK", 10}, + {"kr-electric-mining-drill-mk2", "fi_materials_GFK", 6}, + {"kr-research-server", "fi_materials_NFK", 8}, + {"kr-research-server", "fi_materials_GFK", 8}, + {"kr-air-purifier", "fi_materials_NFK", 4}, + {"kr-bio-lab", "fi_materials_NFK", 20}, + {"kr-atmospheric-condensor", "fi_materials_GFK", 4}, + {"kr-fusion-reactor", "fu_tech_sign_item",200}, + {"fu_tokamak_reactor_recipe", "kr-fusion-reactor",1}, + {"kr-advanced-steam-turbine", "fu_materials_KFK", 10}, + --logistics + {"kr-fast-loader", "el_materials_ALK", 4}, + {"kr-express-loader", "fi_materials_GFK", 4}, + {"kr-advanced-transport-belt", "fu_materials_KFK", 1}, + {"kr-advanced-splitter", "fu_materials_KFK", 3}, + {"kr-advanced-loader", "fu_materials_KFK", 4}, + {"kr-advanced-underground-belt", "fu_materials_KFK", 8}, + + {"kr-advanced-assembling-machine", "fu_materials_KFK", 6}, + {"kr-advanced-furnace", "fu_materials_KFK", 6}, + {"kr-advanced-chemical-plant", "fu_materials_KFK", 6}, + {"kr-large-roboport", "fi_robo_port_item", 1}, + } @@ -101,33 +282,281 @@ item_table = { {"speed-module-3", "fi_modules_core_item", 3}, {"effectivity-module-2", "fi_modules_core_item", 1}, {"effectivity-module-3", "fi_modules_core_item", 3}, + {"ai-core", "fu_materials_energy_crystal", 1}, + {"fusion-reactor-equipment","fu_materials_energy_crystal", 25}, + {"imersium-plate", "fi_crushed_crystal_item", 4}, + {"lithium-sulfur-battery", "el_lithium_battery", 1}, + {"empty-dt-fuel", "fu_materials_KFK", 2}, + {"fu_empty_container_recipe","empty-dt-fuel", 1}, + {"energy-control-unit", "fu_materials_energy_crystal", 1}, + + --science + {"chemical-science-pack", "el_energy_crystal_item",3}, + {"production-science-pack", "fi_materials_titan", 1}, + {"utility-science-pack", "fi_materials_neodym", 1}, + {"matter-tech-card", "fu_tech_sign_item", 5}, + {"singularity-tech-card", "gr_materials_magnet", 1}, } --[TECH] tech_table = { + {"kr-fluids-chemistry", "el_materials_ALK"}, + {"kr-advanced-solar-panel", "el_solar_tech"}, + {"kr-fluids-chemistry", "el_materials_ALK"}, + {"kr-fluid-excess-handling", "el_burner_tech"}, + {"kr-advanced-lab", "fi_materials_tech"}, + {"kr-electric-mining-drill-mk2","fi_materials_tech"}, + {"kr-kr-research-server", "fi_materials_tech"}, + {"kr-air-purification", "fi_materials_tech"}, + {"kr-bio-processing", "fi_materials_tech"}, + {"kr-logistic-4", "fu_KFK_tech"}, + {"logistics-2", "el_materials_ALK"}, + {"fi_robo_tech", "construction-robotics"}, + {"fi_robo_tech", "logistic-robotics"}, + {"fu_tokamak_tech", "kr-fusion-energy"}, + {"kr-fusion-energy", "fu_KFK_tech"}, + {"kr-ai-core", "fu_crystal_tech"}, + {"fusion-reactor-equipment", "fu_crystal_tech"}, + {"kr-imersium-processing", "fu_crystal_tech"}, + {"kr-lithium-sulfur-battery", "el_lithium_tech"}, + {"kr-matter-tech-card", "fu_energy_tech"}, + {"kr-singularity-tech-card", "gr_magnet_tech"}, + {"kr-energy-control-unit", "fu_crystal_tech"}, + {"kr-advanced-assembling-machine","fu_KFK_tech"}, + {"kr-advanced-furnace", "fu_KFK_tech"}, + {"kr-advanced-chemical-plant", "fu_KFK_tech"}, + {"kr-advanced-roboports", "fi_robo_tech"}, + {"gr_stage_tech", "kr-matter-tech-card"}, + {"gr_stage_tech", "kr-advanced-tech-card"}, + {"gr_charger_tech", "kr-singularity-tech-card"}, + {"gr_compact_fusion_tech", "kr-singularity-tech-card"}, + --energy tech + {"kr-fuel", "el_energy_tech"}, + {"kr-gas-power-station", "el_energy_tech"}, + {"kr-nuclear-reactor-equipment","fi_energy_tech"}, + {"nuclear-fuel-reprocessing", "fi_energy_tech"}, + {"kr-nuclear-locomative", "fi_energy_tech"}, + + +} + +--[ADD TECH CARDS] + +add_card_table = { + --{"el_purifier_tech", "space-science-pack"}, + } --[REMOVE TECH CARDS] -card_table = { +remove_card_table = { {"el_purifier_tech", "logistic-science-pack"}, {"el_arc_furnace_tech", "logistic-science-pack"}, {"el_caster_tech", "logistic-science-pack"}, {"el_ALK_tech", "logistic-science-pack"}, } +--[REMOVE PREREQUISITES] + +pre_tech_table = { + {"el_purifier_tech", "logistic-science-pack"}, +} + --=================================================================================================================== --- structure and adding +-- changes in entities and other protypes --=================================================================================================================== +data.raw["solar-panel"]["el_solar_entity"].production = "220kW" +data.raw["solar-panel"]["kr-advanced-solar-panel"].production = "480kW" +data.raw.item["el_materials_ALK"].stack_size = 200 +data.raw.recipe["dt-fuel"].ingredients = { + {type="item", name="empty-dt-fuel", amount=1}, + {type="fluid", name="fu_deuterium", amount=6}, + {type="fluid", name="fu_tritium", amount=6} +} + +data:extend({ + { + name = 'fi_arc_glass_recipe', + type = 'recipe', + enabled = 'false', + category = 'el_arc_furnace_category', + ingredients = { + {type="item", name="glass", amount=15}, + {type="item", name="quartz", amount=5}, + {type="item", name="coke", amount=5} + }, + results = { + {type="fluid", name="fi_arc_glass", amount=600}, + }, + energy_required = 1, + order = 'a-b', + always_show_made_in = true + }, + { + name = 'fu_activator_4_recipe', + type = 'recipe', + category = 'chemistry', + main_product = 'fu_tritium', + enabled = 'false', + ingredients = { + {type="item", name="tritium", amount=1}, + }, + results = { + {type="fluid", name="fu_tritium", amount=3}, + }, + result_count = 1, + energy_required = 1, + always_show_made_in = true, + }, + { + name = 'fu_activator_3_recipe', + type = 'recipe', + category = 'chemistry', + main_product = 'fu_deuterium', + enabled = 'false', + ingredients = { + {type="fluid", name="heavy-water", amount=10}, + {type="item", name="improved-pollution-filter", amount=1}, + }, + results = { + {type="fluid", name="fu_deuterium", amount=3}, + }, + result_count = 1, + energy_required = 10, + always_show_made_in = true, + }, +}) + +--=================================================================================================================== +-- structures and adding +--=================================================================================================================== recipe_structure = {"recipe", "item", "item_amount"} tech_structure = {"tech", "pre_tech"} card_structure = {"tech", "card"} +break_con = "gr_red_tech" add_to_recipes(change_table_index(building_table, recipe_structure)) add_to_recipes(change_table_index(item_table, recipe_structure)) add_to_techs(change_table_index(tech_table, tech_structure)) -remove_tech_cards(change_table_index(card_table, card_structure)) \ No newline at end of file +add_tech_cards(change_table_index(add_card_table, tech_structure)) +remove_pre_techs(change_table_index(pre_tech_table, tech_structure)) +remove_tech_cards(change_table_index(remove_card_table, card_structure)) + +add_cards_to_tree(del_doubles(walk_techs("gr_stage_tech", break_con)), "matter-tech-card") +add_cards_to_tree(del_doubles(walk_techs("gr_stage_tech", break_con)), "advanced-tech-card") +add_cards_to_tree(del_doubles(walk_techs("gr_charger_tech", break_con)), "singularity-tech-card") +add_cards_to_tree(del_doubles(walk_techs("gr_compact_fusion_tech", break_con)), "singularity-tech-card") +add_cards_to_tree(del_doubles(walk_techs("kr-singularity-tech-card", break_con)), "fu_space_probe_science_item") + + +--TODO +--rare metals with fi_materials +--compact fusion tech and singularity tech +--singularity tech stuff integate + +--=================================================================================================================== +-- math and meta +--=================================================================================================================== + +--[FUSION CALC] +--[[ + 1 D/s = 1 Neutron Fluid + 1 T/s = 2 Neutron Fluid + + TOKAMAK: + D2 Fusion: + 110.000 cold lead + 200 D | 100s = 110.000 hot lead + -> 1.100 hot lead/s + A: (415 dec steam) 1 hot lead = 10 steam + -> 11.000 hot steam/s | 50 (415 dec steam)/s = 10MW + == 2.200 MW + + B: (975 dec steam) 1 hot lead = 2.5 steam + -> 2.750 hot steam/s | 100 (975 dec steam)/s = 100MW + == 2.750 MW + + DT Fusion: + 180.000 cold lead + 100 D + 100 T | 100s = 180.000 hot lead + -> 1.800 hot lead/s + A: (415 dec steam) 1 hot lead = 10 steam + -> 18.000 hot steam/s | 50 (415 dec steam)/s = 10MW + == 3.600 MW + + B: (975 dec steam) 1 hot lead = 2.5 steam + -> 4.500 hot steam/s | 100 (975 dec steam)/s = 100MW + == 4.500 MW + STELLARATOR: + DT Fusion: + 1.000 cold lead + 1 D + 1 T | 1s = 1.000 hot lead + -> 1.000 hot lead/s + A: (415 dec steam) 1 hot lead = 10 steam + -> 10.000 hot steam/s | 50 (415 dec steam)/s = 10MW + == 2.000 MW + + B: (975 dec steam) 1 hot lead = 2.5 steam + -> 2.500 hot steam/s | 100 (975 dec steam)/s = 100MW + == 2.500 MW + + PL Fusion: + 1.000 cold lead + 15 P + 15 L | 1s = 1.000 hot lead + -> 1.000 hot lead/s + A: (415 dec steam) 1 hot lead = 10 steam + -> 10.000 hot steam/s | 50 (415 dec steam)/s = 10MW + == 2.000 MW + + B: (975 dec steam) 1 hot lead = 2.5 steam + -> 2.500 hot steam/s | 100 (975 dec steam)/s = 100MW + == 2.500 MW + + DT Breeder Fusion: + 300 cold lead + 1 D + 1 T | 1s = 300 hot lead + -> 300 hot lead/s + A: (415 dec steam) 1 hot lead = 10 steam + -> 3.000 hot steam/s | 50 (415 dec steam)/s = 10MW + == 600 MW + + B: (975 dec steam) 1 hot lead = 2.5 steam + -> 750 hot steam/s | 100 (975 dec steam)/s = 100MW + == 750 MW + + PL Breeder Fusion: + 300 cold lead + 15 P + 15 L | 1s = 300 hot lead + -> 300 hot lead/s + A: (415 dec steam) 1 hot lead = 10 steam + -> 3.000 hot steam/s | 50 (415 dec steam)/s = 10MW + == 600 MW + + B: (975 dec steam) 1 hot lead = 2.5 steam + -> 750 hot steam/s | 100 (975 dec steam)/s = 100MW + == 750 MW + + KRASTORIO 2: + DT Fusion: + 1 T(K2) + 10 HW(K2) | 1s = 2.000 (975 dec steam) + -> 2.000 hot steam/s | 100 (975 dec steam)/s = 100MW + == 2.000 MW +]] + +--=================================================================================================================== +-- sumarize +--=================================================================================================================== + +--[[ + + Recipe Input/s Output (415 dec) Output (975 dec) + TOKAMAK: + D2 2 D 2.200 MW 2.750 MW + DT 1 D + 1 T 3.600 MW 4.500 MW + STELLARATOR: + DT 1 D + 1 T 2.000 MW 2.500 MW + PL 15 P + 15 L 2.000 MW 2.500 MW + DT + NF 1 D + 1 T 600 MW 750 MW + PL + NF 15 P + 15 L 600 MW 750 MW + KRASTORIO 2: + DT Cell 1/5 T(K2) + 2 HW(K2) - 2.000 MW + +]] diff --git a/scripts/overhaul.lua b/scripts/overhaul.lua index c41a747..99ae702 100644 --- a/scripts/overhaul.lua +++ b/scripts/overhaul.lua @@ -162,7 +162,7 @@ tech_table = { } --=================================================================================================================== --- structure and adding +-- structures and adding --=================================================================================================================== recipe_structure = {"recipe", "item", "item_amount"}