Factorio: correctly display player names with spaces and detect desyncs

This commit is contained in:
Fabian Dill
2021-07-04 15:25:56 +02:00
parent 5943c8975a
commit c669bc3e7f
3 changed files with 24 additions and 6 deletions

View File

@@ -220,14 +220,20 @@ end)
commands.add_command("ap-get-technology", "Grant a technology, used by the Archipelago Client.", function(call)
local force = game.forces["player"]
chunks = {}
for substring in call.parameter:gmatch("%S+") do -- split on " "
table.insert(chunks, substring)
end
chunks = split(call.parameter, "\t")
local tech_name = chunks[1]
local source = chunks[2] or "Archipelago"
local index = chunks[2]
local source = chunks[3] or "Archipelago"
local tech = force.technologies[tech_name]
if tech ~= nil then
if global.index_sync == nil then
global.index_sync = {}
end
if global.index_sync[index] ~= nil and global.index_sync[index] ~= tech then
game.print("Warning: Desync Detected. Duplicate/Missing items may occur.")
end
global.index_sync[index] = tech
if tech.researched ~= true then
game.print({"", "Received [technology=" .. tech.name .. "] from ", source})
game.play_sound({path="utility/research_completed"})