From 884dece54cb251376aacc71ca77984dd3f2cd818 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 27 Jul 2021 14:59:16 +0200 Subject: [PATCH] Factorio: move prints from /sc (silent command) to /ap-print, to prevent two warnings getting printed by Factorio --- FactorioClient.py | 12 +++++------- data/factorio/mod_template/control.lua | 3 +++ worlds/factorio/__init__.py | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/FactorioClient.py b/FactorioClient.py index bf7d8ca0..224ecdae 100644 --- a/FactorioClient.py +++ b/FactorioClient.py @@ -185,8 +185,8 @@ class FactorioContext(CommonContext): logger.info(args["text"]) if self.rcon_client: cleaned_text = args['text'].replace('"', '') - self.rcon_client.send_command(f"/sc game.print(\"[font=default-large-bold]Archipelago:[/font] " - f"{cleaned_text}\")") + self.rcon_client.send_command(f"/ap-print [font=default-large-bold]Archipelago:[/font] " + f"{cleaned_text}") def on_print_json(self, args: dict): text = self.raw_json_text_parser(copy.deepcopy(args["data"])) @@ -194,8 +194,8 @@ class FactorioContext(CommonContext): if self.rcon_client: text = self.factorio_json_text_parser(args["data"]) cleaned_text = text.replace('"', '') - self.rcon_client.send_command(f"/sc game.print(\"[font=default-large-bold]Archipelago:[/font] " - f"{cleaned_text}\")") + self.rcon_client.send_command(f"/ap-print [font=default-large-bold]Archipelago:[/font] " + f"{cleaned_text}") @property def savegame_name(self) -> str: @@ -280,11 +280,9 @@ async def factorio_server_watcher(ctx: FactorioContext): factorio_server_logger.info(msg) if not ctx.rcon_client and "Starting RCON interface at IP ADDR:" in msg: ctx.rcon_client = factorio_rcon.RCONClient("localhost", rcon_port, rcon_password) - # trigger lua interface confirmation - ctx.rcon_client.send_command("/sc game.print('Starting Archipelago Bridge')") - ctx.rcon_client.send_command("/sc game.print('Starting Archipelago Bridge')") if not ctx.awaiting_bridge and "Archipelago Bridge Data available for game tick " in msg: ctx.awaiting_bridge = True + if ctx.rcon_client: while ctx.send_index < len(ctx.items_received): transfer_item: NetworkItem = ctx.items_received[ctx.send_index] diff --git a/data/factorio/mod_template/control.lua b/data/factorio/mod_template/control.lua index a6a46705..542cc162 100644 --- a/data/factorio/mod_template/control.lua +++ b/data/factorio/mod_template/control.lua @@ -217,6 +217,9 @@ commands.add_command("ap-sync", "Used by the Archipelago client to get progress rcon.print(game.table_to_json({["slot_name"] = SLOT_NAME, ["seed_name"] = SEED_NAME, ["info"] = data_collection})) end) +commands.add_command("ap-print", "Used by the Archipelago client to print messages", function (call) + game.print(call.parameter) +end) commands.add_command("ap-get-technology", "Grant a technology, used by the Archipelago Client.", function(call) if global.index_sync == nil then diff --git a/worlds/factorio/__init__.py b/worlds/factorio/__init__.py index fce638a0..512a7317 100644 --- a/worlds/factorio/__init__.py +++ b/worlds/factorio/__init__.py @@ -118,7 +118,7 @@ class Factorio(World): return super(Factorio, self).collect(state, item) def get_required_client_version(self) -> tuple: - return max((0, 1, 5), super(Factorio, self).get_required_client_version()) + return max((0, 1, 6), super(Factorio, self).get_required_client_version()) options = factorio_options