Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Variables
- local mfsu1 = peripheral.wrap("ic2:mfsu_1")
- local mfsu2 = peripheral.wrap("ic2:mfsu_2")
- local mon = peripheral.wrap("top")
- local rx,ry = mon.getSize()
- -- text
- local headLine = "EU Power Storage"
- -- colors
- local bc = colors.black
- local tc = colors.white
- local bar = colors.lime
- local barOff = colors.gray
- --- Functions
- function drawIntro()
- mon.setBackgroundColor(bc)
- mon.setTextColor(tc)
- mon.clear()
- mon.setBackgroundColor(colors.gray)
- mon.setCursorPos(1, 1)
- mon.clearLine()
- mon.setCursorPos(math.floor((rx/2)-(string.len(headLine))/2)+1, 1)
- mon.write(headLine)
- end
- function drawBar(x, y, text, name)
- mon.setBackgroundColor(bc)
- mon.setTextColor(tc)
- if(name=="mfsu1") then
- ene = mfsu1.getEUStored()
- cap = mfsu1.getEUCapacity()
- elseif(name=="mfsu2") then
- ene = mfsu2.getEUStored()
- cap = mfsu2.getEUCapacity()
- end
- local per = math.ceil((ene/cap)*100)
- local pro = math.ceil(((rx-1)/100)*per)
- mon.setCursorPos(x, y)
- mon.write(text.." - "..ene.." / "..cap)
- if(per<15) then
- mon.setBackgroundColor(colors.red)
- elseif(per>15 and per<30) then
- mon.setBackgroundColor(colors.orange)
- else
- mon.setBackgroundColor(bar)
- end
- for i = x, pro do
- mon.setCursorPos(i, y+1)
- mon.write(" ")
- mon.setCursorPos(i, y+2)
- mon.write(" ")
- mon.setCursorPos(i, y+3)
- mon.write(" ")
- end
- mon.setBackgroundColor(barOff)
- for i = pro, rx-1 do
- if(i<x) then
- i=x
- end
- mon.setCursorPos(i, y+1)
- mon.write(" ")
- mon.setCursorPos(i, y+2)
- mon.write(" ")
- mon.setCursorPos(i, y+3)
- mon.write(" ")
- end
- end
- function draw()
- drawBar(2, 3, "MFSU 1", "mfsu1")
- drawBar(2, 8, "MFSU 2", "mfsu2")
- end
- --- Execute
- function init()
- drawIntro()
- while true do
- draw()
- sleep(0.5)
- end
- end
- init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement