From 023a798ac1b972db33f1476778f9178c021d5745 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 21 Jun 2021 22:25:49 +0200 Subject: [PATCH] Factorio: refactor visibility option into tech_tree_information set vanilla technologies to be hidden instead of disabled fix advancement icon still showing when no information in tech was supposed to be given --- Main.py | 4 ++-- Options.py | 13 +++++++------ data/factorio/mod_template/data-final-fixes.lua | 6 +++--- data/factorio/mod_template/locale/en/locale.cfg | 8 +++++--- playerSettings.yaml | 5 +++-- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Main.py b/Main.py index 2ef8ccc4..f21c50f8 100644 --- a/Main.py +++ b/Main.py @@ -508,10 +508,10 @@ def main(args, seed=None): for item in world.precollected_items: precollected_items[item.player].append(item.code) precollected_hints = {player: set() for player in range(1, world.players + 1)} - # for now special case Factorio visibility + # for now special case Factorio tech_tree_information sending_visible_players = set() for player in world.factorio_player_ids: - if world.visibility[player]: + if world.tech_tree_information[player].value == 2: sending_visible_players.add(player) for i, team in enumerate(parsed_names): diff --git a/Options.py b/Options.py index c7821e04..5052a4fa 100644 --- a/Options.py +++ b/Options.py @@ -348,8 +348,8 @@ class MaxSciencePack(Choice): default = 6 def get_allowed_packs(self): - return {option.replace("_", "-") for option, value in self.options.items() - if value <= self.value} + return {option.replace("_", "-") for option, value in self.options.items() if value <= self.value} - \ + {"space-science-pack"} # with rocket launch being the goal, post-launch techs don't make sense class TechCost(Choice): @@ -388,10 +388,11 @@ class TechTreeLayout(Choice): default = 0 -class Visibility(Choice): +class TechTreeInformation(Choice): option_none = 0 - option_sending = 1 - default = 1 + option_advancement = 1 + option_full = 2 + default = 2 class RecipeTime(Choice): @@ -411,7 +412,7 @@ factorio_options: typing.Dict[str, type(Option)] = { "tech_tree_layout": TechTreeLayout, "tech_cost": TechCost, "free_samples": FreeSamples, - "visibility": Visibility, + "tech_tree_information": TechTreeInformation, "starting_items": FactorioStartItems, "recipe_time": RecipeTime, "imported_blueprints": DefaultOnToggle, diff --git a/data/factorio/mod_template/data-final-fixes.lua b/data/factorio/mod_template/data-final-fixes.lua index 58eb4425..9efd1539 100644 --- a/data/factorio/mod_template/data-final-fixes.lua +++ b/data/factorio/mod_template/data-final-fixes.lua @@ -23,7 +23,7 @@ template_tech.effects = {} template_tech.prerequisites = {} function prep_copy(new_copy, old_tech) - old_tech.enabled = false + old_tech.hidden = true new_copy.unit = table.deepcopy(old_tech.unit) local ingredient_filter = allowed_ingredients[old_tech.name] if ingredient_filter ~= nil then @@ -69,12 +69,12 @@ prep_copy(new_tree_copy, original_tech) {% if tech_cost_scale != 1 %} new_tree_copy.unit.count = math.max(1, math.floor(new_tree_copy.unit.count * {{ tech_cost_scale }})) {% endif %} -{%- if item_name in tech_table and visibility -%} +{%- if item_name in tech_table and tech_tree_information == 2 -%} {#- copy Factorio Technology Icon -#} copy_factorio_icon(new_tree_copy, "{{ item_name }}") {%- else -%} {#- use default AP icon if no Factorio graphics exist -#} -{% if advancement %}set_ap_icon(new_tree_copy){% else %}set_ap_unimportant_icon(new_tree_copy){% endif %} +{% if advancement or not tech_tree_information %}set_ap_icon(new_tree_copy){% else %}set_ap_unimportant_icon(new_tree_copy){% endif %} {%- endif -%} {#- connect Technology #} {%- if original_tech_name in tech_tree_layout_prerequisites %} diff --git a/data/factorio/mod_template/locale/en/locale.cfg b/data/factorio/mod_template/locale/en/locale.cfg index bce4d5f9..9a6202e7 100644 --- a/data/factorio/mod_template/locale/en/locale.cfg +++ b/data/factorio/mod_template/locale/en/locale.cfg @@ -1,17 +1,19 @@ [technology-name] {% for original_tech_name, item_name, receiving_player, advancement in locations %} -{%- if visibility -%} +{%- if tech_tree_information == 2 -%} ap-{{ tech_table[original_tech_name] }}-={{ player_names[receiving_player] }}'s {{ item_name }} {% else %} -ap-{{ tech_table[original_tech_name] }}-= An Archipelago Sendable +ap-{{ tech_table[original_tech_name] }}-=An Archipelago Sendable {%- endif -%} {% endfor %} [technology-description] {% for original_tech_name, item_name, receiving_player, advancement in locations %} -{%- if visibility -%} +{%- if tech_tree_information == 2 -%} ap-{{ tech_table[original_tech_name] }}-=Researching this technology sends {{ item_name }} to {{ player_names[receiving_player] }}{% if advancement %}, which is considered a logical advancement{% endif %}. +{%- elif tech_tree_information == 1 and advancement -%} +ap-{{ tech_table[original_tech_name] }}-=Researching this technology sends something to someone, which is considered a logical advancement. {% else %} ap-{{ tech_table[original_tech_name] }}-=Researching this technology sends something to someone. {%- endif -%} diff --git a/playerSettings.yaml b/playerSettings.yaml index ea00b2c4..e46428d4 100644 --- a/playerSettings.yaml +++ b/playerSettings.yaml @@ -91,9 +91,10 @@ Factorio: single_craft: 0 half_stack: 0 stack: 0 - visibility: + tech_tree_information: none: 0 - sending: 1 + advancement: 0 # show which items are a logical advancement + full: 1 # show full info on each tech node imported_blueprints: # can be turned off to prevent access to blueprints created outside the current world on: 1 off: 0