Factorio: Show item source and enable research queue
This commit is contained in:
		
							parent
							
								
									433981fd3d
								
							
						
					
					
						commit
						b7327138f3
					
				| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue