Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local m = peripheral.wrap("left")
- local c1 = peripheral.wrap("draconic_rf_storage_0")
- local c2 = peripheral.wrap("draconic_rf_storage_1")
- local c3 = peripheral.wrap("draconic_rf_storage_2")
- local c4 = peripheral.wrap("draconic_rf_storage_3")
- monX, monY = m.getSize()
- function clear()
- m.setBackgroundColor(colors.black)
- m.clear()
- m.setCursorPos(1,1)
- m.setTextScale(0.5)
- end
- function drawText(x, y, text, color_txt, color_bg)
- m.setBackgroundColor(color_bg)
- m.setTextColor(color_txt)
- m.setCursorPos(x,y)
- m.write(text)
- end
- function drawLine(x, y, length, height, color_line)
- for yPos = y, y+height do
- m.setBackgroundColor(color_line)
- m.setCursorPos(x,yPos)
- m.write(string.rep(" ", length))
- end
- end
- function drawProg(x, y, name, length, height, minVal, maxVal, color_bg)
- if minVal > (.5*maxVal) then
- color_line = colors.green
- elseif minVal < (.25*maxVal) then
- color_line = colors.red
- else
- color_line = colors.orange
- end
- drawLine(x, y, length, height, color_bg)
- local barSize = (minVal/maxVal)*length
- drawLine(x, y, barSize, height, color_line)
- local text = name.." "..((minVal/maxVal)*100).."%"
- if barSize > monX/2+#text/2 then
- drawText(monX/2-#text/2+1, y+height/2, text, colors.black, color_line)
- elseif barSize > #text then
- drawText((x+barSize)-#text, y+height/2, text, colors.black, color_line)
- else
- drawText(monX/2-#text/2+1, y+height/2, text, colors.black, color_bg)
- end
- end
- local function comma_value(amount)
- local formatted = amount
- while true do
- formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
- if (k==0) then
- break
- end
- end
- return formatted
- end
- local function ReadableNumber(num, places)
- local ret
- local placeValue = ("%%.%df"):format(places or 0)
- if not num then
- return 0
- elseif num >= 1000000000000 then
- ret = placeValue:format(num / 1000000000000) .. " Trillion" -- trillion
- elseif num >= 1000000000 then
- ret = placeValue:format(num / 1000000000) .. " Billion" -- billion
- elseif num >= 1000000 then
- ret = placeValue:format(num / 1000000) .. " Million" -- million
- elseif num >= 1000 then
- ret = placeValue:format(num / 1000) .. " Kilo" -- thousand
- else
- ret = num -- hundreds
- end
- return ret
- end
- while true do
- clear()
- c1Max = c1.getMaxEnergyStored()
- c1Cur = c1.getEnergyStored()
- c2Max = c2.getMaxEnergyStored()
- c2Cur = c2.getEnergyStored()
- c3Max = c3.getMaxEnergyStored()
- c3Cur = c3.getEnergyStored()
- c4Max = c4.getMaxEnergyStored()
- c4Cur = c4.getEnergyStored()
- pMax = c1Max + c2Max + c3Max + c4Max
- pCur = c1Cur + c2Cur + c3Cur + c4Cur
- drawProg(2, 2, "Core 1:", monX-2, 2, c1Cur, c1Max, colors.gray)
- drawProg(2, 6, "Core 2:", monX-2, 2, c2Cur, c2Max, colors.gray)
- drawProg(2, 10, "Core 3:", monX-2, 2, c3Cur, c3Max, colors.gray)
- drawProg(2, 14, "Core 4:", monX-2, 2, c4Cur, c4Max, colors.gray)
- drawText(2, 21, "Core 1: "..ReadableNumber(c1Cur, 2).." ".."RF", colors.white, colors.black)
- drawText(2, 23, "Core 2: "..ReadableNumber(c2Cur, 2).." ".."RF", colors.white, colors.black)
- drawText(2, 25, "Core 3: "..ReadableNumber(c3Cur, 2).." ".."RF", colors.white, colors.black)
- drawText(2, 27, "Core 4: "..ReadableNumber(c4Cur, 2).." ".."RF", colors.white, colors.black)
- drawText(2, monY-7, "Total Power: "..ReadableNumber(pCur, 2).." ".."RF", colors.white, colors.black)
- drawProg(2, monY-3, "Total Power:", monX-2, 2, pCur, pMax, colors.gray)
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement