Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- twerk = peripheral.wrap("left")
- monitor = peripheral.wrap("top")
- maxEnergy = twerk.getMaxEnergyStored()
- width, height = monitor.getSize()
- function getColor(percentage)
- if percentage < 0.2 then
- return colors.red
- elseif percentage < 0.4 then
- return colors.orange
- elseif percentage < 0.6 then
- return colors.yellow
- elseif percentage < 0.8 then
- return colors.lime
- else
- return colors.green
- end
- end
- function fillMonitor(percentage)
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- amount = math.floor(percentage*height)
- monitor.setCursorPos(0,height-amount)
- monitor.setBackgroundColor(getColor(percentage))
- for i = 1,amount do
- monitor.setCursorPos(0,height-amount+i)
- monitor.clearLine()
- end
- end
- while true do
- monitor.clear()
- monitor.setCursorPos(1,1)
- energy = twerk.getEnergyStored()/maxEnergy
- fillMonitor(energy)
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement