Advertisement
Guest User

rctrl

a guest
Oct 24th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. --Copyright 2014 Seth Traverse (WinMac32)
  2. print("Running reactor control utility.")
  3. mfe = peripheral.wrap("top")
  4.  
  5. local reactorSide = "right"
  6.  
  7. redstone.setOutput(reactorSide, false)
  8. local on = false
  9.  
  10. function rText(x, y, text)
  11.   ox, oy = term.getCursorPos()
  12.   term.setCursorPos(x, y)
  13.   term.write(text)
  14.   term.setCursorPos(ox, oy)
  15. end
  16.  
  17. function renderStats(cap, stored, perc)
  18.   scrX = term.getSize()
  19.   x = scrX - 16
  20.   rText(x, 1, "Capacity: " .. cap)
  21.   rText(x, 2, "Stored: " .. stored)
  22.   rText(x, 3, "Percent: " .. perc)
  23. end
  24.  
  25. while 1 do
  26.   cap = mfe.getEUCapacity()
  27.   stored = mfe.getEUStored()
  28.   perc = stored / cap * 100
  29.   renderStats(cap, stored, perc)
  30.  
  31.   if (redstone.getInput("left")) then
  32.     redstone.setOutput(reactorSide, false)
  33.     print("MANUAL SHUTDOWN ENABLED!!")
  34.     sleep(10)
  35.   else
  36.     if (perc < 80 and not on) then
  37.       redstone.setOutput(reactorSide, true)
  38.       print("Storage percentage less than 80%")
  39.       print("-> Reactor turned on")
  40.       on = true
  41.     elseif (perc > 95 and on) then
  42.       redstone.setOutput(reactorSide, false)
  43.       print("Storage percentage greater than 95%")
  44.       print("-> Reactor turned off")
  45.       on = false
  46.     end
  47.   end
  48.   sleep(2)  
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement