Advertisement
MikiCZEch

BigReactors (Reactor/Turbine Monitor)

Jan 25th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.34 KB | None | 0 0
  1. -- BigReactor monitor by MikiCZEch
  2. print("CTRL+T iterupt program.")
  3. monitor = peripheral.wrap("top")
  4. reactor = peripheral.wrap("BigReactors-Reactor_50")
  5. turbine = peripheral.wrap("BigReactors-Turbine_14")
  6.  
  7. monitor.clear()
  8. -- Reactor Template
  9. monitor.setCursorPos(1,1)
  10. monitor.setTextColor(colors.blue)
  11. monitor.write("Reactor Monitor")
  12. monitor.setCursorPos(1,2)
  13. monitor.setTextColor(colors.lightGray)
  14. monitor.write("Status: ")
  15. monitor.setCursorPos(1,3)
  16. monitor.write("CoreTemp: ")
  17. monitor.setCursorPos(1,4)
  18. monitor.write("SteamGen: ")
  19. monitor.setCursorPos(1,5)
  20. monitor.write("Reactivity: ")
  21. -- Turbine Template
  22. zpc2 = 20 -- zero position column 2
  23. monitor.setCursorPos(zpc2,1)
  24. monitor.setTextColor(colors.blue)
  25. monitor.write("Turbine Monitor")
  26. monitor.setCursorPos(zpc2,2)
  27. monitor.setTextColor(colors.lightGray)
  28. monitor.write("Status: ")
  29. monitor.setCursorPos(zpc2,3)
  30. monitor.write("RotorSpd: ")
  31. monitor.setCursorPos(zpc2,4)
  32. monitor.write("EnergyGen: ")
  33. monitor.setCursorPos(zpc2,5)
  34. monitor.write("Energy: ")
  35. monitor.setCursorPos(zpc2,6)
  36. monitor.write("Transfer: ")
  37. -- Reactor Function
  38. function statusR()
  39.   if reactor.getActive() == true then
  40.     monitor.setTextColor(colors.green)
  41.     a = "Online "
  42.     else
  43.     monitor.setTextColor(colors.red)
  44.     a = "Offline"
  45.   end
  46.   monitor.setCursorPos(8,2)
  47.   monitor.write(a)
  48.   monitor.setTextColor(colors.white)
  49. end
  50. function coretemp()
  51.   ft = math.floor(reactor.getFuelTemperature())
  52.   local space = ("")
  53.   if ft < 100 then
  54.     space = (" ")
  55.   end
  56.   monitor.setCursorPos(12,3)
  57.   monitor.write(space..ft.."stC")
  58. end
  59. function steamgen()
  60.   hfplt = reactor.getHotFluidProducedLastTick()
  61.   local space = ("")
  62.   if hfplt < 1000 then
  63.     space = (" ")
  64.     if hfplt < 100 then
  65.       space = ("  ")
  66.       if hfplt < 10 then
  67.         space = ("   ")
  68.       end
  69.     end
  70.   end
  71.   monitor.setCursorPos(11,4)
  72.   monitor.write(space..hfplt.."mB/t")
  73. end
  74. function reactivity()
  75.   monitor.setCursorPos(12,5)
  76.   fr = math.floor(reactor.getFuelReactivity())
  77.   monitor.write(fr.."%")
  78. end
  79. -- Turbine function
  80. function statusT()
  81.   if turbine.getActive() == true then
  82.     monitor.setTextColor(colors.green)
  83.     a = "Online "
  84.     else
  85.     monitor.setTextColor(colors.red)
  86.     a = "Offline"
  87.   end
  88.   monitor.setCursorPos(zpc2+8,2)
  89.   monitor.write(a)
  90.   monitor.setTextColor(colors.white)
  91. end
  92. function rotorspd()
  93.   rs = math.floor(turbine.getRotorSpeed())
  94.   local space = ("")
  95.   if rs < 1000 then
  96.     space = (" ")
  97.     if rs < 100 then
  98.       space = ("  ")
  99.       if rs < 10 then
  100.         space = ("   ")
  101.       end
  102.     end
  103.   end
  104.   monitor.setCursorPos(zpc2+11,3)
  105.   monitor.write(space..rs.."RPM")
  106. end
  107. function energygen()
  108.   eplt = math.floor(turbine.getEnergyProducedLastTick())
  109.   local space = ("")
  110.   if eplt < 1000 then
  111.     space = (" ")
  112.     if eplt < 100 then
  113.       space = ("  ")
  114.       if eplt < 10 then
  115.         space = ("   ")
  116.       end
  117.     end
  118.   end
  119.   monitor.setCursorPos(zpc2+11,4)
  120.   monitor.write(space..eplt.."RF/t")
  121. end
  122. function energy()
  123.   es = math.floor(turbine.getEnergyStored())
  124.   local space = ("")
  125.   if es < 10000000 then
  126.     space = (" ")
  127.     if es < 100000 then
  128.       space = ("  ")
  129.       if es < 10000 then
  130.         space = ("   ")
  131.         if es < 1000 then
  132.           space = ("    ")
  133.           if es < 100 then
  134.             space = ("     ")
  135.             if es < 10 then
  136.               space = ("      ")
  137.             end
  138.           end
  139.         end
  140.       end
  141.     end
  142.   end
  143.   monitor.setCursorPos(zpc2+8,5)
  144.   monitor.write(space..es.."RF")
  145. end
  146. function transfer()
  147.   es1 = turbine.getEnergyStored()
  148.   os.sleep(1)
  149.   es2 = turbine.getEnergyStored()
  150.   et = math.floor((es2 - es1)/20)
  151.   local space = ("")
  152.   if es < 10000 then
  153.     space = (" ")
  154.     if es < 1000 then
  155.       space = ("  ")
  156.       if es < 100 then
  157.         space = ("   ")
  158.         if es < 10 then
  159.           space = ("    ")
  160.           if es < 0 then
  161.             space = ("   ")
  162.             if es < -9 then
  163.               space = ("  ")
  164.               if es < -99 then
  165.                 space = (" ")
  166.                 if es < -999 then
  167.                   space = ("")
  168.                 end
  169.               end
  170.             end
  171.           end
  172.         end
  173.       end
  174.     end
  175.   end
  176.   monitor.setCursorPos(zpc2+10,6)
  177.   monitor.write(space..et.."RF/t")
  178. end
  179. -- Program Cycle
  180. while true do
  181.   statusR()
  182.   coretemp()
  183.   steamgen()
  184.   reactivity()
  185.   statusT()
  186.   rotorspd()
  187.   energygen()
  188.   energy()
  189.   transfer()
  190. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement