Guest User

reactos

a guest
Sep 18th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.91 KB | None | 0 0
  1. -- Reactor Monitor
  2.  
  3. local reactor
  4. reactor = peripheral.wrap("back")
  5. monitor = peripheral.wrap("right")
  6. monitor.setTextScale(.5)
  7. ---Rounding to be used later
  8. --Rounding to remove decimal
  9. function round (num, idp)
  10. local mult = 10^(idp or 0)
  11. return math.floor(num * mult + 0.5) / mult
  12. end
  13. --Rounding to 1 place
  14. function round1 (num, idp)
  15. local mult = 10^(idp or 1)
  16. return math.floor(num * mult + 0.5) / mult
  17. end
  18.  
  19.  
  20. --Label
  21. term.setTextColor(colors.lightBlue)
  22. print("---------------------------")
  23. print("General Reactor Information")
  24. print("---------------------------")
  25. print(" ")
  26.  
  27. term.setTextColor(colors.white)
  28. --Gets and displays if the comp and reactor are connected.
  29. write("Connection Status:")
  30. if reactor.getConnected(true) then
  31. term.setTextColor(colors.green)
  32. print("Connected!")
  33. else
  34. term.setTextColor(colors.red)
  35. print("Not Connected!")
  36. end
  37. term.setTextColor(colors.white)
  38.  
  39. --Gets and displays the activity status of the reactor.
  40. write("Activity Status:")
  41. if reactor.getActive(true) then
  42. term.settextcolor(colors.green)
  43. print("Active!") else
  44. term.setTextColor(colors.red)
  45. print("Inactive!")
  46. end
  47. term.setTextColor(colors.white)
  48. --Energy info
  49. local int energy = reactor.getEnergyStored()
  50. local int max = 10000000
  51. local decimal percent = round1((energy/max)*100)
  52. write("Stored Energy:")
  53. if percent >= 70.0 then
  54. term.setTextColor(colors.green)
  55. print(percent,"%")else
  56. if percent >= 40.0 then
  57. term.setTextColor(colors.orange)
  58. print(percent,"%")else
  59. if percent <= 39.9 then
  60. term.setTextColor(colors.red)
  61. print(percent,"%")
  62. end
  63. end
  64. end
  65. term.setTextColor(colors.white)
  66. --Fuel Amount
  67. local int f = reactor.getFuelAmount()
  68. --Max Fuel
  69. local int fm = reactor.getFuelAmountMax()
  70. --Fuel Percent
  71. local decimal pf = round1((f/fm)*100)
  72. --Needed fuel/Fuel Defecit(In Ingots)
  73. local int nf = round((fm-f)/1000)
  74. --Needed Fuel/Fuel Defecit(In stacks)
  75. local int st = round1(nf/64)
  76. print("Fuel Info:")
  77. write("    Fuel Percent:")
  78. if pf >=70.0 then
  79. term.setTextColor(colors.green)
  80. print(pf,"%") else
  81. if pf >= 40.0 then
  82. term.setTextColor(colors.orange)
  83. print(pf,"%") else
  84. if pf <= 39.9 then
  85. term.setTextColor(colors.red)
  86. print(pf,"%")
  87. end
  88. end
  89. end
  90. term.setTextColor(colors.white)
  91. write("    Fuel Needed:")
  92. term.setTextColor(colors.red)
  93. print(nf," ingots/",st," stacks")
  94.  
  95.  
  96. term.setTextColor(colors.lightBlue)
  97. --label
  98. print(" ")
  99. print("----------------------------")
  100. print("Control Rod Information")
  101. print("----------------------------")
  102. print(" ")
  103.  
  104. term.setTextColor(colors.white)
  105. --Gets and displays number of control rods
  106. write("Number of Control Rods:")
  107. local int rods = reactor.getNumberOfControlRods()
  108. term.setTextColor(colors.red)
  109. print(rods)
  110. term.setTextColor(colors.white)
  111.  
  112. --Gets control rod information
  113.  
  114. i = 0
  115.  
  116. while true do
  117.   local cr = reactor.getControlRodName(i)
  118.   local cl = reactor.getControlRodLevel(i)
  119.   print(cr,": ",cl)
  120.   i = i + 1
  121. if i > 17 then
  122. break
  123. end
  124. end
Advertisement
Add Comment
Please, Sign In to add comment