local mon = peripheral.wrap("top") local bgCol = colors.black function draw(val, x, y) local color mon.setBackgroundColor(bgCol) mon.clearLine() mon.setCursorPos(x, y) if val >= 10 then color = colors.lightBlue elseif val >= 7 then color = colors.lime elseif val >= 4 then color = colors.yellow elseif val >= 1 then color = colors.orange elseif val == 0 then color = colors.red else color = colors.gray end for i = 1, val + 2 do mon.setBackgroundColor(color) mon.write(" ") --This is the segment of bar itself mon.setCursorPos(i + 1, y) end end function drawBar(val, x, y) draw(math.floor(val * 0.1), x, y) end