diff --git a/FactorioClient.py b/FactorioClient.py index d1b32b67..cfb59528 100644 --- a/FactorioClient.py +++ b/FactorioClient.py @@ -109,6 +109,12 @@ class FactorioContext(CommonContext): self.rcon_client.send_command(f"/ap-print [font=default-large-bold]Archipelago:[/font] " f"{text}") + def on_package(self, cmd: str, args: dict): + if cmd == "Connected": + # catch up sync anything that is already cleared. + for tech in args["checked_locations"]: + item_name = f"ap-{tech}-" + self.rcon_client.send_command(f'/ap-get-technology {item_name}\t-1') async def game_watcher(ctx: FactorioContext): bridge_logger = logging.getLogger("FactorioWatcher") diff --git a/worlds/factorio/data/mod_template/control.lua b/worlds/factorio/data/mod_template/control.lua index 57a9074a..80d344e0 100644 --- a/worlds/factorio/data/mod_template/control.lua +++ b/worlds/factorio/data/mod_template/control.lua @@ -373,7 +373,15 @@ commands.add_command("ap-get-technology", "Grant a technology, used by the Archi local item_name = chunks[1] local index = chunks[2] local source = chunks[3] or "Archipelago" - if progressive_technologies[item_name] ~= nil then + if index == -1 then -- for coop sync and restoring from an older savegame + tech = force.technologies[item_name] + if tech.researched ~= true then + game.print({"", "Received [technology=" .. tech.name .. "] as it is already checked.") + game.play_sound({path="utility/research_completed"}) + tech.researched = true + return + end + elif progressive_technologies[item_name] ~= nil then if global.index_sync[index] == nil then -- not yet received prog item global.index_sync[index] = item_name local tech_stack = progressive_technologies[item_name]