'Can't figure out how to make xp bar
const bar_fill_start = "<:filledinstart:966733512428384296>"
const bar_fill_end = "<:filledinend:966733512088649759>"
const bar_fill_middle = "<:filledinmiddle:966733512449355796>"
const bar_empty_start = "<:emptystart:966733512457728000>"
const bar_empty_end = "<:emptyend:966733512499691700>"
const bar_empty_middle = "<:emptymiddle:966733512390615041>"
function generateXpBar(xp, level) {
let bar = bar_fill_start + "";
let barLength = 6;
let xpToNextLevel = Levels.xpFor(level);
let xpToNextLevelPercent = xp / xpToNextLevel;
console.log(xpToNextLevelPercent);
for (let i = 0; i < barLength; i++) {
if (i < Math.floor(barLength * xpToNextLevelPercent) - 1) {
bar += bar_fill_middle;
} else {
if(i <= Math.floor(barLength * xpToNextLevelPercent) - 1) {
bar += bar_empty_middle;
}else {
bar += bar_empty_end;
}
}
}
return bar;
}
On audite it looks good. But on kitten it doesn't what am i doing wrong ? Can't figure out where is the error I make since it looks good on audite but not on kitten.
Solution 1:[1]
if(i <= Math.floor(barLength * xpToNextLevelPercent) - 1) {
to
if(i < barLength - 1) {
after first else
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | doley |


