Kavan wrote: - Code:
//#CLIENTSIDE
function onCreated(){
setimg("block.png");
setshape(1,32,32);
this.insults = {"you smell!","you're ugly!","take a bath!"};
}
function onPlayerTouchsMe(){
temp.randint = int(random(0,this.insults.size());
this.chat = player.nick@", "@this.insults[randint];
sleep(3);
this.chat = "";
}
Just thought I'd clear the text after someone touches the object, because I think permanent chat looks yucky.
Nice... :O
temp.randint = int(random(0,this.insults.size());
If anyone else looks at this, this line is good for others because they would never have to change this line, it depends on the array size.. I think I did it the poor way D:
Anyway, I think you know what you are doing so the following is for anyone else interested.
this.chat = player.nick@", "@this.insults[randint];
Also, I recently learned that SPC does exactly the same as @" "@ does
"for those who don't know, @ separates two things, variable @ variable, string @ variable,
// <- one line comment
/*
Block of comment
*/
After you declare a temp, in the function you no longer have to put temp. behind it. But it does make it easier to understand keeping temp.
Ex.
temp.age = 22; // My age variable.
this.chat = "message here"@temp.age
or
this.chat = "message here"@" "@temp.age
//this now has a space between them.
You could do also do "message here" SPC temp.age
which also has a space between them.
P.S. I still miss PHP on the Graal Forums... :'[