Advertisement
tobast

[AT_switch] checker

Jun 29th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.50 KB | None | 0 0
  1. ------ PARAMS ------
  2. TABLE_SIDE = 'top'
  3. MODEM_SIDE = 'left'
  4. function check(periph)
  5.     return periph.isActive()
  6. end
  7. ------- END --------
  8.  
  9. function main()
  10.     rednet.open(MODEM_SIDE)
  11.     rednet.host('switch_check','checker')
  12.  
  13.     periph = peripheral.wrap(TABLE_SIDE)
  14.  
  15.     while true do
  16.         evt,snd,mess = os.pullEvent('rednet_message')
  17.         if(type(mess) == 'string') then
  18.             mess = textutils.unserialize(mess)
  19.         end
  20.        
  21.         if(mess.type == 'check') then
  22.             rednet.send(snd, { type='status', status = check(periph) } )
  23.         end
  24.     end
  25. end
  26. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement