Advertisement
CelticCoder

turtleGetLava

Nov 15th, 2023 (edited)
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.64 KB | None | 0 0
  1. os.loadAPI("turtleChest.lua")
  2. os.loadAPI("setNorth.lua")
  3. os.loadAPI("turtleToCords.lua")
  4. os.loadAPI("userInput.lua")
  5.  
  6. function userPrompt(length, width)
  7.     total = length * width
  8.     print(total .. " Buckets Needed")
  9.     userInput.getUserInput("Press Anything to Continue")
  10. end
  11.  
  12. -- Get the dimensions
  13. function input(newWidth, newLength, newDepth)
  14.     width = newWidth
  15.     length = newLength
  16.     depth = newDepth
  17. end
  18.  
  19. function bucketCheck(x, z, sdirection, bucket)
  20.     bucket = bucket + 1
  21.     if bucket == 16 then
  22.         toRefuel(x, z, sdirection)
  23.         bucket = 0
  24.     end
  25.     return bucket
  26. end
  27.  
  28. function toRefuel(x, z, sdirection)
  29.     cdirection = setNorth.getDirection()
  30.     cx, cy, cz = gps.locate()
  31.     turtleToCords.twoDMove(x, z, cx, cz)
  32.     --face chests
  33.     setNorth.lookNorth()
  34.     sdirection = setNorth.oppDirection(sdirection)
  35.     setNorth.setDirection(sdirection)
  36.     turtle.forward()
  37.     --look at chest on right and middle chests to deposit
  38.     turtle.turnRight()
  39.     turtleChest.insertAll()
  40.     turtle.turnLeft()
  41.     turtleChest.insertAll()
  42.     --look at chest on left and take buckets
  43.     turtle.turnLeft()
  44.     turtle.suck(16)
  45.     turtle.turnLeft()
  46.     turtle.forward()
  47.     --move back to previous position when was working and faces same direction
  48.     turtleToCords.twoDMove(cx, cz,x, z)
  49.     setNorth.lookNorth()
  50.     setNorth.setDirection(cdirection)
  51. end
  52.  
  53. function toStart(x, z, sdirection)
  54.     --get current direction of turtle mid work
  55.     cdirection = setNorth.getDirection()
  56.     cx, cy, cz = gps.locate()
  57.     turtleToCords.twoDMove(x, z, cx, cz)
  58.     setNorth.lookNorth()
  59.     sdirection = setNorth.oppDirection(sdirection)
  60.     setNorth.setDirection(sdirection)
  61.     turtle.forward()
  62.     turtle.turnRight()
  63.     turtleChest.insertAll(1)
  64.     turtle.turnLeft()
  65.     turtleChest.insertAll(1)
  66.     turtle.turnLeft()
  67.     turtle.suck(16)
  68.     turtle.turnLeft()
  69. end
  70.  
  71. function collectLevel(length, width)
  72.     width = width - 1
  73.     bucket = 0
  74.     turtle.forward()
  75.     sdirection = setNorth.getDirection()
  76.     x, y, z = gps.locate()
  77.     for i = 1, length do
  78.         for j = 1, width do
  79.             turtle.placeDown()
  80.             bucket = bucketCheck(x, z, sdirection, bucket)
  81.             turtle.forward()
  82.         end
  83.         if i < length then
  84.             if i % 2 == 1 then
  85.                 turtle.placeDown()
  86.                 bucket = bucketCheck(x, z, sdirection, bucket)
  87.                 turtle.turnRight()
  88.                 turtle.forward()
  89.                 turtle.turnRight()
  90.             else
  91.                 turtle.placeDown()
  92.                 bucket = bucketCheck(x, z, sdirection, bucket)
  93.                 turtle.turnLeft()
  94.                 turtle.forward()
  95.                 turtle.turnLeft()
  96.             end
  97.         end
  98.     end
  99.     turtle.placeDown()
  100.     toStart(x, z, sdirection)
  101. end
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement