Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 09:12 PM.


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