Advertisement
Guest User

Cropper V2

a guest
Feb 6th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local component = require("component")
  2. local robot = require("robot")
  3. local geo = component.geolyzer
  4. local ic = component.inventory_controller
  5. local event = require "event"
  6.  
  7. local checked = false
  8. local step = 0
  9.  
  10. function placeCross()
  11.   ic.equip()
  12.   robot.useDown(0)
  13.   os.sleep(0.1)
  14.   robot.useDown(0)
  15.   ic.equip()
  16. end
  17.  
  18. while event.pull(1, "interrupted") == nil do
  19.    meta = geo.analyze(0).metadata
  20.    if meta == 7 then
  21.      print("next")
  22.      checked = false
  23.      if step == 0 then
  24.        step=1
  25.        robot.turnLeft()
  26.        robot.forward()
  27.        robot.turnLeft()
  28.        robot.forward()
  29.        robot.swingDown()
  30.        placeCross()
  31.      else
  32.        step=0
  33.        robot.turnLeft()
  34.        robot.forward()
  35.        robot.swingDown()
  36.        placeCross()
  37.      end
  38.    elseif not checked and meta  > 0 then
  39.      robot.useDown(0,false,0)
  40.      if geo.analyze(0).metadata < meta then
  41.         checked = true
  42.         robot.useDown(0,false,0)
  43.         print("Detected crop")
  44.      else --weed
  45.         print("Removing weeds")
  46.         robot.select(2)
  47.         ic.equip()
  48.         robot.useDown(0,false,0)
  49.         os.sleep(.4)
  50.         robot.useDown(0,false,0)
  51.         ic.equip()
  52.         robot.select(1)
  53.         ic.equip()
  54.         robot.useDown(0,false,0)
  55.         ic.equip()
  56.      end
  57.   else
  58.      robot.up()
  59.      os.sleep(5)
  60.      robot.down()
  61.    end
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement