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 10-13-2001, 09:31 PM
Shard_IceFire Shard_IceFire is offline
Registered User
Shard_IceFire's Avatar
Join Date: Jun 2001
Location: Eastern Harkoonia
Posts: 861
Shard_IceFire is on a distinguished road
Arrays...?

Hi!
I am a pretty good scripter, but one thing that I just skipped over when I was learning was arrays. I was wondering, exactly how do you use them? And what can they be used for?
Thanks.
__________________

-=Shard IceFire=-
Reply With Quote
  #2  
Old 10-13-2001, 09:34 PM
ownerofbabylon ownerofbabylon is offline
Lord Helmut
ownerofbabylon's Avatar
Join Date: Jun 2001
Location: Gainesville FL
Posts: 1,763
ownerofbabylon is on a distinguished road
Send a message via ICQ to ownerofbabylon Send a message via AIM to ownerofbabylon
they are used for storing more than one thing in a variable. it would be like hearts(1) and hearts (2) but the variable would just be hearts but it breaks it up into parts
__________________


Warrior of Light

WWW.BABYLONSERVER.COM
Reply With Quote
  #3  
Old 10-13-2001, 09:36 PM
KJS KJS is offline
The one, The only -
KJS's Avatar
Join Date: Apr 2001
Location: USA, Minnesota
Posts: 1,012
KJS is on a distinguished road
Send a message via AIM to KJS
Re: Arrays...?

Quote:
Originally posted by Shard_IceFire
Hi!
I am a pretty good scripter, but one thing that I just skipped over when I was learning was arrays. I was wondering, exactly how do you use them? And what can they be used for?
Thanks.
well a basic array would be like
NPC Code:

if(created){
this.x={1,30,50,25};
this.y={5,20,18,30};
}
if(playertouchsme){
this.rnd=int(random(0,4));
x=this.x[this.rnd];
y=this.y[this.rnd];
}

__________________
Thanks,
-KJL
Reply With Quote
  #4  
Old 10-14-2001, 04:45 AM
ownerofbabylon ownerofbabylon is offline
Lord Helmut
ownerofbabylon's Avatar
Join Date: Jun 2001
Location: Gainesville FL
Posts: 1,763
ownerofbabylon is on a distinguished road
Send a message via ICQ to ownerofbabylon Send a message via AIM to ownerofbabylon
Re: Re: Arrays...?

Quote:
Originally posted by KJS


well a basic array would be like
NPC Code:

if(created){
this.x={1,30,50,25};
this.y={5,20,18,30};
}
if(playertouchsme){
this.rnd=int(random(0,4));
x=this.x[this.rnd];
y=this.y[this.rnd];
}

whats:

if(created){
this.x={1,30,50,25};
this.y={5,20,18,30};
}

for?
__________________


Warrior of Light

WWW.BABYLONSERVER.COM
Reply With Quote
  #5  
Old 10-14-2001, 07:20 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
Re: Re: Re: Arrays...?

Quote:
Originally posted by ownerofbabylon


whats:

if(created){
this.x={1,30,50,25};
this.y={5,20,18,30};
}

for?
same thing as if you did
this.x[0]=1
this.x[1]=30
this.x[2]=50
this.x[3]=25
__________________
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
  #6  
Old 10-14-2001, 07:52 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
Re: Re: Re: Re: Arrays...?

Quote:
Originally posted by LiquidIce00


same thing as if you did
this.x[0]=1
this.x[1]=30
this.x[2]=50
this.x[3]=25
Maybe my mistake, but don't you need setarray this.x 4; in front of that?
__________________
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
  #7  
Old 10-14-2001, 08:02 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
Re: Re: Re: Re: Re: Arrays...?

Quote:
Originally posted by Xaviar


Maybe my mistake, but don't you need setarray this.x 4; in front of that?
yes

doing this.array={1,2,3,4}

is far more efficient
Reply With Quote
  #8  
Old 10-14-2001, 08:08 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
Re: Re: Re: Re: Re: Re: Arrays...?

Quote:
Originally posted by btedji


yes

doing this.array={1,2,3,4}

is far more efficient
'Tis generally what I do, unless I want the array to have a 'variable' length
__________________
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
  #9  
Old 10-16-2001, 09:51 PM
Shard_IceFire Shard_IceFire is offline
Registered User
Shard_IceFire's Avatar
Join Date: Jun 2001
Location: Eastern Harkoonia
Posts: 861
Shard_IceFire is on a distinguished road
=/ I still don't get why you would need them...
__________________

-=Shard IceFire=-
Reply With Quote
  #10  
Old 10-17-2001, 03:49 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
Quote:
Originally posted by Shard_IceFire
=/ I still don't get why you would need them...
say you have prices for different apples

you could do this:

this.appleprices={30,40,50,50}

then call it like this:

players[0].rupees-=this.appleprices[this.appletype];

which would be far more efficient than
having variables for each apple price and
would be easy to customize if you had at
the beginning of a script

Last edited by btedji; 10-17-2001 at 03:51 AM..
Reply With Quote
  #11  
Old 10-17-2001, 07:11 AM
Shard_IceFire Shard_IceFire is offline
Registered User
Shard_IceFire's Avatar
Join Date: Jun 2001
Location: Eastern Harkoonia
Posts: 861
Shard_IceFire is on a distinguished road
Quote:
Originally posted by btedji


say you have prices for different apples

you could do this:

this.appleprices={30,40,50,50}

then call it like this:

players[0].rupees-=this.appleprices[this.appletype];

which would be far more efficient than
having variables for each apple price and
would be easy to customize if you had at
the beginning of a script
I still don't quite get that....
rupees-=this.appleprices[this.appletype];
does it just choose one of the 'appleprices' numbers at random or something?
__________________

-=Shard IceFire=-
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:49 AM.


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