Advertisement
RLPGhost

Recepteur Rod

Nov 22nd, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. wifi = peripheral.wrap("back")
  2. modem = peripheral.wrap("top")
  3. cr1 = peripheral.wrap("CentralControl_0")
  4. cr2 = peripheral.wrap("CentralControl_5")
  5. cr3 = peripheral.wrap("CentralControl_4")
  6. cr4 = peripheral.wrap("CentralControl_2")
  7.  
  8. wifi.closeAll()
  9. wifi.open(2)
  10.  
  11.  
  12.  
  13. while true do
  14.  
  15. local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  16.  
  17. if senderChannel == 2 then
  18.  
  19.     i = tonumber(message)
  20.     term.clear()
  21.     term.setCursorPos(1,1)
  22.     print(tostring(i))
  23.    
  24.     if bit.band(i,1) > 0 then
  25.     cr1.raiseRods()
  26.     else
  27.     cr1.lowerRods()
  28.     end
  29.    
  30.     if bit.band(i,2) > 0 then
  31.     cr2.raiseRods()
  32.     else
  33.     cr2.lowerRods()
  34.     end
  35.    
  36.     if bit.band(i,4) > 0 then
  37.     cr3.raiseRods()
  38.     else
  39.     cr3.lowerRods()
  40.     end
  41.    
  42.     if bit.band(i,8) > 0 then
  43.     cr4.raiseRods()
  44.     else
  45.     cr4.lowerRods()
  46.     end
  47.    
  48.    
  49. end
  50.  
  51. sleep(1)
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement