# How can I make a bar that shows the distance between one variable and another

be it in progress or be it in percentage im fine with either (or both)

1 Like

Assuming you’ve already created the bar, all you have to do is change what the progress function returns.

For example, say you’re trying to see how close your amount of points is to your amount of prestige points. You could do this:

``````{
...,
progress() {
return player.points.div(player.p.points).clamp(0, 1);
}
}
``````
1 Like

thanks

also wow you respond here faster in the forums instead of discord

2 Likes

I saw you post these example inputs/outputs in discord:

``````2 - 4
50%
4 - 4
100%
6 - 4
50%
``````

This is a bit more complicated. I think you made a mistake here - the last one should be 66%. I can’t think of a formula that would return 50% in that case but also get smaller as the first number got larger. Assuming I understand the formula you were trying to demonstrate, the function would look like this, where “a” is the first number and “b” is the second (and the base):

``````return a.sub(b).abs().div(a.max(b))
``````
2 Likes

the first one you made is fine, it’s not really accurate so it’s okay

3 Likes