Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- slaveName = "5"
- masterID = 0
- outputBool = false
- masterActive = false
- function testMaster(pID, pMessage)
- pID = pID or -1
- if pID == -1 then
- while true do
- id, message = rednet.receive()
- if message == "KKRNBTNMaster" then
- rednet.send(id, slaveName)
- masterID = id
- print("Discovered Master with ID: " .. id)
- return true
- end
- end
- else
- if message == "KKRNBTNMaster" then
- rednet.send(pID, slaveName)
- masterID = pID
- print("Discovered Master with ID: " .. pID)
- return true
- end
- end
- function testMessage()
- id, message = rednet.receive()
- if message == "t" then
- if id == masterID then
- outputBool = not outputBool
- setRedstone(outputBool)
- end
- else
- masterActive = false
- if testMaster(id, message) then
- masterActive = true
- end
- end
- end
- function setRedstone(state)
- print("Setting Redstone to: " .. tostring(state))
- redstone.setOutput("back", state)
- end
- setRedstone(outputBool)
- rednet.open("top")
- while true do
- testMessage()
- end
Advertisement
Add Comment
Please, Sign In to add comment