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()
- function checkPower()
- max = mat.getMaxEnergy()
- cur = mat.getEnergy()
- per = math.floor((cur/max)*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)
- Text(" Füllstand: " .. per .. "% ", y-5, colors.black, colors.red)
- end
- function barDraw()
- local bar = math.floor((cur/max)*(x-2))+0.5
- mon.setCursorPos(2,y-4)
- mon.setBackgroundColor(colors.blue)
- mon.write(string.rep(" ", x-2))
- mon.setCursorPos(2, y-4)
- 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()
- barDraw()
- print(cur .. "/" .. max.." - "..per.."%")
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement