Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-03-2001, 03:33 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
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++)
hideimg 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++)
if (insert complicate onwall check) {
x += vecx(dir)*0.5;
y += vecy(dir)*0.5;
sleep 0.05;
}


... 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:
if (washit) {
switchhit = true;
setimg insert switch image;
sleep 5;
switchhit = false;
setimg insert other switch image;
}

Door:
if (playertouchsme && switchhit==true) {
hide;
sleep 3;
show;
}


... 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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.