Advertisement
Guest User

startup

a guest
Aug 4th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.55 KB | None | 0 0
  1. while true do
  2.  
  3. local mon = peripheral.wrap("monitor_0")
  4. local reactor1 = peripheral.wrap("BigReactors-Reactor_1")
  5. local reactor2 = peripheral.wrap("BigReactors-Reactor_2")
  6. local bank = peripheral.wrap("tile_blockcapacitorbank_name_1")
  7. local high = 1700000000
  8. local low = 900000000
  9. local bankstorage = bank.getEnergyStored()
  10. local reactorenergy1 = reactor1.getEnergyProducedLastTick()
  11. local reactorenergy2 = reactor2.getEnergyProducedLastTick()
  12. local fuelused1 = reactor1.getFuelConsumedLastTick()
  13. local fuelused2 = reactor2.getFuelConsumedLastTick()
  14. local rod1 = reactor1.getControlRodLevel(1)
  15. local rod2 = reactor2.getControlRodLevel(2)
  16. local fuelamount = reactor1.getFuelAmount()
  17. local fuelamount2 = reactor2.getFuelAmount()
  18. local fuelamountmax = reactor1.getFuelAmountMax()
  19. local fuelamountmax2 = reactor2.getFuelAmountMax()
  20. local numCapacitors = 72
  21.  
  22. mon.clear()
  23. mon.setTextScale(2)
  24.  
  25. mon.setTextColor(colors.yellow)
  26. mon.setCursorPos(1,3)
  27. mon.write("--------------------------------")
  28. --reactor1
  29. mon.setCursorPos(8,1)
  30. mon.setTextColor(colors.purple)
  31. mon.write("Reactor1")
  32. mon.setCursorPos(8,2)
  33. if reactor1.getActive(true) then
  34. mon.setTextColor(colors.lime)
  35. mon.write("Online") else
  36. mon.setTextColor(colors.red)
  37. mon.write("Offline")
  38. end
  39. --reactor2
  40. mon.setCursorPos(21,1)
  41. mon.setTextColor(colors.purple)
  42. mon.write("Reactor2")
  43. mon.setCursorPos(21,2)
  44. if reactor2.getActive(true) then
  45. mon.setTextColor(colors.lime)
  46. mon.write("Online") else
  47. mon.setTextColor(colors.red)
  48. mon.write("Offline")
  49. end
  50. --RF/t
  51. --reactor1
  52. mon.setCursorPos(1,4)
  53. mon.setTextColor(colors.orange)
  54. mon.write("RF/T:")
  55. mon.setCursorPos(8,4)
  56. mon.setTextColor(colors.cyan)
  57. mon.write(comma_value(reactorenergy1))
  58. --reactor2
  59. mon.setCursorPos(21,4)
  60. mon.setTextColor(colors.cyan)
  61. mon.write(comma_value(reactorenergy2))
  62. --Both reactors Total rf/t
  63. mon.setCursorPos(1,5)
  64. mon.setTextColor(colors.orange)
  65. mon.write("Total:")
  66. mon.setCursorPos(8,5)
  67. mon.setTextColor(colors.cyan)
  68. mon.write(comma_value(reactorenergy1+reactorenergy2))
  69. --------------------------------------------------
  70. --bankTotal%
  71. mon.setCursorPos(1,9)
  72. mon.setTextColor(colors.orange)
  73. mon.write("RF:")
  74. mon.setCursorPos(8,9)
  75. mon.setTextColor(colors.cyan)
  76. bankstoragepercent = math.floor((bankstorage/bank.getMaxEnergyStored())*100)
  77. mon.write(bankstoragepercent.."%")
  78. --bankTotal
  79. mon.setCursorPos(14,9)
  80. mon.setTextColor(colors.cyan)
  81. mon.write(comma_value(bankstorage*numCapacitors))
  82. ----------------------------------------------
  83. --reactor fuel amount
  84. --reactor1
  85. mon.setCursorPos(1,6)
  86. mon.setTextColor(colors.orange)
  87. mon.write("Fuel:")
  88. mon.setCursorPos(8,6)
  89. mon.setTextColor(colors.cyan)
  90. fuelpercentage = math.floor((fuelamount/fuelamountmax)*100)
  91. mon.write(fuelpercentage.."%")
  92. --reactor2
  93. mon.setCursorPos(21,6)
  94. mon.setTextColor(colors.cyan)
  95. fuelpercentage = math.floor((fuelamount2/fuelamountmax2)*100)
  96. mon.write(fuelpercentage.."%")
  97. --------------------------------------------
  98. --reactor rod%
  99. --reactor1
  100. mon.setCursorPos(1,7)
  101. mon.setTextColor(colors.orange)
  102. mon.write("Rod%:")
  103. mon.setCursorPos(8,7)
  104. mon.setTextColor(colors.cyan)
  105. rodpercentage = math.floor((rod1/100)*100)
  106. mon.write(rodpercentage.."%")
  107. --reactor2
  108. mon.setCursorPos(21,7)
  109. mon.setTextColor(colors.cyan)
  110. rodpercentage = math.floor((rod2/100)*100)
  111. mon.write(rodpercentage.."%")
  112. ---------------------------------------------
  113. --reactor fuel used/t
  114. --reactor1
  115. mon.setCursorPos(1,8)
  116. mon.setTextColor(colors.orange)
  117. mon.write("Used/T:")
  118. mon.setCursorPos(8,8)
  119. fuelused = math.floor(fuelused1*100)
  120. fuelused = fuelused/100
  121. mon.setTextColor(colors.cyan)
  122. mon.write(fuelused)
  123. --reactor2
  124. mon.setCursorPos(21,8)
  125. mon.setTextColor(colors.cyan)
  126. fuelused = math.floor(fuelused2*100)
  127. fuelused = fuelused2/100
  128. mon.write(fuelused)
  129. ------------------------------------------
  130. --function reactor control rod levels
  131. --reactor1
  132. if bankstorage*numCapacitors <= low then
  133. reactor1.setAllControlRodLevels(0)
  134. end
  135. if bankstorage*numCapacitors >= high then
  136. reactor1.setAllControlRodLevels(100)
  137. end
  138. --reactor2
  139. if bankstorage*numCapacitors <= low then
  140. reactor2.setAllControlRodLevels(0)
  141. end
  142. if bankstorage*numCapacitors >= high then
  143. reactor2.setAllControlRodLevels(100)
  144. end
  145.  
  146. function comma_value(amount)
  147.   local formatted = amount
  148.   local swap = false
  149.   if formatted < 0 then
  150.     formatted = formatted*-1
  151.     swap = true
  152.   end
  153. while true do
  154.   formatted, k = string.gsub(formatted, "^(%d+)(%d%d%d)", '%1,%2')
  155.   if k == 0 then
  156.        break
  157.    end
  158. end
  159. if swap then
  160.       formatted = "-"..formatted
  161.       end
  162.       return formatted
  163.   end  
  164. sleep(0)
  165. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement