It's nearly 3am, can you tell?

Fix fallback failure: we should check for both 3 and 4 arguments.
This commit is contained in:
Matthew Wilbern 2023-11-11 02:38:40 -07:00 committed by GitHub
parent bb4d1ca3de
commit 135a756e5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -148,8 +148,8 @@ function locate(_nTimeout, _bDebug)
local sSide, sChannel, sReplyChannel, tMessage, nDistance = p1, p2, p3, p4, p5
if sSide == sModemSide and sChannel == CHANNEL_GPS and sReplyChannel == CHANNEL_GPS and nDistance then
-- Received the correct message from the correct modem: use it to determine position
if type(tMessage) == "table" and #tMessage == 4 and tonumber(tMessage[1]) and tonumber(tMessage[2]) and tonumber(tMessage[3]) then
local tFix = { vPosition = vector.new(tMessage[1], tMessage[2], tMessage[3]), nDistance = tonumber(tMessage[4]) and tMessage[4] or nDistance }
if type(tMessage) == "table" and (#tMessage == 3 or #tMessage == 4 and tonumber(tMessage[4])) and tonumber(tMessage[1]) and tonumber(tMessage[2]) and tonumber(tMessage[3]) then
local tFix = { vPosition = vector.new(tMessage[1], tMessage[2], tMessage[3]), nDistance = tonumber(tMessage[4]) or nDistance }
if _bDebug then
print(tFix.nDistance .. " metres from " .. tostring(tFix.vPosition))
end