Fixed nil value error when requesting status.

This commit is contained in:
Harrison Deng 2021-05-03 15:44:31 -05:00
parent 2970b23270
commit 308b6a7fe2

View File

@ -384,10 +384,10 @@ local function listen()
fuel=turtle.getFuelLevel(),
task=(task and task["name"] or "nothing")
}
sendLog(STATUS, "Relative position: " .. textutils.serializeJSON(data["content"][1]["relative_position"]) ..
"\nPosition: " .. (data["content"][1]["position"]["coordinates"] and textutils.serialiseJSON(data["content"][1]["position"]) or "not positioned.") ..
"\nfuel: " .. tostring(data["content"][1]["fuel"]) ..
"\ncurrent task: " .. data["content"][1]["task"], status)
sendLog(STATUS, "Relative position: " .. textutils.serializeJSON(status["relative_position"]) ..
"\nPosition: " .. (status["position"]["coordinates"] and textutils.serialiseJSON(status["position"]) or "not positioned.") ..
"\nfuel: " .. tostring(status["fuel"]) ..
"\ncurrent task: " .. status["task"], status)
elseif data["request"] == POSITION then
locatePosition()
elseif data["request"] == HEADING then