![]() |
This. again
i'm just wondering if someone could give me an example script telling me what everything does. I would like the script to have this. in it a lot. i htink i understand better but not completely. could you tell how to set it and what is the point.:confused:
|
Well, This. is a type of variable, there are two different kinds of variables, global (every npc in the room) and this (which is only of the specific npc)
|
yeah, i think pythons right....
|
are regular vars are shared with other people in the same room?
|
Quote:
|
if you have 2 npc's one is like
if (playerenters) { on=1; } then the other if (playerenters) { on=2; } they would confuse each other, because they would be sharing it, but if you have if (playerenters) { this.on=1; } then the other if (playerenters) { this.on=2; } then on for the 1st script would be 1 and on for the 2nd script would be 2 .. they would be variables for the npc itself |
Basically you can say:
If you want a variable to stay the same for some time, use this.stuff, if that's not needed or you want to use it also on other NPCs, you use normal variables. For example, hiding 10 showimgs ... NPC Code:for (i=0; i<10; i++) ... can be done with normal variables (less typing work :) and looks nicer), but a movement using for-loops... NPC Code:for (this.i=0; this.i<10; this.i++) ... would need to be done with this.vars, because some other NPC would probably use the same variable for his stuff and confuse the moving one. A switch for example... NPC Code:Switch: ... would need to be done with normal variables because the other NPC is checking it. And always, all variables (besides NPC or playerstats (All stuff you can check with npcs/players[index].blah)) are always local and not sent to other people (unless it's a serverside NPC of course). Bash me if I am wrong, but I think I am not. |
go look at the other posts, there was a really good explanation not too long ago
|
Quote:
|
i still don't really understand. could you give me an example script that someone uses. and tell me why you use this. and what it is for. could you explain it in very good detail every part and what they do. for ex. this.rupee=10 would that work? and if so what would rupee be for. and why 10. what would the = do.:(
|
A Quote:
One who dies... Well... Dies |
So the third use of my description:
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) hope u'll understand and Loriel it's always good to use things no new scripter will understand to explain how something like this.-variables work... |
| All times are GMT +2. The time now is 03:48 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.