Advertisement
Clorith

Untitled

Sep 29th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. glass = peripheral.wrap( "bottom" )
  2.  
  3. rednet.open( "back" )
  4.  
  5. -- Constants
  6. pos_x = 40
  7. pos_y = 45
  8. pos_inc = 10
  9. color = {}
  10. color["on"] = 0x229000
  11. color["off"] = 0xFF0000
  12.  
  13. -- Devices
  14.  
  15. -- Device status
  16. status = {}
  17. function addStatus( device, mode )
  18.   status[device] = glass.addText( pos_x, pos_y, device, color["off"] )
  19.   pos_y = pos_y + pos_inc
  20. end
  21.  
  22. while true do
  23.   local command = ""
  24.   local device = ""
  25.   local mode = ""
  26.  
  27.   senderID, message, distance = rednet.receive()
  28.   print( senderID .. ": " .. message )
  29.  
  30.   for i in string.gmatch( message,  "%S+" ) do
  31.     if command ~= "" and device ~= "" then
  32.       mode  = i
  33.     end
  34.     if command ~= "" and device == "" then
  35.       device = i
  36.     end
  37.     if command == "" and device == "" then
  38.       command = i
  39.     end
  40.   end
  41.  
  42.   if nil status[device] then
  43.     addStatus( device, mode )
  44.   else
  45.     status[device].setColor( color[mode] )
  46.   end
  47. end
  48.  
  49. rednet.close( "back" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement