Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap("monitor_138")
- local core = peripheral.wrap("draconic_rf_storage_13")
- local gateBlock1 = peripheral.wrap("flux_gate_65")
- local gateBlock2 = peripheral.wrap("flux_gate_63")
- local gateBlock3 = peripheral.wrap("flux_gate_61")
- local gateBlock4 = peripheral.wrap("flux_gate_64")
- local gateBlock5 = peripheral.wrap("flux_gate_62")
- local gateBlock6 = peripheral.wrap("flux_gate_60")
- local gateExtra = peripheral.wrap("flux_gate_67")
- local mon, monX, monY
- monX, monY = monitor.getSize()
- mon = {}
- mon.monitor,mon.X, mon.Y = monitor, monX, monY
- function clear(mon)
- term.clear()
- term.setCursorPos(1,1)
- mon.monitor.setBackgroundColor(colors.black)
- mon.monitor.clear()
- mon.monitor.setCursorPos(1,1)
- end
- function draw_text(mon, x, y, text, text_color, bg_color)
- mon.monitor.setBackgroundColor(bg_color)
- mon.monitor.setTextColor(text_color)
- mon.monitor.setCursorPos(x,y)
- mon.monitor.write(text)
- end
- function draw_text_right(mon, offset, y, text, text_color, bg_color)
- mon.monitor.setBackgroundColor(bg_color)
- mon.monitor.setTextColor(text_color)
- mon.monitor.setCursorPos(mon.X-string.len(tostring(text))-offset,y)
- mon.monitor.write(text)
- end
- function draw_text_lr(mon, x, y, offset, text1, text2, text1_color, text2_color, bg_color)
- draw_text(mon, x, y, text1, text1_color, bg_color)
- draw_text_right(mon, offset, y, text2, text2_color, bg_color)
- end
- function draw_line(mon, x, y, length, color)
- if length < 0 then
- length = 0
- end
- mon.monitor.setBackgroundColor(color)
- mon.monitor.setCursorPos(x,y)
- mon.monitor.write(string.rep(" ", length))
- end
- function progress_bar(mon, x, y, length, minVal, maxVal, bar_color, bg_color)
- draw_line(mon, x, y, length, bg_color)
- local barSize = math.floor((minVal/maxVal) * length)
- draw_line(mon, x, y, barSize, bar_color)
- end
- function format_int(number)
- if number == nil then number = 0 end
- local i, j, minus, int, fraction = tostring(number):find('([-]?)(%d+)([.]?%d*)')
- int = int:reverse():gsub("(%d%d%d)", "%1,")
- return minus .. int:reverse():gsub("^,", "") .. fraction
- end
- local eMax
- local eNow
- local ePercent
- local eLast = 0
- local eFlow
- function update()
- while true do
- clear(mon)
- eMax = core.getMaxEnergyStored()
- eNow = core.getEnergyStored()
- ePercent = (math.floor(eNow/eMax*10000))/100
- eFlow = math.floor((eNow-eLast)/2)
- eLast = eNow
- -- terminal display
- print(" Capacity: " .. eMax .. " rf")
- print(" Energy: " .. eNow .. " rf ... " .. ePercent .. " %")
- print()
- if (eFlow > 0) then
- print("Avg. flow: +" .. eFlow .. " rf/t")
- else
- print("Avg. flow: " .. eFlow .. " rf/t")
- end
- print()
- -- monitor display
- draw_text_lr(mon, 2, 2, 0, "Main Energy Core", "Tier 7", colors.orange, colors.orange, colors.black)
- local energyColor
- if ePercent >= 75 then energyColor = colors.orange end
- if ePercent < 75 and ePercent >= 50 then energyColor = colors.red end
- if ePercent < 50 and ePercent >= 25 then energyColor = colors.purple end
- if ePercent < 25 then energyColor = colors.cyan end
- if eNow >= 1000000000000 then
- draw_text_lr(mon, 2, 4, 0, format_int((math.floor(eNow/1000000000))/1000) .. " T rf", ePercent .. " %", colors.lightGray, energyColor, colors.black)
- elseif eNow < 1000000000000 and eNow >= 1000000000 then
- draw_text_lr(mon, 2, 4, 0, format_int((math.floor(eNow/1000000))/1000) .. " B rf", ePercent .. " %", colors.lightGray, energyColor, colors.black)
- elseif eNow < 1000000000 and eNow >= 1000000 then
- draw_text_lr(mon, 2, 4, 0, format_int((math.floor(eNow/1000))/1000) .. " M rf", ePercent .. " %", colors.lightGray, energyColor, colors.black)
- else
- draw_text_lr(mon, 2, 4, 0, format_int(eNow) .. " rf", ePercent .. " %", colors.lightGray, energyColor, colors.black)
- end
- progress_bar(mon, 2, 5, mon.X-2, ePercent, 100, energyColor, colors.gray)
- local energyUpDown
- if eFlow > 0 then energyUpDown = colors.lime end
- if eFlow == 0 then energyUpDown = colors.gray end
- if eFlow < 0 then energyUpDown = colors.red end
- if eFlow >= math.abs(1000000000) then
- if eFlow > 0 then
- draw_text_lr(mon, 2, 7, 0, "Energy flow", "+" .. format_int((math.floor(eFlow/1000000))/1000) .. " B rf/t", colors.white, energyUpDown, colors.black)
- else
- draw_text_lr(mon, 2, 7, 0, "Energy flow", format_int((math.floor(eFlow/1000000))/1000) .. " B rf/t", colors.white, energyUpDown, colors.black)
- end
- elseif eFlow < math.abs(1000000000) and eFlow >= math.abs(1000000) then
- if eFlow > 0 then
- draw_text_lr(mon, 2, 7, 0, "Energy flow", "+" .. format_int((math.floor(eFlow/1000))/1000) .. " M rf/t", colors.white, energyUpDown, colors.black)
- else
- draw_text_lr(mon, 2, 7, 0, "Energy flow", format_int((math.floor(eFlow/1000))/1000) .. " M rf/t", colors.white, energyUpDown, colors.black)
- end
- else
- if eFlow > 0 then
- draw_text_lr(mon, 2, 7, 0, "Energy flow", "+" .. format_int(eFlow) .. " rf/t", colors.white, energyUpDown, colors.black)
- else
- draw_text_lr(mon, 2, 7, 0, "Energy flow", format_int(eFlow) .. " rf/t", colors.white, energyUpDown, colors.black)
- end
- end
- sleep(0.1)
- end
- end
- parallel.waitForAny(update)
Add Comment
Please, Sign In to add comment