Advertisement
Guest User

reactor

a guest
May 6th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.14 KB | None | 0 0
  1. -- BigReactor Control
  2. -- by jivebiscuit
  3. -- updated 6 May 2016
  4.  
  5. -- Set Peripherals
  6. local m = peripheral.find("monitor")
  7. local mX = 39
  8. local mY = 19
  9. local c = peripheral.find("tile_blockcapacitorbank_name")
  10. local r = peripheral.find("BigReactors-Reactor")
  11.  
  12. -- EnderIO Capacitor Bank Setup
  13. local SingleCapStored = c.getEnergyStored()
  14. local SingleCapMax = c.getMaxEnergyStored()
  15. local CapMult = 14 -- Number of individual capacitor bank blocks
  16. local AllCapStored = (SingleCapStored*CapMult)
  17. local AllCapMax = (SingleCapMax*CapMult)
  18. local CapPercent = (AllCapStored/AllCapMax)
  19.  
  20. function draw_text(x,y, text, text_color, bg_color)
  21.   m.setBackgroundColor(bg_color)
  22.   m.setTextColor(text_color)
  23.   m.setCursorPos(x,y)
  24.   m.write(text)
  25.   end
  26.  
  27. function draw_line(x, y, length, color)
  28.   m.setBackgroundColor(color)
  29.   m.setCursorPos(x,y)
  30.   m.write(string.rep(" ", length))
  31. end
  32.  
  33. function progress_bar(x,y, length, minVal, maxVal, bar_color, bg_color)
  34.   draw_line(x,y, length, bg_color)
  35.   local barSize = math.floor((minVal/maxVal) * length)
  36.   draw_line(x,y, barSize, bar_color)
  37. end
  38.  
  39. function button(x,y, length, text, text_color, bg_color)
  40.   draw_line(x,y, length, bg_color)
  41.   m.setBackgroundColor(bg_color)
  42.   m.setTextColor(text_color)
  43.   m.setCursorPos(x+2,y)
  44.   m.write(text)
  45. end
  46.  
  47. function clearcolors()
  48.   m.setBackgroundColor(colors.black)
  49.   m.setTextColor(colors.white)
  50. end
  51.  
  52. -- Begin Display
  53. m.clear()
  54. clearcolors()
  55.  
  56. -- Reactor Status and Buttons
  57. draw_text(1,1,"Reactor ", colors.yellow, colors.black)
  58. active = r.getActive()
  59. if active
  60.   then draw_text(9,1,"ONLINE", colors.lime, colors.black)
  61.   else draw_text(9,1,"OFFLINE", colors.red, colors.black)
  62. end
  63.  
  64. button(26,1, 6,"ON", colors.white, colors.gray)
  65. button(33,1, 6,"OFF", colors.white, colors.blue)
  66.  
  67. -- Control Rod Status
  68. draw_text(1,3,"Control Rods ", colors.yellow, colors.black)
  69. local minVal = r.getControlRodLevel(1)
  70. local maxVal = 100
  71. local percent = r.getControlRodLevel(1)
  72. draw_text(20,3,r.getControlRodLevel(1).."%", colors.white, colors.black)
  73. progress_bar(2,4, 21, minVal, maxVal, colors.blue, colors.gray)
  74.  
  75. -- Fuel Temps and Levels
  76. draw_text(1,5,"Fuel Level:", colors.yellow, colors.black)
  77. local minVal = r.getFuelAmount()
  78. local maxVal = r.getFuelAmountMax()
  79. local percent = math.floor((minVal/maxVal)*100)
  80. draw_text(20,5, percent.."%",colors.white, colors.black)
  81.  
  82. if percent < 25 then
  83.   progress_bar(2,6, 21, minVal, maxVal, colors.red, colors.gray)
  84.   else if percent < 50 then
  85.   progress_bar(2,6, 21, minVal, maxVal, colors.orange, colors.gray)
  86.   else if percent < 75 then
  87.   progress_bar(2,6, 21, minVal, maxVal, colors.yellow, colors.gray)
  88.   else if percent <= 100 then
  89.   progress_bar(2,6, 21, minVal, maxVal, colors.green, colors.gray)
  90. end
  91. end
  92. end
  93. end
  94.  
  95. draw_text(1,7,"Producing "..r.getEnergyProducedLastTick().." RF/t", colors.white, colors.black)
  96.  
  97. draw_text(1,8,"Consuming "..r.getFuelConsumedLastTick().." mb/t", colors.white, colors.black)
  98.  
  99. draw_text(1,9,"Fuel Temp "..math.floor(r.getFuelTemperature()).." C", colors.white, colors.black)
  100.  
  101. draw_text(1,10,"Case Temp "..math.floor(r.getCasingTemperature()).." C", colors.white, colors.black)
  102.  
  103. clearcolors()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement