Elgskred

CCReactorMonWireless

Feb 19th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. --Reactor Monitor Wireless
  2.  
  3. reactor = peripheral.wrap("back")
  4. local modem = peripheral.wrap("left")
  5. modem.open(1) --Chanel 1 is used for comunicating with the controller
  6.  
  7. local t = {}
  8.  
  9. while true do
  10.  
  11. if reactor.getConnected() == true then
  12.  
  13.     if reactor.getEnergyStored() > 9000000 then
  14.             if reactor.getActive() == true then
  15.                     reactor.setActive(false)
  16.             end
  17.     end
  18.  
  19.     if reactor.getEnergyStored() < 100000 then
  20.             if reactor.getActive() == false then
  21.                     reactor.setActive(true)
  22.             end
  23.     end
  24.  
  25.  
  26. else
  27.     sleep(10)
  28. end
  29.  
  30.     t[1] = 1 -- Reactor number - Set manualy
  31.     t[2] = reactor.getActive()
  32.     t[3] = reactor.getEnergyProducedLastTick()
  33.     t[4] = (reactor.getEnergyStored() / 10000000) * 100
  34.     local msg = textutils.serialize(t)
  35.     modem.transmit(1,10,msg) -- 1=sending chan , 10=reply chan , msg=message
  36.     sleep(3)
  37.    
  38. end
Advertisement
Add Comment
Please, Sign In to add comment