ownown

run.lua

Jan 30th, 2022
788
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. require "robot"
  2.  
  3. Z = 0
  4.  
  5. MINING_FLOOR = -64
  6.  
  7. ROBOT = Robot.new(0,0,Z)
  8.  
  9. DISTANCE_DOWN = 0 - Z - MINING_FLOOR
  10.  
  11. ROBOT.checkInventory()
  12.  
  13. if turtle.getFuelLevel() < 1 and not ROBOT.refuel() then
  14.     print("No fuel")
  15. end
  16.  
  17. ROBOT.downMany(DISTANCE_DOWN)
  18.  
  19. ROBOT.forwardMany(64, true)
  20.  
  21. X,Y,Z,O = ROBOT.getLocation()
  22. while turtle.getFuelLevel() < (math.abs(X) + math.abs(Y) + math.abs(Z) + BUFFER) do
  23.     ROBOT.left()
  24.     ROBOT.forwardOne(true)
  25.     ROBOT.left()
  26.  
  27.     local StepsForward = math.abs(ROBOT.getForwardCoordinate())
  28.     ROBOT.forwardMany(StepsForward, true)
  29.  
  30.  
  31.     BUFFER = 100
  32.     X,Y,Z,O = ROBOT.getLocation()
  33. end
  34.  
  35. if X < 0 then
  36.     ROBOT.turnTo(1)
  37.     ROBOT.forwardMany(math.abs(X))
  38. end
  39.  
  40. if X > 0 then
  41.     ROBOT.turnTo(3)
  42.     ROBOT.forwardMany(math.abs(X))
  43. end
  44.  
  45. if Y < 0 then
  46.     ROBOT.turnTo(2)
  47.     ROBOT.forwardMany(math.abs(Y))
  48. end
  49.  
  50. if Y > 0 then
  51.     ROBOT.turnTo(4)
  52.     ROBOT.forwardMany(math.abs(Y))
  53. end
  54.  
  55. X,Y,Z,O = ROBOT.getLocation()
  56.  
  57. if X ~= 0 then
  58.     print("Not at X=0")
  59. end
  60.  
  61. if Y ~= 0 then
  62.     print("Not at Y=0")
  63. end
  64.  
  65. ROBOT.upMany(math.abs(Z))
  66.  
Advertisement
Add Comment
Please, Sign In to add comment