Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.sleep(1)
- local monitor = peripheral.find("monitor")
- local source = peripheral.wrap("back")
- local modem = peripheral.find("modem")
- modem.open(9)
- local powerPerc = 0
- local width, height = monitor.getSize()
- local wCenter, hCenter = math.floor(width/2)+1, math.floor(height/2)+1
- local scale = width/15
- function monitorSetup(monitor)
- monitor.setTextScale(0.5)
- paintutils.drawFilledBox(1, 1, width, height, colors.black)
- if width % 2 ~= 0 then
- --Main Sqr
- paintutils.drawBox(wCenter-(4*scale), hCenter+(3*scale), wCenter+(4*scale), hCenter-(3*scale), colors.white)
- --Bat Top
- paintutils.drawBox(wCenter-(2*scale), hCenter-(3*scale), wCenter+(2*scale), hCenter-(4*scale), colors.white)
- else
- --Main Sqr
- paintutils.drawBox(wCenter-(4*scale), hCenter+(3*scale), wCenter+(4*scale), hCenter-(3*scale), colors.white)
- --Bat Top
- paintutils.drawBox(wCenter-(2*scale), hCenter-(3*scale), wCenter+(2*scale+1), hCenter-(4*scale + 1), colors.white)
- end
- end
- function update(h)
- if monitor ~= nil then
- local y = hCenter+(3*scale-1)
- local nbars = (4*scale-1) + (4*scale-1) - scale
- local color
- paintutils.drawFilledBox(wCenter-(4*scale-1), hCenter+(3*scale-1), wCenter+(4*scale-1), hCenter-(3*scale-1), colors.black)
- if h > 66 then
- color = colors.green
- elseif h > 33 then
- color = colors.orange
- else
- color = colors.red
- end
- if h ~= 0 then
- if width % 2 ~= 0 then
- paintutils.drawFilledBox(wCenter-(4*scale-1), y, wCenter+(4*scale-1), y-math.floor(nbars*h/100)+1, color)
- else
- paintutils.drawFilledBox(wCenter-(4*scale-1), y, wCenter+(4*scale-1), y-math.floor(nbars*h/100)+1, color)
- end
- end
- end
- modem.transmit(6, 9, h)
- end
- if monitor ~= nil then
- term.redirect(monitor)
- monitorSetup(monitor)
- end
- while true do
- powerPerc = (source.getEnergy() / source.getMaxEnergy()) * 100
- update(powerPerc)
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement