From d0ba5a96de9b6e59f2c9ba341a95ca36eac70e3e Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Mon, 3 May 2021 14:21:07 -0500 Subject: [PATCH] Fixed incorrect table fields being referenced. --- mineleader.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mineleader.lua b/mineleader.lua index 84fc913..9d838eb 100644 --- a/mineleader.lua +++ b/mineleader.lua @@ -327,10 +327,10 @@ local function listen() local event, side, sendChannel, replyChannel, serialized, distance = os.pullEvent("modem_message") print("Recieved data...") local data = textutils.unserialise(serialized) - if data["token"] == TOKEN and data["recipient"] == UNIT then - print("Got content: " .. data["type"]) + if data["token"] == TOKEN and data["recipient"] == UNIT and data["type"] == REQUEST then + print("Got request: " .. data["request"]) - if data["type"] == LUA_PREFIX then + if data["request"] == LUA_PREFIX then print("Executing: " .. data["content"][0]) local f = loadstring(luaScript) if f ~= nil then @@ -342,7 +342,7 @@ local function listen() else printError("Unable to load lua string.") end - elseif data["type"] == MOVETO then + elseif data["request"] == MOVETO then local x = data["content"][1] local y = data["content"][2] local z = data["content"][3] @@ -355,7 +355,7 @@ local function listen() sendLog(MOVETO, "Using relative coordinates to move.") attemptStartTask(moveTo, vector.new(x,y,z), relHeading, relRightAxis) end - elseif data["type"] == MOVEBY then + elseif data["request"] == MOVEBY then local x = data["content"][1] local y = data["content"][2] local z = data["content"][3] @@ -368,7 +368,7 @@ local function listen() sendLog(MOVEBY, "Using relative coordinates to move.") attemptStartTask(moveBy, vector.new(x,y,z), relHeading, relRightAxis) end - elseif data["type"] == STATUS then + elseif data["request"] == STATUS then status = { relative_position = { coordinates=relativePos, @@ -383,11 +383,11 @@ local function listen() fuel=turtle.getFuelLevel(), } sendLog(STATUS, status) - elseif string.find(content, POSITION) == 1 then + elseif data["request"] == POSITION then locatePosition() - elseif string.find(content, HEADING) == 1 then + elseif data["request"] == HEADING then determineHeading() - elseif string.find(content, QUARRY) == 1 then + elseif data["request"] == QUARRY then end end end