Wieghant

Agribot

Feb 22nd, 2022 (edited)
1,339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. local r = require("robot")
  2. local component = require("component")
  3. local g = component.geolyzer
  4. local slots = r.inventorySize()
  5. local computer = require("computer")
  6. local tty = require("tty")
  7.  
  8. local function harvest()
  9.     r.forward()
  10.     if g.analyze(0).growth == 1 then
  11.         r.swingDown()
  12.     end
  13. end
  14.  
  15. local function harvestLine()
  16.     for i = 1, 36, 1 do
  17.         harvest()
  18.     end
  19. end
  20.  
  21. local function turnAroundLeft()
  22.     r.forward()
  23.     r.turnLeft()
  24.     r.forward()
  25.     r.turnLeft()
  26. end
  27.  
  28. local function turnAroundRight()
  29.     r.forward()
  30.     r.turnRight()
  31.     r.forward()
  32.     r.turnRight()
  33. end
  34.  
  35. local function dropAll()
  36.     for i = 1, slots, 1 do
  37.         r.select(i)
  38.         if r.count == 0 then
  39.             break
  40.         end
  41.         r.dropDown()
  42.     end
  43. end
  44.  
  45. local function harvestPatch()
  46.     harvestLine()
  47.     turnAroundLeft()
  48.     harvestLine()
  49.     turnAroundRight()
  50.     harvestLine()
  51.     turnAroundLeft()
  52.     harvestLine()
  53.     r.forward()
  54.     dropAll()
  55. end
  56.  
  57. local function moveToNextPatch()
  58.     r.turnRight()
  59.     r.forward()
  60.     r.forward()
  61.     r.turnRight()
  62. end
  63.  
  64. harvestPatch()
  65. for i = 1, 5, 1 do
  66.     moveToNextPatch()
  67.     harvestPatch()
  68. end
  69.  
  70. r.turnLeft()
  71. for i = 1, 28, 1 do
  72.     r.forward()
  73. end
  74. r.turnLeft()
  75.  
  76. tty.clear()
  77. computer.shutdown()
Add Comment
Please, Sign In to add comment