Thread: Some questions
View Single Post
  #1  
Old 04-30-2011, 11:26 PM
papajchris papajchris is offline
Zeus Condero
papajchris's Avatar
Join Date: Jan 2006
Location: Michigan
Posts: 1,600
papajchris is a splendid one to beholdpapajchris is a splendid one to beholdpapajchris is a splendid one to beholdpapajchris is a splendid one to behold
Some questions

So im looking at one of xXziroXx's old scripts and i had some questions

Quote:
Originally Posted by xXziroXx View Post
PHP Code:
function onPlayerChats()
{
  
tokens = player.chat.tokenize();
  
BodyParts = { "skin", "coat", "sleeves", "shoes", "belt", "all"};
  
BodyColors = { "white", "yellow", "orange", "pink", "red",
    
"darkred", "lightgreen", "green", "darkgreen", "lightblue",
      
"blue", "darkblue", "brown", "cynober", "purple",
        
"darkpurple", "lightgray", "gray", "black"};
  if (
BodyParts.index( tokens[0]) > -1 && BodyColors.index( tokens[1]) > -1) {
    if (
tokens[0] != "all") player.colors[ BodyParts.index( tokens[0])] = tokens[1];
    else {
      for (
i: BodyParts) player.colors[ BodyParts.index( i)] = tokens[1];
    }
    
player.chat = "Changed " @ tokens[0] @ " to " @ tokens[1] @ "!";
  }
} 
PHP Code:
 if (BodyParts.index( tokens[0]) > -1 && BodyColors.index( tokens[1]) > -1) 
What does the -1 do? Assuming its the word number, how can words be less than first word (which is number 0).


PHP Code:
for (i: BodyParts) player.colors[ BodyParts.index( i)] = tokens[1]; 
What does the "i" do? My guess is its a variable?

Lastly can SPC be used instead of "@"?
__________________
Reply With Quote