Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- power = peripheral.wrap("tile_blockcapacitorbank_name_1")
- mon = peripheral.wrap("right")
- local maxPower = 0
- local curPower = 0
- local perPower = 0
- local emergency = 0
- monX, monY = mon.getSize()
- function checkPower()
- maxPower = power.getMaxEnergyStored()
- curPower = power.getEnergyStored()
- perPower = math.floor(((curPower/maxPower)*100)+0.5)
- emergency = perPower
- end
- function writeMon()
- mon.setBackgroundColor(colors.blue)
- mon.clear()
- mon.setCursorPos(1,1)
- -- mon.write("Power")
- title = " Power:" .. perPower .. "% Full "
- center(title,1,colors.lightGray,colors.red)
- end
- function center(text,line,backColor,textColor)
- mon.setBackgroundColor(backColor)
- mon.setTextColor(textColor)
- length = ( string.len(text))
- dif = math.floor(monX-length)
- x = math.floor(dif/2)
- mon.setCursorPos(x+1, line)
- mon.write(text)
- end
- function draw()
- bar = math.floor(((curPower/maxPower)*(monX-2))+0.5)
- mon.setCursorPos(2,monY-3)
- mon.setBackgroundColor(colors.red)
- mon.write(string.rep(" ", monX-2))
- mon.setCursorPos(2,monY-3)
- mon.setBackgroundColor(colors.green)
- mon.write(string.rep(" ", bar))
- end
- while true do
- checkPower()
- writeMon()
- draw()
- print(curPower .. "/" .. maxPower)
- sleep(1)
- if emergency < 10 then
- redstone.setOutput("back",true)
- elseif emergency > 50 then
- redstone.setOutput("back",false)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement