Advertisement
RabaGhast

BerryTurtle

Nov 2nd, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. row = 0
  2.  
  3. function switch()
  4.   print("Met a wall, switching row")
  5.   if row % 2 == 0 then
  6.     turtle.turnRight()
  7.     turtle.forward()
  8.     turtle.turnRight()
  9.   else
  10.     turtle.turnLeft()
  11.     turtle.forward()
  12.     turtle.turnLeft()
  13.   end
  14.   row = row + 1
  15. end
  16.  
  17. function move()
  18.   turtle.forward()
  19.   local success, data = turtle.inspectDown()
  20.   if success then
  21.     if data.name == "JABBA:barrel" then
  22.       unload()
  23.       return true
  24.     elseif not data.name == "TConstruct:ore.berries.two" then
  25.       turtle.back()
  26.       switch()
  27.       return false
  28.     end
  29.   end
  30. end
  31.  
  32. function harvest()
  33.   turtle.attackUp()
  34.   turtle.attackDown()
  35. end
  36.  
  37. function unload()
  38.   for i = 1,16 do
  39.     turtle.select(i)
  40.     turtle.dropDown()
  41.   end
  42.   if row % 2 == 0 then
  43.     turtle.turnRight()
  44.     turtle.turnRight()
  45.   end
  46.   row = 0
  47. end
  48.  
  49. ---------Main-----------
  50.  
  51. while true do
  52.  if move() then
  53.    sleep(st)
  54.  end
  55.   harvest()
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement