le_Fish

QuarrySwarmBot

Apr 30th, 2020
899
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.00 KB | None | 0 0
  1. -- Movement
  2. if not fs.exists("movementApi") then
  3.     shell.run("pastebin", "get", "yykL6u8N", "movementApi")
  4. end
  5. os.loadAPI("movementApi")
  6. -- GPS
  7. if not fs.exists("gpsApi") then
  8.     shell.run("pastebin", "get", "gKySQWcG", "gpsApi")
  9. end
  10. os.loadAPI("gpsApi")
  11. -- Quarry
  12. if not fs.exists("digApi") then
  13.     shell.run("pastebin", "get", "Q2RSv5cF", "digApi")
  14. end
  15. os.loadAPI("digApi")
  16.  
  17. print("V0.2.5")
  18.  
  19. local config = {
  20.     homePos = vector.new(0, 0, 0),
  21.     startDir = "s",
  22.     startHeight = 85,
  23.     parkHeight = 85,
  24.     flyHeight = 85,
  25.     masterPc = 0,
  26.     startChunk = {[1] = true, [2] = true},
  27.     currentChunk = {[1] = true, [2] = true},
  28.     quarry = false,
  29.     goingHome = false,
  30.     home = false,
  31.     maxChunks = 128,
  32.     chunks = 0,
  33.     goingMine = true
  34. }
  35. local skips = {}
  36.  
  37. local stopProgram = false
  38. local loopRunning
  39. local turtleMov = movementApi.Movement:new(vector.new(0, 0, 0), "e")
  40. local turtleGPS = gpsApi.BetterGPS:new(vector.new(0, 0, 0), "e")
  41. local turtleDig, xPoint, yPoint
  42.  
  43. -- Set turtleMovment position and direction
  44. turtleGPS:locate(10)
  45. turtleMov.pos = turtleGPS:locate(10)
  46. turtleMov.dir = turtleGPS:getDir()
  47.  
  48. -- Check for enderchest
  49. local data = turtle.getItemDetail(1)
  50. if data == nil or string.find(data.name, "EnderStorage") == false then
  51.     turtle.select(1)
  52.     local success, inspectUp = turtle.inspectUp()
  53.     if success and string.find(inspectUp.name, "EnderStorage") then
  54.         if turtle.getItemCount(1) > 0 then
  55.             turtle.dropUp(turtle.getItemCount(1))
  56.         end
  57.         turtle.digUp()
  58.     else
  59.         print("Put an enderchest in slot 1")
  60.         repeat
  61.             data = turtle.getItemDetail(1)
  62.             sleep(0.2)
  63.         until data ~= nil and string.find(data.name, "EnderStorage")
  64.     end
  65. end
  66. -- open rednet
  67. if peripheral.getType("right") == "modem" then
  68.     rednet.open("right")
  69. elseif peripheral.getType("left") == "modem" then
  70.     rednet.open("left")
  71. else
  72.     error("Couldn't find a modem on my left or right side")
  73. end
  74.  
  75. -- quarry loop with stop loop
  76. function digLoop()
  77.     checkSkips()
  78.     -- if busy with quarry, keep going
  79.     if config.quarry then
  80.         -- Check if bot is in
  81.         runQuarry()
  82.     end
  83.     -- main loop
  84.     while true do
  85.         -- Go to correct Z, X & Y
  86.         if turtleMov.pos.z ~= config.flyHeight then
  87.             turtleMov:goToZ(tonumber(config.flyHeight), 'dig', {'computer'})
  88.         end
  89.         xPoint = config.currentChunk[1] * 16
  90.         yPoint = config.currentChunk[2] * 16
  91.         if config.startDir == "e" then
  92.             yPoint = yPoint + 15
  93.         elseif config.startDir == "n" then
  94.             yPoint = yPoint + 15
  95.             xPoint = xPoint + 15
  96.         elseif config.startDir == "w" then
  97.             xPoint = xPoint + 15
  98.         end
  99.  
  100.         if turtleMov.pos.x ~= xPoint then
  101.             turtleMov:goToX(xPoint, 'dig', {'computer'})
  102.         end
  103.         if turtleMov.pos.y ~= yPoint then
  104.             turtleMov:goToY(yPoint, 'dig', {'computer'})
  105.         end
  106.         if turtleMov.pos.z ~= config.startHeight then
  107.             turtleMov:goToZ(tonumber(config.startHeight), 'dig', {'computer'})
  108.         end
  109.         if config.startDir == "s" then
  110.             turtleMov:face("e")
  111.         elseif config.startDir == "w" then
  112.             turtleMov:face("s")
  113.         elseif config.startDir == "n" then
  114.             turtleMov:face("w")
  115.         elseif config.startDir == "e" then
  116.             turtleMov:face("n")
  117.         end
  118.         config.chunks = config.chunks + 1
  119.         if config.maxChunks + 1 == config.chunks then
  120.             goHome()
  121.             break
  122.         end
  123.         config.quarry = true
  124.         saveConfig()
  125.         runQuarry()
  126.     end
  127. end
  128. function stopLoop()
  129.     while not stopProgram do
  130.         sleep(1)
  131.     end
  132. end
  133.  
  134. -- Main quarry loop & rednet loop
  135. function mainLoop()
  136.     while true do
  137.         if not stopProgram then
  138.             loopRunning = true
  139.             parallel.waitForAny(digLoop, stopLoop)
  140.             print("digLoop stopped")
  141.             loopRunning = false
  142.         end
  143.         sleep(1)
  144.     end
  145. end
  146.  
  147. function pingLoop()
  148.     while true do
  149.         sleep(600)
  150.         sendPing()
  151.     end
  152. end
  153.  
  154. local rednetMessage = {}
  155.  
  156. function stopRednetLoopHome()
  157.     print("stopRednetLoopHome")
  158.     local stopRednetHomeMessage = {}
  159.     local message = ""
  160.     while 1 do
  161.         stopRednetHomeMessage = {rednet.receive("swarmbot", 10)}
  162.         if next(stopRednetHomeMessage) ~= nil then
  163.             message = stopRednetHomeMessage[2]
  164.             if message == "pause" then
  165.                 rednetMessage = stopRednetHomeMessage
  166.                 print("stopping a second rednet loop to pause")
  167.                 return
  168.             elseif message == "mine" then
  169.                 rednetMessage = stopRednetHomeMessage
  170.                 print("stopping a second rednet loop to mine")
  171.                 return
  172.             end
  173.         else
  174.             sleep(0.1)
  175.         end
  176.     end
  177. end
  178. function stopRednetLoopMine()
  179.     print("stopRednetLoopMine")
  180.     local stopRednetMineMessage = {}
  181.     local message = ""
  182.     while 1 do
  183.         stopRednetMineMessage = {rednet.receive("swarmbot", 10)}
  184.         if next(stopRednetMineMessage) ~= nil then
  185.             message = stopRednetMineMessage[2]
  186.             if message == "pause" then
  187.                 rednetMessage = stopRednetMineMessage
  188.                 print("stopping a second rednet loop to pause")
  189.                 return
  190.             elseif message == "home" then
  191.                 rednetMessage = stopRednetMineMessage
  192.                 print("stopping a second rednet loop to mine")
  193.                 return
  194.             end
  195.         else
  196.             sleep(0.1)
  197.         end
  198.     end
  199. end
  200. function rednetLoop()
  201.     print("rednetloop live")
  202.     local paused = false;
  203.     while 1 do
  204.         if next(rednetMessage) == nil then
  205.             rednetMessage = {rednet.receive("swarmbot", 10)}
  206.         end
  207.         local response = {}
  208.         if next(rednetMessage) ~= nil then
  209.             response.senderID = rednetMessage[1]
  210.             response.message = rednetMessage[2]
  211.             rednetMessage = {}
  212.             print("received: " .. textutils.serialise(response.message))
  213.             if response.message == "pause" and not paused then
  214.                 if not stopProgram then
  215.                     stopProgram = true
  216.                     paused = true
  217.                     sleep(2.5)
  218.                     paused = false
  219.                 end
  220.             elseif response.message == "home" then
  221.                 if not config.goingHome then
  222.                     config.goingHome = true
  223.                     stopProgram = true
  224.                     sleep(2.5)
  225.                     turtleGPS:locate(10)
  226.                     turtleMov.pos = turtleGPS:locate(10)
  227.                     if turtleMov.pos ~= config.homePos then
  228.                         turtleMov.dir = turtleGPS:getDir()
  229.                         saveCurrentPos()
  230.                         saveConfig()
  231.                         parallel.waitForAny(stopRednetLoopHome, goHome)
  232.                         print("either done with goHome or stopped")
  233.                     end
  234.                 end
  235.             elseif response.message == "mine" then
  236.                 if not loopRunning and not goingMine then
  237.                     config.goingMine = true
  238.                     config.home = false
  239.                     saveConfig()
  240.                     if fs.exists("data/swarm/lastPos") then
  241.                         config.goingHome = false
  242.                         saveConfig()
  243.                         parallel.waitForAny(stopRednetLoopMine, goLastPos)
  244.                         print("either done with goLastPos or stopped")
  245.                     end
  246.                     stopProgram = false
  247.                     config.goingMine = false
  248.                     saveConfig()
  249.                 end
  250.             elseif response.message == "ping" then
  251.                 sendPing()
  252.             elseif string.match(response.message, "skip") then
  253.                 local skipChunk = string.gsub(response.message, "skip", "")
  254.                 skipChunk = string.gsub(skipChunk, " ", "")
  255.                 local results = {}
  256.                 for match in string.gmatch(skipChunk, "[^,]+") do
  257.                     results[#results + 1] = tonumber(match)
  258.                 end
  259.                 local dontSave = false
  260.                 for k,v in pairs(skips) do
  261.                     if v[1] == results[1] and v[2] == results[2] then
  262.                         dontSave = true
  263.                         break
  264.                     end
  265.                 end
  266.                 if not dontSave then
  267.                     print("Saving skip")    
  268.                     skips[#skips + 1] = results
  269.                     saveSkip()
  270.                     if config.currentChunk[1] == results[1] and config.currentChunk[2] == results[2] then
  271.                         if not stopProgram then
  272.                             stopProgram = true
  273.                             sleep(2.5)
  274.                         end
  275.                         config.quarry = false
  276.                         stopProgram = false
  277.                         turtleMov.pos = turtleGPS:locate(10)
  278.                         turtleMov.dir = turtleGPS:getDir()
  279.                     end
  280.                     saveConfig()
  281.                 end
  282.             elseif response.message == "update" then
  283.                 sleep(10)
  284.                 shell.run("rm","digApi")
  285.                 shell.run("rm","gpsApi")
  286.                 shell.run("rm","movementApi")
  287.                 shell.run("rm","swarmBot")
  288.                 os.reboot()
  289.             end
  290.         end
  291.         sleep(0.5)
  292.         print('listening for rednet')
  293.     end
  294. end
  295.  
  296. -- Main functions
  297. function register()
  298.     if not rednet.isOpen("left") and not rednet.isOpen("right") then
  299.         if peripheral.getType("right") == "modem" or peripheral.getType("left") == "modem" then
  300.             rednet.open("left")
  301.             rednet.open("right")
  302.         else
  303.             error("SwarmBot register couldn't open rednet")
  304.         end
  305.     end
  306.     rednet.broadcast("register", "swarmbotRegisterRequest")
  307.  
  308.     local rawResponse = {rednet.receive("swarmbotRegister", 600)}
  309.     local response = {}
  310.     if next(rawResponse) == nil then
  311.         error("SwarmBot register waited to long for a response")
  312.     else
  313.         rednet.send(rawResponse[1], "OK", "swarmbotRegister")
  314.         if type(rawResponse[1]) ~= "number" then
  315.             error("SwarmBot register response[1] expects to be a number, currently is " .. type(rawResponse[1]))
  316.         elseif type(rawResponse[2]) ~= "table" then
  317.             error("SwarmBot register response[2] expects to be a table, currently is " .. type(rawResponse[2]))
  318.         end
  319.         response.senderID = rawResponse[1]
  320.         response.chunk = rawResponse[2][1]
  321.         response.startHeight = rawResponse[2][2]
  322.         response.parkHeight = rawResponse[2][3]
  323.         response.flyHeight = rawResponse[2][4]
  324.         response.homePos = rawResponse[2][5]
  325.         response.startDir = rawResponse[2][6]
  326.         response.maxChunks = rawResponse[2][7]
  327.         response.skips = rawResponse[2][8]
  328.         return response
  329.     end
  330. end
  331. function runQuarry()
  332.     local x = config.currentChunk[1] * 16
  333.     local y = config.currentChunk[2] * 16
  334.  
  335.     if turtleMov.pos.x >= x and turtleMov.pos.x <= x + 15 and turtleMov.pos.y >= y and turtleMov.pos.y <= y + 15 then
  336.         sendPing()
  337.         turtleDig = digApi.Dig:new(turtleMov.pos, turtleMov.dir, config.startHeight)
  338.         turtleDig:quarryChunk(turtleMov.pos, turtleMov.dir, config.startDir)
  339.         updateChunk()
  340.         turtleGPS:locate(10)
  341.         turtleMov.pos = turtleGPS:locate(10)
  342.         turtleMov.dir = turtleGPS:getDir()
  343.         saveConfig()
  344.         config.quarry = false
  345.     else
  346.         if config.startDir == "s" or config.startDir == "n" then
  347.             turtleMov:goToX(x, "dig", {'computer'})
  348.             turtleMov:goToY(y, "dig", {'computer'})
  349.         else
  350.             turtleMov:goToY(y, "dig", {'computer'})
  351.             turtleMov:goToX(x, "dig", {'computer'})
  352.         end
  353.         runQuarry()
  354.     end
  355. end
  356.  
  357. function updateChunk()
  358.     print("Updating chunk")
  359.     print(textutils.serialise(config.currentChunk))
  360.     if config.startDir == "s" then
  361.         config.currentChunk[1] = config.currentChunk[1] + 1
  362.     elseif config.startDir == "w" then
  363.         config.currentChunk[2] = config.currentChunk[2] + 1
  364.     elseif config.startDir == "n" then
  365.         config.currentChunk[1] = config.currentChunk[1] - 1
  366.     elseif config.startDir == "e" then
  367.         config.currentChunk[2] = config.currentChunk[2] - 1
  368.     else
  369.         error("config.startDir is not n, e, s or w, currently is ", config.startDir)
  370.     end
  371.     print("to")
  372.     print(textutils.serialise(config.currentChunk))
  373.     saveConfig()
  374. end
  375.  
  376. function checkSkips()
  377.     if skips ~= nil and next(skips) ~= nil then
  378.         for k,v in pairs(skips) do
  379.             if config.currentChunk[1] == v[1] and config.currentChunk[2] == v[2] then
  380.                 updateChunk()
  381.                 break
  382.             end
  383.         end
  384.     end
  385. end
  386. -- Functions used by rednet
  387. function goHome()
  388.     print("go home")
  389.  
  390.     config.goingHome = true
  391.     sendPing()
  392.     saveConfig()
  393.     if not config.home then
  394.         turtleMov:goToZ(config.flyHeight, 'dig', {'computer'})
  395.         if config.startDir == "s" or config.startDir == "n" then
  396.             turtleMov:goToX(config.homePos, 'dig', {'computer'})
  397.             turtleMov:goToY(config.homePos, 'dig', {'computer'})
  398.         else
  399.             turtleMov:goToY(config.homePos, 'dig', {'computer'})
  400.             turtleMov:goToX(config.homePos, 'dig', {'computer'})
  401.         end
  402.         turtleMov:goToZ(config.homePos, 'dig', {'computer'})
  403.         turtleMov:face(config.startDir)
  404.         config.goingHome = false
  405.         config.home = true
  406.     end
  407.     sendPing()
  408.     saveConfig()
  409. end
  410. function goLastPos()
  411.     local lastPost = vector.new()
  412.     local lastDir
  413.     local file = fs.open("data/swarm/lastPos", "r")
  414.     lastPost.x = tonumber(file.readLine())
  415.     lastPost.y = tonumber(file.readLine())
  416.     lastPost.z = tonumber(file.readLine())
  417.     lastDir = file.readLine()
  418.     file.close()
  419.     if lastPost.x ~= nil and lastPost.y ~= nil and lastPost.z ~= nil and lastDir ~= nil then
  420.         turtleMov:goToZ(config.flyHeight, 'dig', {'computer'})
  421.         if config.startDir == "s" or config.startDir == "n" then
  422.             turtleMov:goToY(lastPost.y, 'dig', {'computer'})
  423.             turtleMov:goToX(lastPost.x, 'dig', {'computer'})
  424.         else
  425.             turtleMov:goToX(lastPost.x, 'dig', {'computer'})
  426.             turtleMov:goToY(lastPost.y, 'dig', {'computer'})
  427.         end
  428.         turtleMov:goToZ(lastPost.z, 'dig', {'computer'})
  429.         turtleMov:face(lastDir)
  430.     end
  431.     fs.delete("data/swarm/lastPos")
  432.     config.home = false
  433.     config.goingHome = false
  434.     saveConfig()
  435. end
  436.  
  437. -- Save functions
  438. function saveConfig()
  439.     local file = fs.open("data/swarm/config", "w")
  440.     -- Make a hard copy..
  441.     local hardCopy = copy(config)
  442.     hardCopy.startChunk = textutils.serialise(hardCopy.startChunk)
  443.     hardCopy.currentChunk = textutils.serialise(hardCopy.currentChunk)
  444.     file.writeLine(textutils.serialize(hardCopy))
  445.     file.close()
  446. end
  447. function saveSkip()
  448.     local file = fs.open("data/swarm/skips", "w")
  449.     -- Make a hard copy..
  450.     local hardCopy = copy(skips)
  451.     file.writeLine(textutils.serialize(skips))
  452.     file.close()
  453. end
  454. function saveCurrentPos()
  455.     local file = fs.open("data/swarm/lastPos", "w")
  456.     turtleMov.pos = turtleGPS:locate(10)
  457.     turtleMov.dir = turtleGPS:getDir()
  458.     file.writeLine(turtleMov.pos.x)
  459.     file.writeLine(turtleMov.pos.y)
  460.     file.writeLine(turtleMov.pos.z)
  461.     file.writeLine(turtleMov.dir)
  462.     file.close()
  463. end
  464.  
  465. -- hardcopy a obj.
  466. function copy(obj)
  467.     if type(obj) ~= "table" then
  468.         return obj
  469.     end
  470.     local res = {}
  471.     for k, v in pairs(obj) do
  472.         res[copy(k)] = copy(v)
  473.     end
  474.     return res
  475. end
  476.  
  477. function sendPing()
  478.     local pingResponse = {}
  479.  
  480.     turtleMov.pos = turtleGPS:locate(10)
  481.  
  482.     if not turtleMov.pos.x then
  483.         tryHome()
  484.     end
  485.     if not rednet.isOpen("left") and not rednet.isOpen("right") then
  486.         if peripheral.getType("right") == "modem" then
  487.             rednet.open("right")
  488.         elseif peripheral.getType("left") == "modem" then
  489.             rednet.open("left")
  490.         end
  491.     end
  492.  
  493.     if config.goingHome then
  494.         rednet.send(config.masterPc, "Homing", "swarmbotPing")
  495.     elseif config.home then
  496.         rednet.send(config.masterPc, "Home", "swarmbotPing")
  497.     elseif not config.goingHome and stopProgram then
  498.         rednet.send(config.masterPc, "Pause", "swarmbotPing")
  499.     elseif not stopProgram then
  500.         rednet.send(config.masterPc, turtleGPS:locate(10), "swarmbotPing")
  501.     end
  502.  
  503.     local done = false
  504.     local tries = 0
  505.     while not done do
  506.         pingResponse = {rednet.receive("swarmbotReceived", 5)}
  507.         if next(pingResponse) ~= nil and tonumber(pingResponse[1]) == tonumber(config.masterPc) then
  508.             done = true
  509.         else
  510.             tries = tries + 1
  511.             if config.goingHome then
  512.                 rednet.send(config.masterPc, "Homing", "swarmbotPing")
  513.             elseif config.home then
  514.                 rednet.send(config.masterPc, "Home", "swarmbotPing")
  515.             elseif not config.goingHome and stopProgram then
  516.                 rednet.send(config.masterPc, "Pause", "swarmbotPing")
  517.             elseif not stopProgram then
  518.                 rednet.send(config.masterPc, turtleGPS:locate(10), "swarmbotPing")
  519.             end
  520.         end
  521.         if tries == 50 then
  522.             if config.home == false then
  523.                 stopProgram = true
  524.                 turtleMov.pos = turtleGPS:locate(10)
  525.                 turtleMov.dir = turtleGPS:getDir()
  526.                 saveCurrentPos()
  527.                 parallel.waitForAny(stopRednetLoopHome, goHome)
  528.             end
  529.             done = true
  530.         end
  531.         sleep(0.5)
  532.     end
  533. end
  534.  
  535. -- If no GPS was found functions
  536. function saveTryHomeData()
  537.     local file = fs.open("data/swarm/config", "w")
  538.     file.writeLine(textutils.serialize(homeData))
  539.     file.close()
  540. end
  541. function checkGps()
  542.     turtleMov.pos = turtleGPS:locate(10)
  543.  
  544.     if turtleMov.pos.x then
  545.         turtleMov.dir = turtleGPS:getDir()
  546.         return true
  547.     end
  548.     return false
  549. end
  550. function tryHome()
  551.     turtle.turnLeft()
  552.     turtle.turnLeft()
  553.     local homeData = {
  554.         forward = 0,
  555.         up = 0,
  556.     }
  557.     if not fs.exists("data/swarm/tryHome") then
  558.         saveTryHomeData()
  559.     else
  560.         local file = fs.open("data/swarm/config", "r")
  561.         local data = file.readAll()
  562.         file.close()
  563.         local homeData = textutils.unserialize(data)
  564.     end
  565.  
  566.     while true do
  567.         repeat
  568.             if turtle.forward() then
  569.                 homeData.forward = homeData.forward + 1
  570.                 saveTryHomeData()
  571.             else
  572.                 if turtle.up() then
  573.                     homeData.up = homeData.up + 1
  574.                     saveTryHomeData()
  575.                 else
  576.                     turtle.digUp()
  577.                 end
  578.             end
  579.             if checkGps() then
  580.                 goHome()
  581.                 break
  582.             end
  583.         until homeData.forward == 100
  584.  
  585.         if not config.goingHome then
  586.             repeat
  587.                 if turtle.back() then
  588.                         homeData.forward = homeData.forward - 1
  589.                         saveTryHomeData()
  590.                 else
  591.                     if turtle.up() then
  592.                         homeData.up = homeData.up + 1
  593.                         saveTryHomeData()
  594.                     else
  595.                         turtle.digUp()
  596.                     end
  597.                 end
  598.             until homeData.forward == 0
  599.             repeat
  600.                 turtle.down()
  601.                 saveTryHomeData()
  602.                 homeData.up = homeData.up - 1
  603.             until homeData.up == 0
  604.             turtle.turnLeft()
  605.         end
  606.         sleep(1)
  607.     end
  608.  
  609. end
  610.  
  611. -- Check for config data
  612. if fs.exists("data/swarm/config") then
  613.     local file = fs.open("data/swarm/config", "r")
  614.     local data = file.readAll()
  615.     file.close()
  616.     local configLines = textutils.unserialize(data)
  617.     configLines.startChunk = textutils.unserialize(configLines.startChunk)
  618.     configLines.currentChunk = textutils.unserialize(configLines.currentChunk)
  619.     config = configLines
  620. else
  621.     -- save data
  622.     local registerInfo = register()
  623.     config.masterPc = registerInfo.senderID
  624.     config.startChunk = copy(registerInfo.chunk)
  625.     config.currentChunk = copy(registerInfo.chunk)
  626.     config.startHeight = registerInfo.startHeight
  627.     config.parkHeight = registerInfo.parkHeight
  628.     config.flyHeight = registerInfo.flyHeight
  629.     config.homePos = registerInfo.homePos
  630.     config.startDir = registerInfo.startDir
  631.     config.maxChunks = registerInfo.maxChunks
  632.     skips = registerInfo.skips
  633.     os.setComputerLabel("swarmBot_" .. os.getComputerID())
  634.     saveConfig()
  635.     saveSkip()
  636. end
  637. if fs.exists("data/swarm/skips") then
  638.     local file = fs.open("data/swarm/skips", "r")
  639.     local data = file.readAll()
  640.     file.close()
  641.     skips = textutils.unserialize(data)
  642. end
  643. -- program
  644. if config.goingHome then
  645.     stopProgram = true
  646.     parallel.waitForAny(stopRednetLoopHome, goHome)
  647. elseif config.home then
  648.     stopProgram = true
  649. elseif fs.exists("data/swarm/lastPos") then
  650.     parallel.waitForAny(stopRednetLoopMine, goLastPos)
  651. end
  652.  
  653. while true do
  654.     print("Main loop started, listening for mainloop, rednetloop and pingloop")
  655.     parallel.waitForAll(mainLoop, rednetLoop, pingLoop)
  656.     turtleGPS:locate(10)
  657.     turtleMov.pos = turtleGPS:locate(10)
  658.     turtleMov.dir = turtleGPS:getDir()
  659.     sleep(1)
  660. end
Add Comment
Please, Sign In to add comment