Thread: Some questions
View Single Post
  #5  
Old 05-01-2011, 12:18 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by papajchris View Post
Thanks that link had great examples, final question and i think i got this part understood.

Could you do this

PHP Code:
for player.colorsBodyParts.index(BodyParts)] = tokens[1]; 
instead of

PHP Code:
for (iBodyPartsplayer.colorsBodyParts.indexi)] = tokens[1]; 
No. It might help if I pick apart his example.

PHP Code:
for (iBodyParts) {
  
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.0BodyParts.size(); ++) {
  
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.
__________________
Reply With Quote