SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local component = require("component") |
| 1 | + | local component = require("component")
|
| 2 | - | local robot = require("robot") |
| 2 | + | local robot = require("robot")
|
| 3 | - | local geo = component.geolyzer |
| 3 | + | local geo = component.geolyzer |
| 4 | - | local ic = component.inventory_controller |
| 4 | + | local ic = component.inventory_controller |
| 5 | - | |
| 5 | + | local event = require "event" |
| 6 | - | local step = 0 |
| 6 | + | |
| 7 | - | |
| 7 | + | local checked = false |
| 8 | - | function placeCross() |
| 8 | + | local step = 0 |
| 9 | - | ic.equip() |
| 9 | + | |
| 10 | - | robot.useDown(0) |
| 10 | + | function placeCross() |
| 11 | - | os.sleep(0.1) |
| 11 | + | ic.equip() |
| 12 | - | robot.useDown(0) |
| 12 | + | robot.useDown(0) |
| 13 | - | ic.equip() |
| 13 | + | os.sleep(0.1) |
| 14 | robot.useDown(0) | |
| 15 | - | |
| 15 | + | ic.equip() |
| 16 | - | while true do |
| 16 | + | end |
| 17 | - | os.sleep(0.4) |
| 17 | + | |
| 18 | - | meta = geo.analyze(0).metadata |
| 18 | + | while event.pull(1, "interrupted") == nil do |
| 19 | - | if meta == 7 then |
| 19 | + | meta = geo.analyze(0).metadata |
| 20 | - | if step == 0 then |
| 20 | + | if meta == 7 then |
| 21 | - | step=1 |
| 21 | + | print("next")
|
| 22 | - | robot.turnLeft() |
| 22 | + | checked = false |
| 23 | - | robot.forward() |
| 23 | + | if step == 0 then |
| 24 | - | robot.turnLeft() |
| 24 | + | step=1 |
| 25 | - | robot.forward() |
| 25 | + | robot.turnLeft() |
| 26 | - | robot.swingDown() |
| 26 | + | robot.forward() |
| 27 | - | placeCross() |
| 27 | + | robot.turnLeft() |
| 28 | - | else |
| 28 | + | robot.forward() |
| 29 | - | step=0 |
| 29 | + | robot.swingDown() |
| 30 | - | robot.turnLeft() |
| 30 | + | placeCross() |
| 31 | - | robot.forward() |
| 31 | + | else |
| 32 | - | robot.swingDown() |
| 32 | + | step=0 |
| 33 | - | placeCross() |
| 33 | + | robot.turnLeft() |
| 34 | - | end |
| 34 | + | robot.forward() |
| 35 | - | elseif meta > 0 then |
| 35 | + | robot.swingDown() |
| 36 | - | robot.useDown(0,false,0) |
| 36 | + | placeCross() |
| 37 | - | os.sleep(0.2) |
| 37 | + | end |
| 38 | - | robot.useDown(0,false,0) |
| 38 | + | elseif not checked and meta > 0 then |
| 39 | - | if geo.analyze(0).metadata < meta then |
| 39 | + | robot.useDown(0,false,0) |
| 40 | - | ic.equip() |
| 40 | + | if geo.analyze(0).metadata < meta then |
| 41 | - | robot.useDown(0,false,0) |
| 41 | + | checked = true |
| 42 | - | ic.equip() |
| 42 | + | robot.useDown(0,false,0) |
| 43 | - | end |
| 43 | + | print("Detected crop")
|
| 44 | - | |
| 44 | + | else --weed |
| 45 | - | |
| 45 | + | print("Removing weeds")
|
| 46 | - | end |
| 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 |