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 | turtle.dig() | |
| 66 | ||
| 67 | while not turtle.forward() do | |
| 68 | turtle.attack() | |
| 69 | end | |
| 70 | ||
| 71 | while true do | |
| 72 | ||
| 73 | ||
| 74 | ||
| 75 | ||
| 76 | ||
| 77 | ||
| 78 | ore = false | |
| 79 | ||
| 80 | ||
| 81 | ||
| 82 | for c = 1, X do | |
| 83 | turtle.select(2) | |
| 84 | ore = turtle.compareDown() | |
| 85 | if ore == true then | |
| 86 | ||
| 87 | for t = 1, c do | |
| 88 | turtle.digUp() | |
| 89 | while not turtle.up() do | |
| 90 | turtle.digUp() | |
| 91 | turtle.attackUp() | |
| 92 | end | |
| 93 | end | |
| 94 | else | |
| 95 | ||
| 96 | turtle.dig() | |
| 97 | turtle.digDown() | |
| 98 | while not turtle.down() do | |
| 99 | turtle.attackDown() | |
| 100 | end | |
| 101 | end | |
| 102 | end | |
| 103 | ||
| 104 | if ore == false then | |
| 105 | for d = 1, X do | |
| 106 | turtle.dig() | |
| 107 | turtle.digUp() | |
| 108 | while not turtle.up() do | |
| 109 | turtle.attackUp() | |
| 110 | end | |
| 111 | end | |
| 112 | else | |
| 113 | end | |
| 114 | ||
| 115 | ||
| 116 | ||
| 117 | ||
| 118 | ||
| 119 | ||
| 120 | ||
| 121 | ||
| 122 | ||
| 123 | ||
| 124 | for r = 1, 2 do | |
| 125 | turtle.dig() | |
| 126 | while not turtle.forward() do | |
| 127 | turtle.attack() | |
| 128 | end | |
| 129 | ||
| 130 | end | |
| 131 | ||
| 132 | print ("Dropping off items")
| |
| 133 | ||
| 134 | turtle.dig() | |
| 135 | turtle.attack() | |
| 136 | ||
| 137 | ||
| 138 | turtle.select(1) | |
| 139 | while not turtle.place() do | |
| 140 | turtle.select(3) | |
| 141 | turtle.attack() | |
| 142 | turtle.select(1) | |
| 143 | end | |
| 144 | ||
| 145 | for dropslot = 3, 16 do | |
| 146 | turtle.select(dropslot) | |
| 147 | turtle.drop() | |
| 148 | end | |
| 149 | ||
| 150 | waitForSlaves() | |
| 151 | ||
| 152 | turtle.select(1) | |
| 153 | ||
| 154 | turtle.dig() | |
| 155 | ||
| 156 | turtle.select(3) | |
| 157 | ||
| 158 | end | |
| 159 | end |