Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mat = peripheral.wrap("bottom")
- if mat == nil then return end
- local mon = peripheral.wrap("top")
- if mon == nil then return end
- --mon.clear()
- local max, cur, per = 0, 0, 0
- local x, y = mon.getSize()
- local perIn, perOut = 0, 0
- function checkPower()
- max = mat.getMaxEnergy()
- cur = mat.getEnergy()
- per = math.floor((cur/max)*100+0.5)
- perIn = math.floor((mat.getInput()/mat.getTransferCap())*100+0.5)
- perOut = math.floor((mat.getOutput()/mat.getTransferCap())*100+0.5)
- -- mon.write(per)
- end
- function writeMon()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,1)
- Text(" Kiwi-Powerstatus ", 1, colors.white, colors.red)
- end
- function barDraw(bar, _y)
- mon.setCursorPos(2,y-_y)
- mon.setBackgroundColor(colors.blue)
- mon.write(string.rep(" ", x-2))
- mon.setCursorPos(2, y-_y)
- mon.setBackgroundColor(colors.red)
- mon.write(string.rep(" ", bar))
- end
- function Text(text, line, colB, colT)
- mon.setBackgroundColor(colB)
- mon.setTextColor(colT)
- local ts = string.len(text)
- local dif = math.floor(x-ts)
- local _x = math.floor(dif/2)
- mon.setCursorPos(_x+1, line)
- mon.write(text)
- end
- while true do
- checkPower()
- writeMon()
- -- in
- Text(" Input: " .. perIn .. "% (" .. mat.getInput() .. " RF) ", y-15, colors.black, colors.red)
- local bar = math.floor((mat.getInput()/mat.getTransferCap())*(x-2))+0.5
- barDraw(bar, 14)
- barDraw(bar, 13)
- barDraw(bar, 12)
- --out
- Text(" Output: " .. perOut .. "% (" .. mat.getOutput() .. " RF) ", y-24, colors.black, colors.red)
- bar = math.floor((mat.getOutput()/mat.getTransferCap())*(x-2))+0.5
- barDraw(bar, 23)
- barDraw(bar, 22)
- barDraw(bar, 21)
- -- full
- Text(" Füllstand: " .. per .. "% ", y-7, colors.black, colors.red)
- barDraw(math.floor((cur/max)*(x-2))+0.5, 4)
- barDraw(math.floor((cur/max)*(x-2))+0.5, 5)
- barDraw(math.floor((cur/max)*(x-2))+0.5, 6)
- -- console
- print(cur .. "/" .. max.." - "..per.."%")
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement