Factorio: Fix ap-get-technology nil value crashes (#3517)

This commit is contained in:
CaitSith2 2024-07-28 11:57:10 -07:00 committed by GitHub
parent 67f329b96f
commit ab0903679c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -660,11 +660,18 @@ commands.add_command("ap-get-technology", "Grant a technology, used by the Archi
end
local tech
local force = game.forces["player"]
if call.parameter == nil then
game.print("ap-get-technology is only to be used by the Archipelago Factorio Client")
return
end
chunks = split(call.parameter, "\t")
local item_name = chunks[1]
local index = chunks[2]
local source = chunks[3] or "Archipelago"
if index == -1 then -- for coop sync and restoring from an older savegame
if index == nil then
game.print("ap-get-technology is only to be used by the Archipelago Factorio Client")
return
elseif 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."})