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 02-27-2002, 04:07 AM
WHIPENIE4 WHIPENIE4 is offline
I am X-Mann
Join Date: Aug 2001
Location: PA
Posts: 2,715
WHIPENIE4 is on a distinguished road
Send a message via ICQ to WHIPENIE4 Send a message via AIM to WHIPENIE4
Variables

Ok im slowly learning how to script , im kinda stuck on varibles... when do you use them??

In the example they use in npcprogramming
myvar = 1;
if (myvar==1) {..........}

So if the varible ='s 1 then the command in {.....} will be executed...... but lets say
the command in the {...} was messageHello;
then why not just put
If (playertouchsme) messageHello;
???
Or 'playerenters'

[edit]Also what do these symbols mean
>,<,>=,<=,==,!= , or when do you use them?[/edit]
__________________
Mind over Matter. If your body dont mind, why does it matter?

- X-Mann (Blessing Graal since 1998) Haha

- Graal 2000 Project (Contact Me to get Apart of this expierience

Windows Vista. Graal. Not a Good Combination.
Reply With Quote
  #2  
Old 02-27-2002, 04:23 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Re: Variables

Quote:
Originally posted by WHIPENIE4
Ok im slowly learning how to script , im kinda stuck on varibles... when do you use them??

In the example they use in npcprogramming
myvar = 1;
if (myvar==1) {..........}

So if the varible ='s 1 then the command in {.....} will be executed...... but lets say
the command in the {...} was messageHello;
then why not just put
If (playertouchsme) messageHello;
???
Or 'playerenters'

[edit]Also what do these symbols mean
>,<,>=,<=,==,!= , or when do you use them?[/edit]
Well 'if (playertouchsme)' is so if the player touchs the NPC and 'if (myvar==1)' can be set in a variety of ways ...

> - greater than
< - less than
>= - greater than or equal to
<= - less than or equal to
== - is equal to
!= - not equal to (I dont think exists)
Reply With Quote
  #3  
Old 02-27-2002, 04:25 AM
TDK_RC6 TDK_RC6 is offline
Registered User
TDK_RC6's Avatar
Join Date: Jan 2002
Location: Earth
Posts: 0
TDK_RC6 is on a distinguished road
well lets see

you can use variables with flags for certain things, here is a example:

NPC Code:

if (playertouchsme) {
myvar=playerrupees;
if (myvar==0) {
message You have no gralats;
}
if (myvar==1) {
message You have 1 gralat;
}
if (myvar>=2) {
message You have #v(myvar) gralats;
}
sleep 3.4;
message ;
}



>= - great than or equal to
> - greater than
<= - less than or equal to
< - less than
== - equal to
!= - not equal to

if you want to check if a variable is greater than, less than, minimum about (greater than or equal to), maximum number (lesser than or equal to), equal to, or any other number
__________________
Staff on Renegade


email: [email protected]
aim: papivicente
Reply With Quote
  #4  
Old 02-27-2002, 04:26 AM
TDK_RC6 TDK_RC6 is offline
Registered User
TDK_RC6's Avatar
Join Date: Jan 2002
Location: Earth
Posts: 0
TDK_RC6 is on a distinguished road
Re: Re: Variables

Quote:
Originally posted by nyghtGT


!= - not equal to (I dont think exists)
it does exist :P
__________________
Staff on Renegade


email: [email protected]
aim: papivicente
Reply With Quote
  #5  
Old 02-27-2002, 04:30 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Quote:
Originally posted by TDK_RC6

NPC Code:

if (playertouchsme) {
myvar=playerrupees;
if (myvar==0) {
message You have no gralats;
}
if (myvar==1) {
message You have 1 gralat;
}
if (myvar>=2) {
message You have #v(myvar) gralats;
}
sleep 3.4;
message ;
}



NPC Code:

NPC Code:

if (playertouchsme) {
for (i=0;i<playerrupees;i++) {
message I gots #v(i) cash monies!
}
}





I know you can do that, I just wanna confooze him ...
Reply With Quote
  #6  
Old 02-27-2002, 04:33 AM
TDK_RC6 TDK_RC6 is offline
Registered User
TDK_RC6's Avatar
Join Date: Jan 2002
Location: Earth
Posts: 0
TDK_RC6 is on a distinguished road
that not nice
__________________
Staff on Renegade


email: [email protected]
aim: papivicente
Reply With Quote
  #7  
Old 02-27-2002, 04:34 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Re: Re: Re: Variables

Quote:
Originally posted by TDK_RC6


it does exist :P
ok, I just wasn't sure and did not want to give him false info ...
Reply With Quote
  #8  
Old 02-27-2002, 04:36 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Quote:
Originally posted by TDK_RC6
that not nice
its carrying on the tradition ...
Reply With Quote
  #9  
Old 02-27-2002, 04:37 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Re: Variables

Quote:
Originally posted by WHIPENIE4
Ok im slowly learning how to script , im kinda stuck on varibles... when do you use them??
Would you like a lesson in arrays ?
Reply With Quote
  #10  
Old 02-27-2002, 04:45 AM
WHIPENIE4 WHIPENIE4 is offline
I am X-Mann
Join Date: Aug 2001
Location: PA
Posts: 2,715
WHIPENIE4 is on a distinguished road
Send a message via ICQ to WHIPENIE4 Send a message via AIM to WHIPENIE4
Quote:
Would you like a lesson in arrays ?
Yes pwease
__________________
Mind over Matter. If your body dont mind, why does it matter?

- X-Mann (Blessing Graal since 1998) Haha

- Graal 2000 Project (Contact Me to get Apart of this expierience

Windows Vista. Graal. Not a Good Combination.
Reply With Quote
  #11  
Old 02-27-2002, 04:54 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Quote:
Originally posted by WHIPENIE4

Yes pwease
Variable arrays are an easy way to store multiple values to one variable:

this.variable={0,1,2,3,4,5}

The above sets the arrays for the variable 'this.variable'. To access the arrays you use:

if (this.variable[1]=value) {}

Roughly, that says, if the array 1 of this.variable is equal to a value the contents of {} occur.
Arrays start at 0. So the arrays for that variable would be:

this.variable[0]=0
this.variable[1]=1
this.variable[2]=2
And so on...
Reply With Quote
  #12  
Old 02-27-2002, 05:34 AM
WHIPENIE4 WHIPENIE4 is offline
I am X-Mann
Join Date: Aug 2001
Location: PA
Posts: 2,715
WHIPENIE4 is on a distinguished road
Send a message via ICQ to WHIPENIE4 Send a message via AIM to WHIPENIE4


That helped a bit , thanks.
Still a little confuseing though
__________________
Mind over Matter. If your body dont mind, why does it matter?

- X-Mann (Blessing Graal since 1998) Haha

- Graal 2000 Project (Contact Me to get Apart of this expierience

Windows Vista. Graal. Not a Good Combination.
Reply With Quote
  #13  
Old 02-27-2002, 05:48 AM
WHIPENIE4 WHIPENIE4 is offline
I am X-Mann
Join Date: Aug 2001
Location: PA
Posts: 2,715
WHIPENIE4 is on a distinguished road
Send a message via ICQ to WHIPENIE4 Send a message via AIM to WHIPENIE4
Quote:
if (playertouchsme) {
myvar=playerrupees;
if (myvar==0) {
message You have no gralats;
}
if (myvar==1) {
message You have 1 gralat;
}
if (myvar>=2) {
message You have #v(myvar) gralats;
}
sleep 3.4;
message ;
}
Ok let me see , This script would mean

If the player touches the npc and the varible is equal the the amount of ruppees , if the varible is equal to 0 then say You have no gralats , if the varible is equal to 1 then the message is You have 1 gralat, if the varible is greater then 2 message is You have (then i dont know what #v is) the amount the varible is gralets. then sleep for 3.4 secs and the message is nothing...

Am i right?

[edit] Could someone also give me more examples of things with myvar stuff in them?? I want to get this section in scripting down before i go to this.var stuff... [/edit]
__________________
Mind over Matter. If your body dont mind, why does it matter?

- X-Mann (Blessing Graal since 1998) Haha

- Graal 2000 Project (Contact Me to get Apart of this expierience

Windows Vista. Graal. Not a Good Combination.

Last edited by WHIPENIE4; 02-27-2002 at 06:01 AM..
Reply With Quote
  #14  
Old 02-27-2002, 08:03 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Quote:
Originally posted by WHIPENIE4


Ok let me see , This script would mean

If the player touches the npc and the varible is equal the the amount of ruppees , if the varible is equal to 0 then say You have no gralats , if the varible is equal to 1 then the message is You have 1 gralat, if the varible is greater then 2 message is You have (then i dont know what #v is) the amount the varible is gralets. then sleep for 3.4 secs and the message is nothing...

Am i right?

[edit] Could someone also give me more examples of things with myvar stuff in them?? I want to get this section in scripting down before i go to this.var stuff... [/edit]
no, if the player touchs the npc the variable, 'myvar', gets set to the amount of rupees the player has. Then if myvar is equal to 0,1, or 2. It will say, "I have # rupees"
Reply With Quote
  #15  
Old 02-27-2002, 08:39 AM
TDK_RC6 TDK_RC6 is offline
Registered User
TDK_RC6's Avatar
Join Date: Jan 2002
Location: Earth
Posts: 0
TDK_RC6 is on a distinguished road
baby acid, you are right

the #v this is a variable,
if you didnt include that, then it would just show, You have myvar gralats

but when you put, #v(myvar), it reads myvar and outputs the amount of it
__________________
Staff on Renegade


email: [email protected]
aim: papivicente
Reply With Quote
  #16  
Old 02-27-2002, 11:18 AM
slick_soul slick_soul is offline
Registered User
Join Date: Sep 2001
Location: Florida
Posts: 484
slick_soul is on a distinguished road
Okay. I am just completely lost. What is it that whipenie is trying to do and can you re-explain that whole bit about variables and stuff.
__________________
Lopar:Excuse me ol chap your pants are on fire
Chap: Whay thank you for noticing sir , would you like to come over to my house for some tea and crumpets?
Lopar:umm well Like i said your pants are on fire
Chap: Oh yes i forgot AHHHHHH
Reply With Quote
  #17  
Old 02-27-2002, 01:43 PM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Quote:
Originally posted by slick_soul
Okay. I am just completely lost. What is it that whipenie is trying to do and can you re-explain that whole bit about variables and stuff.
he is just wondering how variables how used and set ...

if anyone needs firther help i made this ...

http://nyght.digitalrice.com/variables.php
Reply With Quote
  #18  
Old 02-27-2002, 10:12 PM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
good definition of arrays, read it, and i am sure u'll undertstand.
NPC Code:

// to make an array do this:
// setarray arrayname,size;
// as in this example:
setarray this.values,10;
/*
to set values in an array do this:
arrayname[indexnumber] = value;
the first index in every array is 0.
so if you have an array that you set to size 100
than its 0-99.
as in this example:
*/
this.values[0] = 1;
this.values[9] = 5;
/*
that is the hard way to do it though,
this is easier:
*/
this.values = {1,0,0,0,1,2,3};
/*
that will set an array with 7 values (0-6)
and can be called as so:
*/
this.newnumber = this.values[5];
/*
Meaning that this.newnumber would equal 2
*/
Mostly with big arrays you put them thru a for loop,
like in this rain example:
*/
// Rain script:
if (created) {
setarray this.rainx,100;
setarray this.rainy,100;
for (i=0;i<arraylen(this.rainx);i++;) {
/* arraylen(arrayname) <-- gives you the amount of indexes in the array.*/
this.rainx[i] = random(0,64);
this.rainy[i] = random(0,64);
}
}
if (playerenters||timeout) {
for (i=0;i<arraylen(this.rainx);i++;) {
// Shows rain:
showimg i+500,@.,this.rainx[i],this.rainy;
// Puts the rain above the player:
changeimgvis i+500,3;
// If the rain reaches the end of the screen it will repeat:
this.rainx[i]+=(this.rainx[i]>64 ? -64 : 0);
this.rainy[i]+=(this.rainy[i]>64 ? -64 : 0);
/*
if this:
this.rainx[i]+=(this.rainx[i]>64 ? -64 : 0);
looks weird, what it is, is a condition, if you look, the syntax is this:
(condition ? a : b)
if the condition is true than it goes to a otherwise it goes to b.
If it doesn't make sence im me we can talk about it.
*/
}
timeout=.05;
}

__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
Reply With Quote
  #19  
Old 03-05-2002, 01:26 PM
stomper_TK stomper_TK is offline
Registered User
stomper_TK's Avatar
Join Date: Feb 2002
Location: My chair :-)
Posts: 846
stomper_TK is on a distinguished road
Send a message via AIM to stomper_TK
Hey I started this fad about not knowing how to script right?

[edit]And I still don't get what that rain script means at all! Somoene make an example that a two year old could understand! Because I'm ****ing lost.. [/edit]
__________________
Reply With Quote
  #20  
Old 03-05-2002, 02:00 PM
slick_soul slick_soul is offline
Registered User
Join Date: Sep 2001
Location: Florida
Posts: 484
slick_soul is on a distinguished road
Red face

lol. That last post he did finished me off.
__________________
Lopar:Excuse me ol chap your pants are on fire
Chap: Whay thank you for noticing sir , would you like to come over to my house for some tea and crumpets?
Lopar:umm well Like i said your pants are on fire
Chap: Oh yes i forgot AHHHHHH
Reply With Quote
  #21  
Old 03-06-2002, 01:03 PM
stomper_TK stomper_TK is offline
Registered User
stomper_TK's Avatar
Join Date: Feb 2002
Location: My chair :-)
Posts: 846
stomper_TK is on a distinguished road
Send a message via AIM to stomper_TK
jesbus.. HELP US PEOIPLES!

aim++ ramsey1337
__________________
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 02:28 AM.


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