gghf

tryForwards

Jul 14th, 2022 (edited)
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. -- imports
  2. local rS = require("returnSupplies")
  3. local cl = require("collect")
  4. local dR = require("doRefuel")
  5.  
  6. -- definition
  7. local function tryForwards()
  8.     if not dR.doRefuel() then
  9.         print("Not enough Fuel")
  10.         rS.returnSupplies()
  11.     end
  12.  
  13.     while not turtle.forward() do
  14.         if turtle.detect() then
  15.             if turtle.dig() then
  16.                 if not cl.collect() then
  17.                     rS.returnSupplies()
  18.                 end
  19.             else
  20.                 return false
  21.             end
  22.         elseif turtle.attack() then
  23.             if not cl.collect() then
  24.                 rS.returnSupplies()
  25.             end
  26.         else
  27.             sleep(0.5)
  28.         end
  29.     end
  30.  
  31.     xPos = xPos + xDir
  32.     zPos = zPos + zDir
  33.     return true
  34. end
  35.  
  36. -- export
  37. return { tryForwards = tryForwards }
Add Comment
Please, Sign In to add comment