View Single Post
  #4  
Old 10-27-2001, 10:04 AM
royce royce is offline
Banned
royce's Avatar
Join Date: Sep 2001
Location: Yakitinzen, China
Posts: 2,271
royce is on a distinguished road
Send a message via AIM to royce
'this.' = a variable...even i know that...i did not type this guide adn i forget who did so i do not take the credit for it...here it is

variables:
there are 2 types of variables
1. the global (for every NPC in the room)
2. this. variables for only one NPC

variables are used for numbers and stuff like this...
example

if(playertouchsme){
a=1+3;
message #v(a);
}

if u touch him he will say 4 =)

so this variables:

if u have an NPC which uses normal variables (without this) it is set for all npcs in the level
example:
1. NPC:
if(playertouchsme){
a=1+3;
message #v(a);
}

2. NPC
if(playertouchsother){
message #v(a);
}

so if u touch the 1. NPC both will say 4

if u use this.variables
example:
1. NPC:
if(playertouchsme){
this.a=1+3;
message #v(a);
}

2. NPC
if(playertouchsother){
message #v(this.a);
}

then if u touch the first NPC it will say 4 but the second will say 0 (it's what every variable is before u set it)

so strings:
if u wanna save text or numbers for every level (for example a bank) u have to use strings
the are set with:
setstring stringname,number or text;

for example 3 NPCs in 2 differnet levels
1. NPC:
if(playertouchsme){
message ouch;
setstring ouch, fred;
}

2. NPC:
if(playertouchsme){
message ouch;
setstring ouch, Karl;
}

3. NPC:
if(playertouchsme){
message You touched #s(ouch);
}

the 1. and 2. NPC are in the 1. Level the 3. NPC is in the 2. level
1. NPCs name: fred
2. NPCsname Karl

so if u touch fred in the first level and then u go into the second level and touches the NPC he will say
You touched fred

the #s() is necessary if u want to handle with strings

If u wanna clear a string use:
setstring stringname,;
Reply With Quote