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-02-2001, 07:37 AM
iceman8832 iceman8832 is offline
Registered User
Join Date: Oct 2001
Location: U.S.A.
Posts: 121
iceman8832 is on a distinguished road
Question 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.
Reply With Quote
  #2  
Old 11-02-2001, 07:47 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
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)
Reply With Quote
  #3  
Old 11-02-2001, 10:28 PM
wark2 wark2 is offline
Registered User
Join Date: Oct 2001
Location: Canada
Posts: 306
wark2 is on a distinguished road
Send a message via AIM to wark2 Send a message via Yahoo to wark2
yeah, i think pythons right....
__________________
- Legend
Reply With Quote
  #4  
Old 11-02-2001, 11:24 PM
PresShinP2P PresShinP2P is offline
Registered User
Join Date: Oct 2001
Location: Screw it
Posts: 84
PresShinP2P is on a distinguished road
Send a message via AIM to PresShinP2P
are regular vars are shared with other people in the same room?
__________________
President Shinra
Reply With Quote
  #5  
Old 11-03-2001, 02:28 AM
Xaviar Xaviar is offline
Registered User
Join Date: Aug 2001
Location: Fairyland
Posts: 463
Xaviar is on a distinguished road
Send a message via ICQ to Xaviar Send a message via AIM to Xaviar
Quote:
Originally posted by PresShinP2P
are regular vars are shared with other people in the same room?
A global variable (ie: thisismyvariable = 10) is readable by any NPC in the level it was declared in. A local variable (ie: this.thisismyvariable = 10) is readable only by the npc that created it.
__________________
One by one, the penguins steal my sanity.

*cookie for Xaviar* --Originally posted by Tyhm

--Xaviar

A m e r i c a
Reply With Quote
  #6  
Old 11-03-2001, 03:10 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
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
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #7  
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
  #8  
Old 11-03-2001, 04:19 AM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
go look at the other posts, there was a really good explanation not too long ago
Reply With Quote
  #9  
Old 11-03-2001, 04:41 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
Wink

Quote:
Originally posted by btedji
go look at the other posts, there was a really good explanation not too long ago
You don't like my one? DIE DIE DIE
Reply With Quote
  #10  
Old 11-03-2001, 07:02 AM
iceman8832 iceman8832 is offline
Registered User
Join Date: Oct 2001
Location: U.S.A.
Posts: 121
iceman8832 is on a distinguished road
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.
Reply With Quote
  #11  
Old 11-03-2001, 08:09 AM
SSRobgeta SSRobgeta is offline
Ebil Cloud = l337 *kupo*
SSRobgeta's Avatar
Join Date: Aug 2001
Location: Monroeville, PA
Posts: 1,084
SSRobgeta is on a distinguished road
Send a message via AIM to SSRobgeta
A Quote:
One who dies... Well... Dies
__________________
Rob Getashu
Anyone can show you the way, but the real adventure is finding it yourself..
Reply With Quote
  #12  
Old 11-03-2001, 09:23 AM
TDO2000 TDO2000 is offline
Registered User
TDO2000's Avatar
Join Date: Jul 2001
Location: Germany
Posts: 655
TDO2000 is on a distinguished road
Talking

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...
__________________
No Webhost at the moment
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 07:37 AM.


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