Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- BigReactor Control
- -- by jivebiscuit
- -- updated 6 May 2016
- -- Set Peripherals
- local m = peripheral.find("monitor")
- local mX = 39
- local mY = 19
- local c = peripheral.find("tile_blockcapacitorbank_name")
- local r = peripheral.find("BigReactors-Reactor")
- -- EnderIO Capacitor Bank Setup
- local SingleCapStored = c.getEnergyStored()
- local SingleCapMax = c.getMaxEnergyStored()
- local CapMult = 14 -- Number of individual capacitor bank blocks
- local AllCapStored = (SingleCapStored*CapMult)
- local AllCapMax = (SingleCapMax*CapMult)
- local CapPercent = (AllCapStored/AllCapMax)
- function draw_text(x,y, text, text_color, bg_color)
- m.setBackgroundColor(bg_color)
- m.setTextColor(text_color)
- m.setCursorPos(x,y)
- m.write(text)
- end
- function draw_line(x, y, length, color)
- m.setBackgroundColor(color)
- m.setCursorPos(x,y)
- m.write(string.rep(" ", length))
- end
- function progress_bar(x,y, length, minVal, maxVal, bar_color, bg_color)
- draw_line(x,y, length, bg_color)
- local barSize = math.floor((minVal/maxVal) * length)
- draw_line(x,y, barSize, bar_color)
- end
- function button(x,y, length, text, text_color, bg_color)
- draw_line(x,y, length, bg_color)
- m.setBackgroundColor(bg_color)
- m.setTextColor(text_color)
- m.setCursorPos(x+2,y)
- m.write(text)
- end
- function clearcolors()
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.white)
- end
- -- Begin Display
- m.clear()
- clearcolors()
- -- Reactor Status and Buttons
- draw_text(1,1,"Reactor ", colors.yellow, colors.black)
- active = r.getActive()
- if active
- then draw_text(9,1,"ONLINE", colors.lime, colors.black)
- else draw_text(9,1,"OFFLINE", colors.red, colors.black)
- end
- button(26,1, 6,"ON", colors.white, colors.gray)
- button(33,1, 6,"OFF", colors.white, colors.blue)
- -- Control Rod Status
- draw_text(1,3,"Control Rods ", colors.yellow, colors.black)
- local minVal = r.getControlRodLevel(1)
- local maxVal = 100
- local percent = r.getControlRodLevel(1)
- draw_text(20,3,r.getControlRodLevel(1).."%", colors.white, colors.black)
- progress_bar(2,4, 21, minVal, maxVal, colors.blue, colors.gray)
- -- Fuel Temps and Levels
- draw_text(1,5,"Fuel Level:", colors.yellow, colors.black)
- local minVal = r.getFuelAmount()
- local maxVal = r.getFuelAmountMax()
- local percent = math.floor((minVal/maxVal)*100)
- draw_text(20,5, percent.."%",colors.white, colors.black)
- if percent < 25 then
- progress_bar(2,6, 21, minVal, maxVal, colors.red, colors.gray)
- else if percent < 50 then
- progress_bar(2,6, 21, minVal, maxVal, colors.orange, colors.gray)
- else if percent < 75 then
- progress_bar(2,6, 21, minVal, maxVal, colors.yellow, colors.gray)
- else if percent <= 100 then
- progress_bar(2,6, 21, minVal, maxVal, colors.green, colors.gray)
- end
- end
- end
- end
- draw_text(1,7,"Producing "..r.getEnergyProducedLastTick().." RF/t", colors.white, colors.black)
- draw_text(1,8,"Consuming "..r.getFuelConsumedLastTick().." mb/t", colors.white, colors.black)
- draw_text(1,9,"Fuel Temp "..math.floor(r.getFuelTemperature()).." C", colors.white, colors.black)
- draw_text(1,10,"Case Temp "..math.floor(r.getCasingTemperature()).." C", colors.white, colors.black)
- clearcolors()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement