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 (numberNeighbours) 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 | -- Open up modem to receive wireless broadcasts | |
| 10 | rednet.open("right")
| |
| 11 | ||
| 12 | -- Wait until neighbouring turtles are ready | |
| 13 | function waitForMaster() | |
| 14 | local event, param1, param2 | |
| 15 | ||
| 16 | rednet.broadcast("I am ready and waiting master")
| |
| 17 | os.startTimer(1) | |
| 18 | ||
| 19 | while true do | |
| 20 | event, param1, param2 = os.pullEvent() | |
| 21 | ||
| 22 | -- Resend ready message every second, in case master is not yet ready | |
| 23 | if event == "timer" then | |
| 24 | rednet.broadcast("I am ready and waiting master")
| |
| 25 | os.startTimer(1) | |
| 26 | ||
| 27 | -- Wait for master turtle to give the OK to proceed before continuing digging | |
| 28 | elseif event == "rednet_message" then | |
| 29 | local message = param2 | |
| 30 | if message == "You are authorised to proceed" then | |
| 31 | break | |
| 32 | end -- if message | |
| 33 | end -- if event | |
| 34 | end -- while | |
| 35 | end -- function | |
| 36 | ||
| 37 | bool=true | |
| 38 | ||
| 39 | while bool==true do | |
| 40 | if rs.getInput("back", true) then
| |
| 41 | print ("Waiting")
| |
| 42 | sleep (1) | |
| 43 | else | |
| 44 | print ("Let's Roll!")
| |
| 45 | bool=false | |
| 46 | end | |
| 47 | end | |
| 48 | ||
| 49 | X=66 | |
| 50 | ||
| 51 | - | print ("Startup Functions Activating")
|
| 51 | + | |
| 52 | - | print ("Going to lowest point")
|
| 52 | + | |
| 53 | print ("---------------------------")
| |
| 54 | - | turtle.select(1) |
| 54 | + | |
| 55 | - | turtle.dig() |
| 55 | + | |
| 56 | - | turtle.select(3) |
| 56 | + | |
| 57 | - | turtle.back() |
| 57 | + | |
| 58 | ||
| 59 | - | while true do |
| 59 | + | |
| 60 | - | local mobsPresent = turtle.attackDown() |
| 60 | + | |
| 61 | - | local digSuccess = turtle.digDown() |
| 61 | + | |
| 62 | - | local movementSuccess = turtle.down() |
| 62 | + | |
| 63 | while true do | |
| 64 | - | if not mobsPresent and not digSuccess and not movementSuccess then |
| 64 | + | |
| 65 | - | break |
| 65 | + | |
| 66 | ||
| 67 | ||
| 68 | ||
| 69 | - | for b = 1, X do |
| 69 | + | |
| 70 | - | turtle.digUp() |
| 70 | + | |
| 71 | - | while not turtle.up() do |
| 71 | + | |
| 72 | - | turtle.attackUp() |
| 72 | + | |
| 73 | ||
| 74 | for c = 1, X do | |
| 75 | turtle.select(2) | |
| 76 | ore = turtle.compareDown() | |
| 77 | if ore == true then | |
| 78 | ||
| 79 | for t = 1, c do | |
| 80 | turtle.digUp() | |
| 81 | while not turtle.up() | |
| 82 | turtle.digUp() | |
| 83 | turtle.attackUp() | |
| 84 | end | |
| 85 | end | |
| 86 | else | |
| 87 | ||
| 88 | turtle.dig() | |
| 89 | turtle.digDown() | |
| 90 | while not turtle.down() do | |
| 91 | turtle.attackDown() | |
| 92 | end | |
| 93 | end | |
| 94 | end | |
| 95 | ||
| 96 | if ore == false then | |
| 97 | for d = 1, X do | |
| 98 | turtle.dig() | |
| 99 | turtle.digUp() | |
| 100 | while not turtle.up() do | |
| 101 | turtle.attackUp() | |
| 102 | end | |
| 103 | else | |
| 104 | end | |
| 105 | ||
| 106 | ||
| 107 | ||
| 108 | ||
| 109 | ||
| 110 | ||
| 111 | ||
| 112 | ||
| 113 | ||
| 114 | ||
| 115 | for r = 1, 2 do | |
| 116 | turtle.dig() | |
| 117 | while not turtle.forward() do | |
| 118 | turtle.attack() | |
| 119 | end | |
| 120 | ||
| 121 | end | |
| 122 | ||
| 123 | print ("Dropping off items")
| |
| 124 | ||
| 125 | turtle.dig() | |
| 126 | turtle.attack() | |
| 127 | ||
| 128 | ||
| 129 | turtle.select(1) | |
| 130 | while not turtle.place() do | |
| 131 | turtle.select(3) | |
| 132 | turtle.attack() | |
| 133 | turtle.select(1) | |
| 134 | end | |
| 135 | ||
| 136 | for dropslot = 3, 16 do | |
| 137 | turtle.select(dropslot) | |
| 138 | turtle.drop() | |
| 139 | end | |
| 140 | ||
| 141 | waitForMaster() | |
| 142 | ||
| 143 | turtle.select(1) | |
| 144 | ||
| 145 | turtle.dig() | |
| 146 | ||
| 147 | turtle.select(3) | |
| 148 | ||
| 149 | end | |
| 150 | end |