SHOW:
|
|
- or go back to the newest paste.
1 | - | --local modem = peripheral.wrap("left") |
1 | + | local modem = peripheral.wrap("left") |
2 | - | --modem.open(42) |
2 | + | local clearCount = 0 |
3 | local totalTurtles = 5 | |
4 | - | turtle.select(1) |
4 | + | local turtleNumber = ... |
5 | - | --local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message") |
5 | + | modem.open(42) |
6 | - | --if message == "allClear" then |
6 | + | local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message") |
7 | - | local allClear = true |
7 | + | if message == "start" then |
8 | - | turtle.suckUp() |
8 | + | print("Recieved Start Command") |
9 | - | turtle.refuel(63) |
9 | + | print(turtleNumber) |
10 | - | turtle.forward() |
10 | + | |
11 | - | turtle.down() |
11 | + | |
12 | - | turtle.down() |
12 | + | if turtle.getFuelLevel() < 5 then |
13 | - | |
13 | + | turtle.up() |
14 | - | local x = 0 |
14 | + | turtle.up() |
15 | - | local y = 0 |
15 | + | turtle.suckUp() |
16 | - | local onWayBack = false |
16 | + | turtle.refuel(64) |
17 | - | local yStop = 33 |
17 | + | turtle.down() |
18 | - | local xStop = 3 |
18 | + | turtle.down() |
19 | - | while allClear do |
19 | + | end |
20 | - | if y <= yStop then |
20 | + | print("entered while loop") |
21 | - | if y == yStop then |
21 | + | local laser = peripheral.wrap("right") |
22 | - | turtle.turnRight() |
22 | + | if turtleNumber=="1" then |
23 | - | turtle.forward() |
23 | + | print("entered if") |
24 | - | turtle.turnRight() |
24 | + | for yaw = 0, 90, 1 do |
25 | - | onWayBack = true |
25 | + | laser.fire(yaw, 0, 5) |
26 | - | x = x + 1 |
26 | + | end |
27 | - | end |
27 | + | end |
28 | - | if onWayBack == false then |
28 | + | if turtleNumber=="2" then |
29 | - | y = y + 1 |
29 | + | for yaw = 90, 180, 1 do |
30 | - | turtle.forward() |
30 | + | laser.fire(yaw, 0, 5) |
31 | - | elseif onWayBack == true then |
31 | + | end |
32 | - | y = y - 1 |
32 | + | end |
33 | - | turtle.forward() |
33 | + | if turtleNumber=="3" then |
34 | - | end |
34 | + | for yaw = 180, 270, 1 do |
35 | - | end |
35 | + | laser.fire(yaw, 0, 5) |
36 | - | if y == 0 then |
36 | + | end |
37 | - | onWayBack = false |
37 | + | end |
38 | - | if x >= xStop then |
38 | + | if turtleNumber=="4" then |
39 | - | turtle.turnRight() |
39 | + | for yaw = 270, 360, 1 do |
40 | - | for i = 1, 3, 1 do |
40 | + | laser.fire(yaw, 0, 5) |
41 | - | turtle.forward() |
41 | + | end |
42 | - | x = x - 1 |
42 | + | end |
43 | - | end |
43 | + | turtle.up() |
44 | - | turtle.up() |
44 | + | modem.transmit(42, 1, "allClear") |
45 | - | turtle.up() |
45 | + | clearCount = 0 |
46 | - | turtle.turnLeft() |
46 | + | while clearCount <= totalTurtles do |
47 | - | turtle.forward() |
47 | + | local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message") |
48 | - | turtle.select(1) |
48 | + | if message == "pickupClear" then |
49 | - | turtle.suckUp() |
49 | + | clearCount = clearCount + 1 |
50 | - | turtle.refuel(64) |
50 | + | end |
51 | - | turtle.turnRight() |
51 | + | end |
52 | - | turtle.turnRight() |
52 | + | turtle.down() |
53 | - | turtle.forward() |
53 | + | end |