SHOW:
|
|
- or go back to the newest paste.
| 1 | -- Awake | |
| 2 | - | print("Chunk follow client awake: Hello World!")
|
| 2 | + | print("Chatty turtle awake: Hello World!")
|
| 3 | ||
| 4 | -- Setup wireless | |
| 5 | - | local modem = peripheral.wrap("right")
|
| 5 | + | local modem = peripheral.wrap("left")
|
| 6 | - | -- 5 Server -> Client |
| 6 | + | |
| 7 | - | -- 6 Client -> Server |
| 7 | + | |
| 8 | print("Channel 11 and 12 are open")
| |
| 9 | ||
| 10 | --Setup Chatbox | |
| 11 | local chatbox = peripheral.wrap("right")
| |
| 12 | ||
| 13 | -- Setup receiving wireless messages | |
| 14 | function WaitForMessage(messageCompare) | |
| 15 | while true do | |
| 16 | local a,b,c,d,e,f = os.pullEvent("modem_message")
| |
| 17 | print("Message received: ")
| |
| 18 | print(e) | |
| 19 | if(e == messageCompare) then | |
| 20 | print("Message accepted")
| |
| 21 | break | |
| 22 | end | |
| 23 | end | |
| 24 | end | |
| 25 | - | -- Forward shorthand |
| 25 | + | |
| 26 | - | function Forward() |
| 26 | + | local cycleTracker = 0 |
| 27 | - | while not turtle.forward() do |
| 27 | + | |
| 28 | - | turtle.attack() |
| 28 | + | |
| 29 | - | end |
| 29 | + | |
| 30 | print("Waiting for start of next cycle")
| |
| 31 | WaitForMessage("_StartNextCycle")
| |
| 32 | ||
| 33 | textOut = os.date() .. " >> Mine cycle: " .. tostring(cycleTracker) | |
| 34 | print(textOut) | |
| 35 | chatbox.sendMessage(textOut) | |
| 36 | - | print("Moving forward...")
|
| 36 | + | cycleTracker = cycleTracker + 1 |
| 37 | - | Forward() |
| 37 | + | |
| 38 | - | Forward() |
| 38 | + | |
| 39 | - | Forward() |
| 39 | + | |
| 40 | - | Forward() |
| 40 | + | |
| 41 | end | |
| 42 | ||
| 43 | print("Goodbye >>")
| |
| 44 | read() |