ID:138312
 
Okay, here's the 'there's a...' problem.

usr << "1. difference = [difference]."
var/howmany = 0
for (difference in usr.movesleft) howmany++
for (difference in usr.movesused) howmany++
usr << "2. difference = [difference]."

In the above bit of code, "difference" is a numeric value. Difference is reported correctly to usr in the first output, and as null in the second output. But why should checking to see, for instance, how many 4's are in usr.movesleft make difference = null?

Z
On 11/9/00 9:17 pm Zilal wrote:
Okay, here's the 'there's a...' problem.

usr << "1. difference = [difference]."
var/howmany = 0
for (difference in usr.movesleft) howmany++
for (difference in usr.movesused) howmany++
usr << "2. difference = [difference]."

In the above bit of code, "difference" is a numeric value. Difference is reported correctly to usr in the first output, and as null in the second output. But why should checking to see, for instance, how many 4's are in usr.movesleft make difference = null?

Because you are using difference as your loop var. This causes it to be assigned to each of the members of the list in succession. At the end of the looping, it is assigned to null. I forget why we made this the case, but testing has confirmed that it is true.

Solution: just use some other var to do your looping.

[Edit] Or, even easier:
howmany = usr.movesleft.len + usr.movesused.len
In response to Tom H.
On 11/9/00 9:42 pm Tom H. wrote:
Because you are using difference as your loop var. This causes it to be assigned to each of the members of the list in succession. At the end of the looping, it is assigned to null. I forget why we made this the case, but testing has confirmed that it is true.

Oh.

Solution: just use some other var to do your looping.

I believe that's what I was doing before... back when it worked... then I must have adjusted it for "efficiency" and forgotten about it.

[Edit] Or, even easier:
howmany = usr.movesleft.len + usr.movesused.len

No, no. See, the purpose of the thing was to count, for instance, how many #4's existed in the lists, total. All this so that it can say "There's a 4...", "There's the 4...", "There's a 4." and "There's the 4.", according to the situation. Anything to help my players out!

Z