From 1d954b192cead40e57f53e05f47caa3b3c10a5c7 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sat, 31 Jul 2021 19:45:17 +0200 Subject: [PATCH] Factorio: display required rocket-silo ingredients ahead of time. --- CommonClient.py | 8 +++++++- worlds/factorio/data/mod_template/data-final-fixes.lua | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CommonClient.py b/CommonClient.py index 823d93d3..9d08c2d9 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -211,6 +211,10 @@ class CommonContext(): text = self.jsontotextparser(args["data"]) logger.info(text) + def on_package(self, cmd: str, args: dict): + """For custom package handling in subclasses.""" + pass + async def server_loop(ctx: CommonContext, address=None): cached_address = None @@ -396,6 +400,8 @@ async def process_server_cmd(ctx: CommonContext, args: dict): else: logger.debug(f"unknown command {cmd}") + ctx.on_package(cmd, args) + async def console_loop(ctx: CommonContext): import sys @@ -415,4 +421,4 @@ async def console_loop(ctx: CommonContext): if input_text: commandprocessor(input_text) except Exception as e: - logging.exception(e) + logger.exception(e) diff --git a/worlds/factorio/data/mod_template/data-final-fixes.lua b/worlds/factorio/data/mod_template/data-final-fixes.lua index 8fe865f4..81a75ce8 100644 --- a/worlds/factorio/data/mod_template/data-final-fixes.lua +++ b/worlds/factorio/data/mod_template/data-final-fixes.lua @@ -85,6 +85,11 @@ new_tree_copy.unit.count = math.max(1, math.floor(new_tree_copy.unit.count * {{ {%- if (tech_tree_information == 2 or original_tech_name in static_nodes) and item_name in base_tech_table -%} {#- copy Factorio Technology Icon -#} copy_factorio_icon(new_tree_copy, "{{ item_name }}") +{%- if original_tech_name == "rocket-silo" and original_tech_name in static_nodes %} +{%- for ingredient in custom_recipes["rocket-part"].ingredients %} +table.insert(new_tree_copy.effects, {type = "nothing", effect_description = "Ingredient {{ loop.index }}: {{ ingredient }}"}) +{% endfor -%} +{% endif -%} {%- elif (tech_tree_information == 2 or original_tech_name in static_nodes) and item_name in progressive_technology_table -%} copy_factorio_icon(new_tree_copy, "{{ progressive_technology_table[item_name][0] }}") {%- else -%}