From b7327138f38f70b3d86613a604f343daab99f8aa Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 13 Apr 2021 11:14:05 +0200 Subject: [PATCH] Factorio: Show item source and enable research queue --- FactorioClient.py | 5 +++-- Options.py | 7 ++++++- data/factorio/mod_template/control.lua | 13 +++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/FactorioClient.py b/FactorioClient.py index 38e500be..92125caf 100644 --- a/FactorioClient.py +++ b/FactorioClient.py @@ -146,12 +146,13 @@ async def factorio_server_watcher(ctx: FactorioContext): if ctx.rcon_client: while ctx.send_index < len(ctx.items_received): item_id = ctx.items_received[ctx.send_index].item + player_name = ctx.player_names[ctx.send_index].player if item_id not in lookup_id_to_name: logging.error(f"Cannot send unknown item ID: {item_id}") else: item_name = lookup_id_to_name[item_id] - factorio_server_logger.info(f"Sending {item_name} to Nauvis.") - ctx.rcon_client.send_command(f'/ap-get-technology {item_name}') + factorio_server_logger.info(f"Sending {item_name} to Nauvis from {player_name}.") + ctx.rcon_client.send_command(f'/ap-get-technology {item_name} {player_name}') ctx.send_index += 1 await asyncio.sleep(1) diff --git a/Options.py b/Options.py index 896850a0..f004d394 100644 --- a/Options.py +++ b/Options.py @@ -236,7 +236,8 @@ hollow_knight_skip_options: typing.Dict[str, type(Option)] = { "SHADESKIPS": Toggle, } -hollow_knight_options: typing.Dict[str, type(Option)] = {**hollow_knight_randomize_options, **hollow_knight_skip_options} +hollow_knight_options: typing.Dict[str, type(Option)] = {**hollow_knight_randomize_options, + **hollow_knight_skip_options} class MaxSciencePack(Choice): @@ -264,6 +265,7 @@ class TechCost(Choice): option_insane = 6 default = 3 + class FreeSamples(Choice): option_none = 0 option_single_craft = 1 @@ -271,6 +273,7 @@ class FreeSamples(Choice): option_stack = 3 default = 3 + class TechTreeLayout(Choice): option_single = 0 option_small_diamonds = 1 @@ -279,11 +282,13 @@ class TechTreeLayout(Choice): option_funnel = 4 default = 0 + class Visibility(Choice): option_none = 0 option_sending = 1 default = 0 + factorio_options: typing.Dict[str, type(Option)] = {"max_science_pack": MaxSciencePack, "tech_tree_layout": TechTreeLayout, "tech_cost": TechCost, diff --git a/data/factorio/mod_template/control.lua b/data/factorio/mod_template/control.lua index 011f2330..9c3524f6 100644 --- a/data/factorio/mod_template/control.lua +++ b/data/factorio/mod_template/control.lua @@ -1,4 +1,8 @@ require "lib" +script.on_event(defines.events.on_player_created, function(event) + game.players[event.player_index].force.research_queue_enabled = true +end) + -- for testing script.on_event(defines.events.on_tick, function(event) if event.tick%600 == 0 then @@ -119,12 +123,17 @@ end) commands.add_command("ap-get-technology", "Grant a technology, used by the Archipelago Client.", function(call) local force = game.forces["player"] - local tech_name = call.parameter + chunks = {} + for substring in call.parameter:gmatch("%S+") do -- split on " " + table.insert(chunks, substring) + end + local tech_name = chunks[1] + local source = chunks[2] or "Archipelago" local tech = force.technologies[tech_name] if tech ~= nil then if tech.researched ~= true then tech.researched = true - game.print({"", "Received ", tech.localised_name, " from Archipelago"}) + game.print({"", "Received ", tech.localised_name, " from ", source}) game.play_sound({path="utility/research_completed"}) end else