Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- component = require("component")
- mfsu = component.ic2_te_mfsu
- mfsu2 = component.proxy(component.get("253d"))
- term = require("term")
- gpu = component.gpu
- colors = { black = 0x000000, white = 0xf8f8ff, blue = 0x0000ff, lightGray = 0xd9d9d9, red = 0xff0000,
- purple = 0x9b30ff, carrot = 0xffa500, magenta = 0xcd00cd, lightBlue = 0x87cefa, yellow = 0xffff00,
- lime = 0x32cd32, pink = 0xffc0cb, gray = 0x696969, brown = 0x8b4500, green = 0x006400, cyan = 0x008b8b,
- olive = 0x6b8e23, gold = 0x8b6914, orangered = 0xdb4e02, diamond = 0x0fa7c7,crimson = 0xaf002a,fuchsia = 0xfd3f92,
- folly = 0xff004f, frenchBlue = 0x0072bb, lilac = 0x86608e, flax = 0xeedc82, darkGray = 0x563c5c,
- englishGreen = 0x1b4d3e, eggplant = 0x614051, deepPink = 0xff1493, ruby = 0x843f5b, orange = 0xf5c71a,
- lemon = 0xffd300, darkBlue = 0x002e63, bitterLime = 0xbfff00 }
- bar_col = colors.gray
- default_bg = colors.black
- border_bar = colors.white
- text_col = colors.diamond
- stat_col = colors.gray
- gpu.setResolution(104,10)
- function dot(n)
- local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
- return left..(num:reverse():gsub('(%d%d%d)','%1.'):reverse())..right
- end
- function borderBar( x, y, len, s)
- gpu.setBackground(border_bar)
- gpu.fill(x,y, len, 1, s)
- gpu.setBackground(default_bg)
- end
- function Center(y,text) -- CENTERS TEXT
- w, h = gpu.getResolution()
- term.setCursor((w-string.len(text))/2+1, y)
- term.write(text)
- end
- function initbar(y, title)
- w, h = gpu.getResolution()
- x1 = w-w+2
- x2 = w-w+102
- x3 = w-w+4
- borderBar(x1, y+1, 102, " ")
- borderBar(x1, y+3, 102, " ")
- borderBar(x1, y+2, 1," ")
- borderBar(x3+1, y+2,1," ")
- --
- gpu.setBackground(bar_col)
- borderBar(x3,y+2,100," ")
- --
- gpu.setBackground(default_bg)
- Center(y," "..title.." ")
- end
- function set(y, perc, comp)
- gpu.setBackground(bar_col)
- gpu.fill(3,y+2,100, 1, " ")
- if perc >= 0 and perc <= 25 then
- gpu.setBackground(colors.red)
- elseif perc >= 25 and perc < 50 then
- gpu.setBackground(colors.orange)
- elseif perc >= 50 and perc <= 75 then
- gpu.setBackground(colors.yellow)
- elseif perc >= 75 and perc <= 100 then
- gpu.setBackground(colors.lime)
- end
- gpu.fill(3,y+2, perc, 1," ")
- gpu.setBackground(stat_col)
- Center(y+1," ".. perc .." % ")
- Center(y+3, " Stored: ".. dot(tostring(comp.getEnergy())) .." / ".. dot(tostring(comp.getCapacity())).." ")
- gpu.setBackground(default_bg)
- end
- function bar(y, perc, comp)
- set(y, perc, comp)
- end
- gpu.setBackground(default_bg)
- gpu.setForeground(text_col)
- term.clear()
- initbar(2, "MFSU # 1")
- initbar(7, "MFSU # 2")
- while true do
- perc = math.floor((mfsu.getEnergy() / mfsu.getCapacity() * 100)+0.5)
- perc2 = math.floor((mfsu2.getEnergy() / mfsu2.getCapacity()*100)+0.5)
- set(2, perc, mfsu)
- set(7, perc2, mfsu2)
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement