rednet.open("right") local mapperComID = 20 local x = nil local y = nil local z = nil local curx, cury, curz, dir function getLocation() returnVal = nil while true do os.clock(10) rednet.send(mapperComID,"Need location") myEvent = {os.pullEvent()} if myEvent[1] == "rednet_message" and myEvent[2] == mapperComID then returnVal = myEvent[3] break end end return returnVal end function getPos() return gps.locate(3) end function getDir() local dir, x, y, z x, y, z = getPos() while not turtle.forward() do while not turtle.up() do turtle.digUp() end end nx, ny, nz = getPos() if (x == nx) then if (nz > z) then dir = 2 else dir = 0 end else if (nx > x) then dir = 3 else dir = 1 end end return dir end function setDir(toDir) while toDir ~= dir do turtle.turnLeft() if dir == 3 then dir = 0 else dir = dir+1 end end end function moveX() distxx = x - curx if (x > curx) then setDir(3) else setDir(1) end distx = math.abs(distx) for i = 1, distx do while not turtle.forward() do while not turtle.up() do turtle.digUp() end end end end function moveZ() distz = z - curz if (z < curz) then setDir(0) else setDir(2) end distz = math.abs(distz) for i = 1, distz do while not turtle.forward() do while not turtle.up() do turtle.digUp() end end end end function moveY() disty = y - cury disty = math.abs(disty) if (y < cury) then for i = 1, disty do while not turtle.down() do turtle.digDown() end end else for i = 1, disty do while not turtle.up() do turtle.digUp() end end end end function goto() dir = getDir() bcurx, bcury, bcurz = gps.locate(3) curx = tonumber(bcurx) cury = tonumber(bcury) curz = tonumber(bcurz) nx = tonumber(x) ny = tonumber(y) nz = tonumber(z) distx = x - curx disty = y - cury distz = z - curz moveX() curx, cury, curz = getPos() moveZ() curx, cury, curz = getPos() moveY() curx, cury, curz = getPos() end while true do if (fs.exists("startup_bak") == false) then x,y,z = getLocation() goto() end shell.run("miner") end
Error: attempt to perform arithmetic __sub on table and number
Can u help me i start already with trying thing like nx, ny,nz etc. but i dont get it. Where is the error?