I would think this to be something relatively easy, but I'm having issues working it out. Here's what I'm trying to do:
I have built a trigger that will calculate how much experience I've collected over the day. It's really simple, and I save it under the variable "xptoday."
That works fine.
What I'm trying to do now is to create a seperate trigger that will divide that number into a readable number with commas. Meaning: 123456789 experience points for the day would be displayed as 123,456,789. The idea I had to work this, I think, should work beautifully, if I can get it to work at all:
total = getvariable("xptoday")
setvariable "mil",0
setvariable "thou",0
while total > 999999
mil = world.getvariable (mil)+1
total = total - 1000000
wend
while total > 999
thou = world.getvariable (thou)+1
total = total - 1000
wend
hund = total
To translate, if the number is larger than one million, it will subtract one million from it, add one to the "million" variable, then try again. By the time it is less than one million, I should have the million value stored in the "million" variable, with the remaining total stored in the variable "total". The process is then repeated for the thousands. (I know that this might take a long time, and I could break it down further if necessary, but I'd like to make this much work.)
In the end, I will have it display (in the output, if you like) the million value, followed by a comma, the thousands value, again followed by a comma, topped off by the remaining number "hund" or "total" (they'll have the same value).
The idea seems reasonable enough, but something is wrong with my code. Any guesses what?
I have built a trigger that will calculate how much experience I've collected over the day. It's really simple, and I save it under the variable "xptoday."
That works fine.
What I'm trying to do now is to create a seperate trigger that will divide that number into a readable number with commas. Meaning: 123456789 experience points for the day would be displayed as 123,456,789. The idea I had to work this, I think, should work beautifully, if I can get it to work at all:
total = getvariable("xptoday")
setvariable "mil",0
setvariable "thou",0
while total > 999999
mil = world.getvariable (mil)+1
total = total - 1000000
wend
while total > 999
thou = world.getvariable (thou)+1
total = total - 1000
wend
hund = total
To translate, if the number is larger than one million, it will subtract one million from it, add one to the "million" variable, then try again. By the time it is less than one million, I should have the million value stored in the "million" variable, with the remaining total stored in the variable "total". The process is then repeated for the thousands. (I know that this might take a long time, and I could break it down further if necessary, but I'd like to make this much work.)
In the end, I will have it display (in the output, if you like) the million value, followed by a comma, the thousands value, again followed by a comma, topped off by the remaining number "hund" or "total" (they'll have the same value).
The idea seems reasonable enough, but something is wrong with my code. Any guesses what?