So for example in my code:
numbersGoingUp() {
const atoms = this.user.resources[0]
const molecules = this.user.resources[1]
const atom_gens = this.user.generators[0]
const molecule_gens = this.user.generators[1]
if (!this.interval) {
this.interval = setInterval(() => {
if (atom_gens.active) {
if (atoms.amount >= atoms.max) {
return
} else {
atoms.amount += atom_gens.amount
}
if (molecule_gens.active) {
if (molecules.amount >= molecules.max) {
return
} else {
molecules.amount += molecule_gens.amount
}
}
}
}, 1000);
}
},
If the number to increment by were to stay 1 then there would be no issue whatsoever however when I set the number to increment by to a 2 for example it would increment the following way: 2…4…6…8 and so on.
What I want is for the incrementing number to show every step. So even if it’s incrementing by 3 every second I want to see: 1…2…3…4…5 and so on.
Sorry if the wording is bad or if it’s hard to understand. Any help is appreciated! 😀
I have tried setting the interval time to different values and while that does somewhat do what I want but not in a way that would be easy to manage going forward.
2
Answers
The way step works is by actually incrementing the counter by the step, which I will be using 2 for this example. If you get the step as 2, the counter is going to be:
And this is the default and expected behavior.
If you want to make it show every step, make the
interval
run faster and print every single one:If you are set on keeping your interval / steps where they are at, you could do:
E.g.