JaMaNi133

reactor-main

Apr 23rd, 2022 (edited)
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.58 KB | None | 0 0
  1. monitor = peripheral.wrap("monitor_0")
  2. reactor = peripheral.wrap("BigReactors-Reactor_1")
  3.  
  4. maxCapacity = 10000000
  5.  
  6.  
  7.  
  8.  
  9. while true do
  10.     monitor.clear()
  11.     stored = reactor.getEnergyStored()
  12.     tempFuel = reactor.getFuelTemperature()
  13.     tempCase = reactor.getCasingTemperature()
  14.     energypertick = reactor.getEnergyProducedLastTick()
  15.     reactivity = reactor.getFuelReactivity()
  16.     waste = reactor.getWasteAmount()
  17.     fuel = reactor.getFuelAmount()
  18.     feulpT = reactor.getFuelConsumedLastTick()
  19.  
  20.     RFpmB = energypertick / feulpT --RF per milli Bucket
  21.    
  22.  
  23.     ctrlRods = ((stored / maxCapacity) - 0.5 )*400
  24.  
  25.     if ctrlRods < 0 then
  26.         ctrlRods = 0
  27.     end
  28.  
  29.     if ctrlRods > 95 then
  30.         ctrlRods = 100
  31.     end
  32.     onoff = ctrlRods < 100
  33.     if onoff then
  34.         monitor.setBackgroundColor(colors.green)
  35.     else
  36.         monitor.setBackgroundColor(colors.red)
  37.     end
  38.  
  39.  
  40.    
  41.     monitor.setCursorPos(1,1)
  42.     if onoff then
  43.         monitor.write("Reactor Status :RUNNING                ")
  44.     else
  45.         monitor.write("Reactor Status :NOT RUNNING                ")
  46.     end
  47.    
  48.     monitor.setCursorPos(28,1)
  49.     monitor.write(string.format("  %.1f",100-ctrlRods))
  50.     monitor.write("%")
  51.    
  52.    
  53.     reactor.setAllControlRodLevels(ctrlRods)
  54.  
  55.     monitor.write("                                   ")
  56.     monitor.setBackgroundColor(colors.black)
  57.  
  58.     monitor.setCursorPos(1,3)
  59.     monitor.write(string.format("Case temperature: %.1f °C",tempCase))
  60.  
  61.     monitor.setCursorPos(1,4)
  62.     monitor.write(string.format("Fuel temperature: %.1f °C",tempFuel))
  63.  
  64.     monitor.setCursorPos(1,5)
  65.     monitor.write(string.format("energy stored: %.0f RF",stored))
  66.  
  67.     monitor.setCursorPos(1,6)
  68.     monitor.write(string.format("energy produced: %.2f RF/t",energypertick))
  69.  
  70.     monitor.setCursorPos(1,7)
  71.     monitor.write(string.format("fuel used: %.4f mb/t | %.0f RF/mB",feulpT,RFpmB))
  72.  
  73.     monitor.setCursorPos(1,8)
  74.     monitor.write(string.format("fuel | waste: %.0f mB | %.0f mB",fuel,waste))
  75.  
  76.     monitor.setCursorPos(1,9)
  77.     monitor.write(string.format("rectivity: %.2f ",reactivity))
  78.     monitor.write("%")
  79.  
  80.     monitor.setBackgroundColor(colors.orange)
  81.     monitor.setCursorPos(1,11)
  82.     monitor.write("Reboot                                              ")
  83.     monitor.setBackgroundColor(colors.black)
  84.     monitor.setCursorPos(1,12)
  85.     monitor.write(">> code made by ERiChu <<")
  86.  
  87.     os.startTimer(1)
  88.     event,side,xpos,ypos = os.pullEvent()
  89.  
  90.     if event == "monitor_touch" then
  91.         if ypos == 11 then
  92.             shell.run("reboot")
  93.         end
  94.     end
  95.  
  96. end
Add Comment
Please, Sign In to add comment