SHOW:
|
|
- or go back to the newest paste.
| 1 | -- Awake | |
| 2 | print("Mining client awake: Hello World!")
| |
| 3 | ||
| 4 | -- Setup wireless | |
| 5 | local modem = peripheral.wrap("right")
| |
| 6 | - | -- 5 Server -> Client |
| 6 | + | -- 11 Server -> Client |
| 7 | - | -- 6 Client -> Server |
| 7 | + | -- 12 Client -> Server |
| 8 | - | modem.open(5) |
| 8 | + | modem.open(11) |
| 9 | - | modem.open(6) |
| 9 | + | modem.open(12) |
| 10 | - | print("Channel 5 and 6 are open")
|
| 10 | + | print("Channel 11 and 12 are open")
|
| 11 | ||
| 12 | -- Setup receiving wireless messages | |
| 13 | function WaitForMessage(messageCompare) | |
| 14 | while true do | |
| 15 | local a,b,c,d,e,f = os.pullEvent("modem_message")
| |
| 16 | print("Message received: ")
| |
| 17 | print(e) | |
| 18 | if(e == messageCompare) then | |
| 19 | print("Message accepted")
| |
| 20 | break | |
| 21 | end | |
| 22 | end | |
| 23 | end | |
| 24 | ||
| 25 | function IsTurtle() | |
| 26 | local success, data = turtle.inspect() | |
| 27 | - | modem.transmit(6, 5, message) |
| 27 | + | if success then |
| 28 | return data.name == "computercraft:turtle_advanced" | |
| 29 | else | |
| 30 | - | -- Server handshake |
| 30 | + | return false |
| 31 | - | print("Waiting for server awake")
|
| 31 | + | |
| 32 | - | WaitForMessage("_ServerAwake")
|
| 32 | + | |
| 33 | - | print("Replying to server...")
|
| 33 | + | |
| 34 | - | SendMessage("_TurtleRegistered")
|
| 34 | + | |
| 35 | - | print("Waiting to begin")
|
| 35 | + | |
| 36 | - | WaitForMessage("_Begin")
|
| 36 | + | modem.transmit(12, 11, message) |
| 37 | end | |
| 38 | - | function Down() |
| 38 | + | |
| 39 | - | while not turtle.down() do |
| 39 | + | -- Main loop |
| 40 | - | if turtle.detectDown() then turtle.digDown() end |
| 40 | + | |
| 41 | - | turtle.attackDown() |
| 41 | + | |
| 42 | - | end |
| 42 | + | |
| 43 | - | turtle.dig() |
| 43 | + | |
| 44 | while not IsTurtle() do | |
| 45 | turtle.forward() | |
| 46 | - | function Up() |
| 46 | + | |
| 47 | - | while not turtle.up() do |
| 47 | + | |
| 48 | - | if turtle.detectUp() then turtle.digUp() end |
| 48 | + | |
| 49 | - | turtle.attackUp() |
| 49 | + | |
| 50 | - | end |
| 50 | + | |
| 51 | - | turtle.dig() |
| 51 | + | |
| 52 | print("Goodbye >>")
| |
| 53 | read() |