SHARE
TWEET

reactorControl

a guest Mar 22nd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Find and bind the reactor
  2. modem = peripheral.wrap("bottom")
  3. reactor = modem.getNamesRemote()[1]
  4. reactor = peripheral.wrap(reactor)
  5.  
  6. monitor = peripheral.wrap("top")
  7. monitor.setTextScale(2)
  8. controlRodPercent = 0
  9.  
  10. while (true) do
  11.     buffer = reactor.getEnergyCapacity()
  12.     filled = reactor.getEnergyStored()
  13.     energyPercent = math.floor(filled/buffer * 10000) / 100
  14.     monitor.setCursorPos(1,1)
  15.     monitor.write("Buffer: ")
  16.     monitor.write(math.floor(energyPercent * 100)/100)
  17.     monitor.write("%")
  18.    
  19.     monitor.setCursorPos(1, 2)
  20.     monitor.setBackgroundColor(colors.green)
  21.     for i = 1, math.floor(energyPercent/10) do
  22.         monitor.write(" ")
  23.     end
  24.    
  25.     monitor.setBackgroundColor(colors.red)
  26.     for i = math.floor(energyPercent/10) + 1, 10 do
  27.         monitor.write(" ")
  28.     end
  29.    
  30.     monitor.setBackgroundColor(colors.black)
  31.    
  32.     monitor.setCursorPos(1, 3)
  33.     monitor.write("Control rods: ")
  34.     monitor.write(controlRodPercent)
  35.     monitor.write("%")
  36.     controlRodPercent = energyPercent
  37.    
  38.     monitor.setCursorPos(1, 4)
  39.     monitor.setBackgroundColor(colors.yellow)
  40.     for i = 1, 10 - math.floor(energyPercent/10) do
  41.         monitor.write(" ")
  42.     end
  43.    
  44.     monitor.setBackgroundColor(colors.gray)
  45.     for i = 10 - math.floor(energyPercent/10) + 1, 10 do
  46.         monitor.write(" ")
  47.     end
  48.    
  49.     monitor.setBackgroundColor(colors.black)
  50.    
  51.     monitor.setCursorPos(1,5)
  52.     monitor.write("Output: ")
  53.     monitor.write(string.format("%i", math.floor(reactor.getEnergyProducedLastTick())))
  54.     monitor.write(" RF/t")
  55.    
  56.     monitor.setCursorPos(1, 6)
  57.     monitor.setBackgroundColor(colors.green)
  58.     for i = 1, math.floor((reactor.getEnergyProducedLastTick()/65300)*10) do
  59.         monitor.write(" ")
  60.     end
  61.    
  62.     monitor.setBackgroundColor(colors.red)
  63.     for i = math.floor(reactor.getEnergyProducedLastTick()/65300*10) + 1, 10 do
  64.         monitor.write(" ")
  65.     end
  66.    
  67.     monitor.setBackgroundColor(colors.black)
  68.    
  69.     reactor.setAllControlRodLevels(controlRodPercent)
  70.     os.sleep(0.5)
  71.     monitor.clear()  
  72. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top