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 = 15 |
| 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 | print ("Startup Functions Activating")
| |
| 60 | print ("Going to lowest point")
| |
| 61 | ||
| 62 | turtle.select(1) | |
| 63 | turtle.dig() | |
| 64 | turtle.select(3) | |
| 65 | turtle.back() | |
| 66 | ||
| 67 | while true do | |
| 68 | local mobsPresent = turtle.attackDown() | |
| 69 | local digSuccess = turtle.digDown() | |
| 70 | local movementSuccess = turtle.down() | |
| 71 | ||
| 72 | if not mobsPresent and not digSuccess and not movementSuccess then | |
| 73 | break | |
| 74 | end | |
| 75 | end | |
| 76 | ||
| 77 | for b = 1, X do | |
| 78 | turtle.digUp() | |
| 79 | while not turtle.up() do | |
| 80 | turtle.attackUp() | |
| 81 | end | |
| 82 | end | |
| 83 | ||
| 84 | - | print ("Calibrated level for a flat bedrock world.")
|
| 84 | + | |
| 85 | print ("Starting World Eating Scripts!")
| |
| 86 | print ("---------------------------")
| |
| 87 | ||
| 88 | turtle.dig() | |
| 89 | ||
| 90 | while not turtle.forward() do | |
| 91 | turtle.attack() | |
| 92 | end | |
| 93 | ||
| 94 | while true do | |
| 95 | ||
| 96 | ||
| 97 | - | for i = 1, 2 do |
| 97 | + | |
| 98 | ||
| 99 | ||
| 100 | ||
| 101 | ore = false | |
| 102 | - | while not turtle.down() do |
| 102 | + | |
| 103 | - | turtle.attackDown() |
| 103 | + | |
| 104 | ||
| 105 | for c = 1, X do | |
| 106 | turtle.select(2) | |
| 107 | ore = turtle.compareDown() | |
| 108 | if ore == true then | |
| 109 | ||
| 110 | for t = 1, c do | |
| 111 | turtle.digUp() | |
| 112 | while not turtle.up() | |
| 113 | turtle.digUp() | |
| 114 | turtle.attackUp() | |
| 115 | end | |
| 116 | end | |
| 117 | else | |
| 118 | ||
| 119 | turtle.dig() | |
| 120 | turtle.digDown() | |
| 121 | while not turtle.down() do | |
| 122 | turtle.attackDown() | |
| 123 | - | Fuel = turtle.getFuelLevel() |
| 123 | + | end |
| 124 | end | |
| 125 | - | print ("Fuel level is: "..Fuel)
|
| 125 | + | |
| 126 | ||
| 127 | - | if Fuel >= 8192 then |
| 127 | + | if ore == false then |
| 128 | for d = 1, X do | |
| 129 | - | print ("Fuel level is above minimum safe limit.")
|
| 129 | + | |
| 130 | turtle.digUp() | |
| 131 | - | else |
| 131 | + | |
| 132 | turtle.attackUp() | |
| 133 | - | print ("Fuel is below safe limit! Refueling!")
|
| 133 | + | |
| 134 | else | |
| 135 | - | turtle.select(3) |
| 135 | + | |
| 136 | - | turtle.dig() |
| 136 | + | |
| 137 | - | turtle.select(2) |
| 137 | + | |
| 138 | - | while not turtle.place() do |
| 138 | + | |
| 139 | - | turtle.select(3) |
| 139 | + | |
| 140 | - | turtle.dig() |
| 140 | + | |
| 141 | - | turtle.attack() |
| 141 | + | |
| 142 | - | turtle.select(2) |
| 142 | + | |
| 143 | ||
| 144 | - | turtle.suck() |
| 144 | + | |
| 145 | - | turtle.refuel() |
| 145 | + | |
| 146 | for r = 1, 2 do | |
| 147 | - | |
| 147 | + | |
| 148 | - | turtle.select(3) |
| 148 | + | |
| 149 | - | |
| 149 | + | |
| 150 | end | |
| 151 | ||
| 152 | end | |
| 153 | ||
| 154 | print ("Dropping off items")
| |
| 155 | ||
| 156 | turtle.dig() | |
| 157 | turtle.attack() | |
| 158 | ||
| 159 | ||
| 160 | turtle.select(1) | |
| 161 | while not turtle.place() do | |
| 162 | turtle.select(3) | |
| 163 | turtle.attack() | |
| 164 | turtle.select(1) | |
| 165 | end | |
| 166 | ||
| 167 | for dropslot = 3, 16 do | |
| 168 | turtle.select(dropslot) | |
| 169 | turtle.drop() | |
| 170 | end | |
| 171 | ||
| 172 | waitForSlaves() | |
| 173 | ||
| 174 | turtle.select(1) | |
| 175 | ||
| 176 | turtle.dig() | |
| 177 | ||
| 178 | turtle.select(3) | |
| 179 | ||
| 180 | end | |
| 181 | end |