SHOW:
|
|
- or go back to the newest paste.
| 1 | slaveName = "5" | |
| 2 | masterID = 0 | |
| 3 | outputBool = false | |
| 4 | ||
| 5 | function testMaster(pID = -1, pMessage) | |
| 6 | if pID == -1 then | |
| 7 | while true do | |
| 8 | id, message = rednet.receive() | |
| 9 | if message == "KKRNBTNMaster" then | |
| 10 | rednet.send(id, slaveName) | |
| 11 | masterID = id | |
| 12 | print("Discovered Master with ID: " .. id)
| |
| 13 | return true | |
| 14 | end | |
| 15 | end | |
| 16 | else | |
| 17 | rednet.send(pID, slaveName) | |
| 18 | masterID = pID | |
| 19 | print("Discovered Master with ID: " .. pID)
| |
| 20 | return true | |
| 21 | end | |
| 22 | end | |
| 23 | ||
| 24 | ||
| 25 | function testMessage() | |
| 26 | - | if message == "KKRNBTNMaster" then |
| 26 | + | |
| 27 | - | rednet.send(id, slaveName) |
| 27 | + | |
| 28 | - | masterID = id |
| 28 | + | |
| 29 | - | print("Discovered Master with ID: " .. id)
|
| 29 | + | |
| 30 | - | break |
| 30 | + | |
| 31 | - | end |
| 31 | + | else |
| 32 | testMaster(id, message) | |
| 33 | end | |
| 34 | end | |
| 35 | end | |
| 36 | ||
| 37 | function setRedstone(state) | |
| 38 | print("Setting Redstone to: " .. tostring(state))
| |
| 39 | redstone.setOutput("back", state)
| |
| 40 | end | |
| 41 | ||
| 42 | setRedstone(outputBool) | |
| 43 | ||
| 44 | rednet.open("top")
| |
| 45 | ||
| 46 | while true do | |
| 47 | testMessage() | |
| 48 | end |