Quote:
Originally Posted by papajchris
Thanks that link had great examples, final question and i think i got this part understood.
Could you do this
PHP Code:
for player.colors[ BodyParts.index(BodyParts)] = tokens[1];
instead of
PHP Code:
for (i: BodyParts) player.colors[ BodyParts.index( i)] = tokens[1];
|
No. It might help if I pick apart his example.
PHP Code:
for (i: BodyParts) {
player.colors[BodyParts.index(i)] = tokens[1];
}
This is the example with braces added to clarify it.
I don't really like how he's doing that anyway. This is how I would have done it:
PHP Code:
for (temp.i = 0; i < BodyParts.size(); i ++) {
player.colors[i] = tokens[1];
}
Basically,
i is starting at zero and increasing until it reaches the number of body parts. For each body part, it sets that part's color to
tokens[1].
I'm not really sure how to explain the problems with yours except that it's just not following the right format. If you've got more questions I can try to answer them.
Also check out
Jer's post on arrays.