jonassvensson4

FTB | Openperipheral Reactor

Mar 9th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local glasses = peripheral.wrap("right")
  2. rednet.open("top")
  3.  
  4. reactor = 16
  5.  
  6. -- Create box
  7. function createBox()
  8.     glasses.clear()
  9.     glasses.addBox(5,20,50,50,0x000000,0.2)
  10.     glasses.addText(10,25,"Reactor",0x385E9C)
  11.     glasses.sync()
  12. end
  13.  
  14. -- Default status
  15. function default()
  16.     rednet.send(reactor,"roff")
  17.     glasses.addText(10,35,"Offline",0x9C3838)
  18.     glasses.sync()
  19. end
  20.  
  21. -- Get status
  22. function status()
  23.     rednet.send(reactor,"status")
  24.     id, stat = rednet.receive(5)
  25.  
  26.     if stat == true then
  27.         glasses.clear()
  28.         createBox()
  29.         glasses.addText(10,35,"Online",0x389C51)
  30.         glasses.sync()
  31.     elseif stat == false then
  32.         glasses.clear()
  33.         createBox()
  34.         glasses.addText(10,35,"Offline",0x9C3838)
  35.         glasses.sync()
  36.     else
  37.         default()
  38.     end
  39. end
  40.  
  41. createBox()
  42. status()
  43.  
  44. -- Commands
  45. while true do
  46.     local event = { os.pullEvent() }
  47.  
  48.     if event[1] == "glasses_chat_command" then
  49.         if event[5] == "ron" then
  50.             rednet.send(reactor,"ron")
  51.             sleep(1)
  52.             status()
  53.         elseif event[5] == "roff" then
  54.             rednet.send(reactor,"roff")
  55.             sleep(1)
  56.             status()
  57.         end
  58.     end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment