Advertisement
chardog

Untitled

Dec 10th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.47 KB | None | 0 0
  1. local reactors = {peripheral.find("BigReactors-Reactor")}
  2. local reactor = reactors[1]
  3. reactor.setActive(false)
  4. local minBuffer = 500000
  5. local maxBuffer = 9000000
  6. local reactorActive = false
  7. local monitor1 = peripheral.wrap("top")
  8. local line = 1
  9. local w,h = monitor1.getSize()
  10. local bufferFullness = 0
  11.  
  12. print("Starting up...")
  13. while true do
  14.     line = 0
  15.     monitor1.clear()
  16.  
  17.     monitor1.setCursorPos(1, 1 + line)
  18.     monitor1.write("Reactor Status: ")
  19.     if (reactorActive) then
  20.         monitor1.blit("ACTIVE", "dddddd", "ffffff")
  21.     else
  22.         monitor1.blit("INACTIVE", "eeeeeeee", "ffffffff")
  23.     end
  24.     line = line + 1
  25.  
  26.     monitor1.setCursorPos(1, 1 + line)
  27.     bufferFullness = 10 * reactor.getEnergyStored() / 10000000
  28.     monitor1.write("Buffer Status:")
  29.     for i = 1, bufferFullness, 1 do
  30.         monitor1.blit(" ","5","5")
  31.     end
  32.     for i = 1, 10 - bufferFullness, 1 do
  33.         monitor1.blit(" ","4","4")
  34.     end
  35.  
  36.     if (reactorActive) then
  37.         if (reactor.getEnergyStored() > maxBuffer) then
  38.             reactor.setActive(false)
  39.             reactorActive = false
  40.             print("Buffer full, shutting down")
  41.             monitor1.setCursorPos(w / 2 - 6, h / 2)
  42.             monitor1.blit("Shutting Down...", "dddddddddddddddd", "0000000000000000")
  43.         end
  44.     else
  45.         if (reactor.getEnergyStored() < minBuffer) then
  46.             reactor.setActive(true)
  47.             reactorActive = true
  48.             print("Buffer empty, restarting reactor")
  49.             monitor1.setCursorPos(w / 2 - 6, h / 2)
  50.             monitor1.blit("Starting Up...", "dddddddddddddd", "00000000000000")
  51.         end
  52.     end
  53.    
  54.     os.sleep(10)
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement