Kulgan_Starkk

rednetGet

Mar 27th, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. slaveName = "5" -- number of button to assign to
  2. masterID = 0
  3. outputBool = false -- default (off) state of redstone power for spawner, false means off
  4. masterActive = false
  5.  
  6. function testMaster(pID, pMessage)
  7.   if message == "KKRNBTNMaster" then
  8.     rednet.send(pID, slaveName)
  9.     masterID = pID
  10.     print("Discovered Master with ID: " .. pID)
  11.     masterActive = true
  12.     return true
  13.   end  
  14. end
  15.  
  16.  
  17. function testMessage()
  18.   id, message = rednet.receive()
  19.   if message == "t" then
  20.     if id == masterID then
  21.       outputBool = not outputBool
  22.       setRedstone(outputBool)
  23.     end
  24.   else
  25.     if message == "KKRNBTNReload" then
  26.       masterActive = false
  27.     end
  28.     if not masterActive then
  29.       testMaster(id, message)
  30.     end
  31.   end
  32. end
  33.  
  34. function setRedstone(state)
  35.   print("Setting Redstone to: " .. tostring(state))
  36.   redstone.setOutput("back", state)
  37. end
  38.  
  39. setRedstone(outputBool)
  40.  
  41. rednet.open("top")
  42.  
  43. while true do
  44.   testMessage()
  45. end
Advertisement
Add Comment
Please, Sign In to add comment