This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
makeme's profile picture

How would I make a progress bar?

Started by makeme, 01 March 2014 - 07:41 PM
makeme #1
Posted 01 March 2014 - 08:41 PM
So after 3 days I've managed to work out how to access data from a tank! But now I want to make a progress bar. How would I make a coloured bar?


I mean have a solid bar not a character
Edited on 01 March 2014 - 09:35 PM
Engineer #2
Posted 01 March 2014 - 10:55 PM
If you want a solid bar, you do the following:

term.setBackgroundColor(colors.yellow)
term.write(" ")

If you run this code, this will draw a yellow spot without character.

As for the progress bar you can use percentages. Pseudo code:

local percentage = currentTankLevel / maxTankLevel -- precentage >= 0 and percentage <= 1 (percentage is greater or equals to zero or percentage is less than or equal to 1

Then you need a distance, which is the progress bar.

local squaresToDraw = maxBoxe * percentage

This should get you going, you can always ask for more help :)/>
makeme #3
Posted 01 March 2014 - 11:26 PM
Thanks I've got the percentages all worked out