SHOW:
|
|
- or go back to the newest paste.
| 1 | --[[ | |
| 2 | Changes: | |
| 3 | Turtles no longer monitor how many rows they've gone forward (no more rowsProgressed file) | |
| 4 | Master turtle simply waits for (numberSlaves) unique turtles to send messages saying | |
| 5 | they are ready and waiting. Slave turtles repeatedly send ready and waiting signals to prevent | |
| 6 | the sync problems we were having before. | |
| 7 | --]] | |
| 8 | ||
| 9 | -- Number of neighbouring turtles | |
| 10 | numberSlaves = 8 | |
| 11 | ||
| 12 | -- Open up modem to receive wireless broadcasts | |
| 13 | rednet.open("right")
| |
| 14 | ||
| 15 | -- Wait until neighbouring turtles are ready | |
| 16 | function waitForSlaves() | |
| 17 | local IDsOfWaitingTurtles = {}
| |
| 18 | local remoteTurtleID, rednetMessage | |
| 19 | local newTurtleIsReportingReady | |
| 20 | ||
| 21 | -- Wait for (numberNeighbours) unique turtles to send ready messages | |
| 22 | repeat | |
| 23 | remoteTurtleID, rednetMessage, _ = rednet.receive() | |
| 24 | ||
| 25 | if rednetMessage == "I am ready and waiting master" then | |
| 26 | -- Check if turtle has replied already | |
| 27 | newTurtleIsReportingReady = true | |
| 28 | ||
| 29 | for i=1, table.getn(IDsOfWaitingTurtles) do | |
| 30 | if remoteTurtleID == IDsOfWaitingTurtles[i] then | |
| 31 | newTurtleIsReportingReady = false | |
| 32 | break | |
| 33 | end | |
| 34 | end | |
| 35 | ||
| 36 | if newTurtleIsReportingReady then | |
| 37 | table.insert(IDsOfWaitingTurtles, remoteTurtleID) | |
| 38 | end | |
| 39 | end | |
| 40 | until table.getn(IDsOfWaitingTurtles) >= numberSlaves | |
| 41 | ||
| 42 | rednet.broadcast("You are authorised to proceed")
| |
| 43 | end | |
| 44 | ||
| 45 | bool=true | |
| 46 | ||
| 47 | while bool==true do | |
| 48 | if rs.getInput("back", true) then
| |
| 49 | print ("Waiting")
| |
| 50 | sleep (1) | |
| 51 | else | |
| 52 | print ("Let's Roll!")
| |
| 53 | bool=false | |
| 54 | end | |
| 55 | end | |
| 56 | ||
| 57 | X=66 | |
| 58 | ||
| 59 | ||
| 60 | ||
| 61 | print ("---------------------------")
| |
| 62 | print ("Starting World Eating Scripts!")
| |
| 63 | print ("---------------------------")
| |
| 64 | ||
| 65 | ||
| 66 | ||
| 67 | while true do | |
| 68 | ||
| 69 | ||
| 70 | moves = 0 | |
| 71 | ||
| 72 | ore = false | |
| 73 | ||
| 74 | turtle.select(2) | |
| 75 | ore = turtle.compareDown() | |
| 76 | turtle.select(3) | |
| 77 | ||
| 78 | - | while ore == false and moves < 65 do |
| 78 | + | while ore == false and moves < 67 do |
| 79 | turtle.digDown() | |
| 80 | moves = moves + 1 | |
| 81 | while not turtle.down() do | |
| 82 | turtle.attack() | |
| 83 | end | |
| 84 | sleep(.5) | |
| 85 | turtle.select(2) | |
| 86 | ore = turtle.compareDown() | |
| 87 | turtle.select(3) | |
| 88 | end | |
| 89 | ||
| 90 | for q=1, moves do | |
| 91 | turtle.digUp() | |
| 92 | while not turtle.up() do | |
| 93 | turtle.attack() | |
| 94 | turtle.digUp() | |
| 95 | end | |
| 96 | end | |
| 97 | ||
| 98 | ||
| 99 | ||
| 100 | ||
| 101 | ||
| 102 | ||
| 103 | for r = 1, 2 do | |
| 104 | turtle.dig() | |
| 105 | while not turtle.forward() do | |
| 106 | turtle.attack() | |
| 107 | end | |
| 108 | ||
| 109 | end | |
| 110 | ||
| 111 | print ("Dropping off items")
| |
| 112 | ||
| 113 | turtle.dig() | |
| 114 | turtle.attack() | |
| 115 | ||
| 116 | ||
| 117 | turtle.select(1) | |
| 118 | while not turtle.place() do | |
| 119 | turtle.select(3) | |
| 120 | turtle.attack() | |
| 121 | turtle.select(1) | |
| 122 | end | |
| 123 | ||
| 124 | for dropslot = 3, 16 do | |
| 125 | turtle.select(dropslot) | |
| 126 | turtle.drop() | |
| 127 | end | |
| 128 | ||
| 129 | waitForSlaves() | |
| 130 | ||
| 131 | turtle.select(1) | |
| 132 | ||
| 133 | turtle.dig() | |
| 134 | ||
| 135 | turtle.select(3) | |
| 136 | ||
| 137 | end |