Advertisement
Guest User

bogcube.lua

a guest
Oct 9th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. component = require("component")
  2. sides = require("sides")
  3. robot = require("robot")
  4. inv = component.inventory_controller
  5.  
  6. function harvest_turn(side)
  7.   if side == sides.left then
  8.     robot.turnLeft()
  9.   elseif side == sides.right then
  10.     robot.turnRight()
  11.   elseif side == sides.back then
  12.     robot.turnAround()
  13.   elseif side == sides.front then
  14.     return
  15.   else print("Invalid side.")
  16.   end
  17. end
  18.  
  19. function harvest_peat()
  20.   if not robot.compareDown() then
  21.     robot.swingDown()
  22.     robot.placeDown()
  23.   end
  24. end
  25.  
  26. function harvest_line(side, dist)
  27.   harvest_turn(side)
  28.   for i=1,dist do
  29.     robot.forward()
  30.     harvest_peat()
  31.   end
  32. end
  33.  
  34. function harvest_level() --could be generalized
  35.   harvest_line(sides.front,5)
  36.   harvest_line(sides.right,4)
  37.   harvest_line(sides.right,4)
  38.   harvest_line(sides.right,3)
  39.   harvest_line(sides.right,3)
  40.   harvest_line(sides.right,2)
  41.   harvest_line(sides.right,2)
  42.   harvest_line(sides.right,1)
  43.   forward(2)
  44.   robot.turnLeft()
  45.   forward(2)
  46.   robot.turnAround()
  47. end
  48.  
  49. function forward(dist)
  50.   for i=1,dist do
  51.     robot.forward()
  52.   end
  53. end
  54.  
  55. function harvest_cube()
  56.   harvest_level()
  57.   robot.up()
  58.   robot.up()
  59.   harvest_level()
  60.   robot.up()
  61.   robot.up()
  62.   robot.select(2)
  63.   harvest_level()
  64.   robot.up()
  65.   robot.up()
  66.   harvest_level()
  67.   robot.down()
  68.   robot.down()
  69.   robot.down()
  70.   robot.down()
  71.   robot.down()
  72.   robot.down()
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement