Advertisement
pson

SugarCactii.lua

Jul 17th, 2020
1,404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.39 KB | None | 0 0
  1. -- Check if we are in the correct starting location
  2. function checkForStart()
  3.     turtle.select(16)
  4.     return turtle.compareUp() and
  5.         turtle.compareDown()
  6. end
  7.  
  8. function refuelIfNeeded()
  9.     turtle.select(1)
  10.     while turtle.getFuelLevel() < 100 do
  11.         turtle.suckUp(1)
  12.         turtle.refuel(1)
  13.     end
  14. end
  15.  
  16. function forward(n)
  17.     local i = 0
  18.     while i < n do
  19.         if turtle.detect() then
  20.             turtle.dig()
  21.         end
  22.         turtle.forward()
  23.         if turtle.detectDown() then
  24.             turtle.digDown()
  25.         end
  26.         i = i+1
  27.     end
  28. end
  29.  
  30. function dump(i,j)
  31.     while i <= j do
  32.         if turtle.getItemCount(i) > 0 then
  33.             turtle.select(i)
  34.             turtle.dropDown()
  35.         end
  36.         i = i+1
  37.     end
  38.     turtle.select(1)
  39. end
  40.  
  41. function lap()
  42.     if not checkForStart() then
  43.         print "Wrong position"
  44.         return
  45.     end
  46.     refuelIfNeeded()
  47.     turtle.forward()
  48.     turtle.turnLeft()
  49.     forward(32)
  50.     turtle.turnLeft()
  51.     forward(2)
  52.     turtle.turnLeft()
  53.     forward(32)
  54.     turtle.turnLeft()
  55.     turtle.forward()
  56.     dump(1,15)
  57. end
  58.  
  59. while 1+1 == 2 do
  60.     lap()
  61.     sleep(300)
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement