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 03-10-2002, 05:31 AM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
arrays

i dun know nothing about arrays yet i read npc programming bud tough i dont understand and i dun even know where arrays are good for ,can some teach me in this
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #2  
Old 03-10-2002, 05:40 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
http://razza.org/tormented/php/variables.php

I believe I have something bout regular variable arrays, but not string arrays ...
Reply With Quote
  #3  
Old 03-10-2002, 05:43 AM
screen_name screen_name is offline
is watching you
Join Date: Mar 2002
Location: The 3rd Dimension
Posts: 2,160
screen_name is on a distinguished road
Send a message via AIM to screen_name Send a message via MSN to screen_name
quite simple

a array is like a lot of variables all in one variable

u can set variables like this:

arrayname={0,0,0}

or setarrary arrayname,3;

each would produce the array, arrayname={0,0,0}

and u can use variables out of the array by using indexes, like this

lets say there is a array 'nums' and it is equal to {3,5,7}
say2 #v(arrayname[index]);
so if the index was 2 it would show 7

u must remember that the indexes start with 0, not 1

so

nums[0] - 3
nums[1] - 5
nums[2] - 7

also, if you want to set a value in a array, just do this:

arrayname[index]=whatevervarialbe;
__________________
[signature]insert here[/signature]
Reply With Quote
  #4  
Old 03-10-2002, 08:04 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
also, there are string arrays, there are specific commands for them:
(from newfeatures2001.txt)
addstring list,text;
insertstring list,index,text;
replacestring list,index,text;
removestring list,text;
deletestring list,index;
sarraylen(list)
lindexof(list,text)
#I(list,index)
Reply With Quote
  #5  
Old 03-10-2002, 09:57 AM
screen_name screen_name is offline
is watching you
Join Date: Mar 2002
Location: The 3rd Dimension
Posts: 2,160
screen_name is on a distinguished road
Send a message via AIM to screen_name Send a message via MSN to screen_name
he first needs to learn the basics of arrays, then string arrays should come in
__________________
[signature]insert here[/signature]
Reply With Quote
  #6  
Old 03-10-2002, 10:49 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally posted by screen_name
he first needs to learn the basics of arrays, then string arrays should come in
I don't find any of them hard, string arrays are probably the easiest, I thought they were normal strings until I found out they were string arrays
Reply With Quote
  #7  
Old 03-10-2002, 01:23 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
would someone mind explaining string arrays to me (accesing them, settings them, etc.) and hopefully if I learn em i'll write ai little tutorial for them ...
Reply With Quote
  #8  
Old 03-10-2002, 09:24 PM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
mmm.. ok i understand it. bud what will an array be good for i know its a noobish question i mean what will it come in handy for.
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #9  
Old 03-10-2002, 10:36 PM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
Re: arrays

Quote:
Originally posted by la_builder
i dun know nothing about arrays yet i read npc programming bud tough i dont understand and i dun even know where arrays are good for ,can some teach me in this
its simple.. you have 2 balls in different positions.. so..
ballsx={1,2} //arrays
ballsy={1,2} //arrays

ballsx[1]= 12;
ballsy[1]= 10;
ballsx[2]= 13;
ballsy[2]= 9;

or u can use it in any other place where you have 1 name but more numbers for it...
Reply With Quote
  #10  
Old 03-11-2002, 12:09 AM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
oo now is see thanks everyone
and some bad news another noobish question

NPC Code:
 if(playerenters) { putleaps 3,24,23;sleep 5; putleaps 3,2,5}

how do i loop this so it keeps repeating
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #11  
Old 03-11-2002, 12:39 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally posted by la_builder
oo now is see thanks everyone
and some bad news another noobish question

NPC Code:
 if(playerenters) { putleaps 3,24,23;sleep 5; putleaps 3,2,5}

how do i loop this so it keeps repeating
...
if (created||timeout){
putleaps 3,24,23;
sleep 5;
timeout=.05;
}
Reply With Quote
  #12  
Old 03-11-2002, 03:33 AM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
Talking

thanks
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #13  
Old 03-11-2002, 04:25 AM
screen_name screen_name is offline
is watching you
Join Date: Mar 2002
Location: The 3rd Dimension
Posts: 2,160
screen_name is on a distinguished road
Send a message via AIM to screen_name Send a message via MSN to screen_name
i have never tried this, but would it work??

NPC Code:

if (playerenters) {
message #v(random(0,1));
sleep 3;
callnpc npcid,playerenters;
}



shouldnt that make the npc repeat ??
__________________
[signature]insert here[/signature]
Reply With Quote
  #14  
Old 03-11-2002, 04:48 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 screen_name
i have never tried this, but would it work??

NPC Code:

if (playerenters) {
message #v(random(0,1));
sleep 3;
callnpc npcid,playerenters;
}



shouldnt that make the npc repeat ??
maybe, but it might lag ...
Reply With Quote
  #15  
Old 03-11-2002, 04:53 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 Kaimetsu


Yes, but I couldn't guarantee that it would get the timing exactly right - it could have 1.05 seconds between calls occasionally etc. Plus does "npcid" work? I thought it'd just be "id".
i usually would just do something like this ...
NPC Code:

NPC Code:

if (playerenters) {
message #v(random(0,1));
sleep 3;
for (i=0;i<npcscount;i++) {
callnpc i,playerenters;
}
}



Reply With Quote
  #16  
Old 03-11-2002, 04:56 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 Kaimetsu


Woah, that's crazy. Then every NPC in the level will run all its initialisation scripts and break up whatever it's doing!
I meant that just for the general idea, I knew what would happen ...
Reply With Quote
  #17  
Old 03-11-2002, 05:02 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 Kaimetsu


All in all, I think we can agree that timeouts win the day.
yea ...
Reply With Quote
  #18  
Old 03-11-2002, 05:21 AM
screen_name screen_name is offline
is watching you
Join Date: Mar 2002
Location: The 3rd Dimension
Posts: 2,160
screen_name is on a distinguished road
Send a message via AIM to screen_name Send a message via MSN to screen_name
i know that callnpc isnt immediate

and i do agree that timeouts rule
__________________
[signature]insert here[/signature]
Reply With Quote
  #19  
Old 03-11-2002, 05:43 PM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
question agian is it possible to run to npc at a time in one and the same npc editor screen.So i mean that the scripts do there stuff at the same time.
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #20  
Old 03-11-2002, 06:25 PM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
.....sorry is it possible to fuse 2 diffirent npc' s in one npc.Bud tough they would run at the same time.Can understand me now.
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #21  
Old 03-11-2002, 08:52 PM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
bud wouldnt this do first the x than the y.
let me explain i need to make a pw system and i need to fuse a putleaps with a rain script clear so far?Now i wanna make sure the diong 2 things at 1 time like putting the leaps and raining.
so the wont do putting leaps first and after that rainging uderstand me
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #22  
Old 03-11-2002, 09:02 PM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
NPC Code:
 raining script<--after this i put ;putleaps 5,34,12;



wouldnt it start raining and put the laps after the end of the raining script.so it will stop raining and than start putting laps
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #23  
Old 03-11-2002, 09:11 PM
screen_name screen_name is offline
is watching you
Join Date: Mar 2002
Location: The 3rd Dimension
Posts: 2,160
screen_name is on a distinguished road
Send a message via AIM to screen_name Send a message via MSN to screen_name
Quote:
Originally posted by Kaimetsu


Then I suggest you buy a quantum computer, because they're the only kind I know of that can work on two separate tasks simultaneously. But if you're content for it to merely LOOK like everything's happening at once then the script I showed you would work fine. There would be no way for the player to know which of x or y was changed first.
__________________
[signature]insert here[/signature]
Reply With Quote
  #24  
Old 03-11-2002, 11:14 PM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
thanks dude
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #25  
Old 03-12-2002, 01:17 AM
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
Arrays.

Ok, I am goona bust this out supreme style...but I wanted to ask,, I have never used the callnpc command, so could someone tell me about it? Anyway, heres a supreme explanation of arrays. ;)

Arrays are basically values that contain other values, like a long string of numbers (unless unsing string arrays), that can be called and changed, it is one of the best ways I know of to keep organized. Also there are so many great values to arrays, you will end up using them in practiallcy every script. So what I will first define is the different ways to create your arrays. The first way is to actually use the setarray name,size; command.
NPC Code:

setarray this.rainx,100;
setarray this.rainy,100;


The second way of setting arrays is through curly brackets.
NPC Code:

this.rainx = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
this.rainy = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};



The next thing I will discuss is getting and setting values of arrays. Ok, there are so many ways of actually setting the values, the first I will explain is the simple one.
NPC Code:

setarray this.rainx,100;
setarray this.rainy,100;
this.rainx[0] = 10;
this.rainx[1] = 15;
this.rainy[0] = 5;
this.rainy[1] = 10;


Something to always remember is that arrays start on the value 0 not 1, so the first value in the array is 0 and the last it the arraysize-1. The previous way of setting the array value is best for when setting only one or two values, the next way I will show you is a way for setting arrays when multiple values are needed
NPC Code:

this.rainx = {1,1,1,1,1,1,1,1,1,1};


This will set this.rainx with 10 values with 1 as each, this is a good way when having specific values that will be consistant thruout the script. The next thing I will explain is how to use a for loop to generate random values for an array using the arraylen() variable. If you call arraylen(this.rainx) on the previous example, it will return 10, because it measures how many values are in the array. So using this you could measure the size of an array with undefined values set with setarray; as in this example.
NPC Code:

setarray this.rainx,100;
for (i=0;i<arraylen(100);i++;)
this.rainx[i] = random(0,100);


The next thing I will explain is how to call array values, as in this example.
NPC Code:

setarray this.rainx,100;
for (i=0;i<arraylen(100);i++;) {
this.rainx[i] = random(0,100);
setplayerprop #c,#v(this.rainx[i]);
sleep .05;
}


So this correctly reads the value and sets the player's chat to the random value. The next thing I will exaplin is how to read values and act on them.
NPC Code:

setarray this.rainx,100;
for (i=0;i<arraylen(100);i++;)
this.rainx[i] = random(0,100);
if (this.rainx[5]>=3)
setplayerprop #c,this.rainx[5] is more than or equal to three, its exact value is #v(this.rainx[5]);
else
setplayerprop #c,this.rainx[5] is less than three, its exact value is #v(this.rainx[5]);


Another very little known fact, is that the value is set as it goes, so in this example, all values will be set correctly.
NPC Code:

this.rainx = {32,this.rainx[0]-10,this.rainx[0]-15};


This can be used very often when writing code that depends on other values. Also you can include conditions in arrays like so (if you don't know what a condition is, it can be an if statement or a block like this num = (a==0 ? 1 : 0) what this does is, if a equals 0 than num equals 1 otherwise it equals 0).
NPC Code:

this.rainx = {32,(this.rainx[0]>0 ? 1 : 0),this.rainx[0]-15};


I need to go now, so that is all I will explain for now, maybe later later. I hope that was useful.
__________________

!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
  #26  
Old 03-12-2002, 03:26 AM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
thanks thats really usefull you should make a tutorial
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #27  
Old 03-12-2002, 03:38 AM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
NPC Code:
//Rain Array by -=GodSpeed=-
--Removed by Kaimetsu--



for example how would i fuse this with this
NPC Code:
// NPC made by Discounter{hiring lats}
if (created||timeout)

putleaps 5,13,36;sleep 2;putleaps 5,30,33
;sleep 2;putleaps 5,70,60;sleep 5
;putleaps 5,50,40; sleep 2;putleaps 5,12,50;sleep 2;putleaps 5,19,23;sleep 3;putleaps 5,14,32;sleep 2;putleaps 5,36,10;putleaps 5,38,33; sleep 3;putleaps 5,34,11;sleep 4;putleaps 5,12,50;sleep3;putleaps 5,30,40;putleaps 5,playerx,playery;timeout=0.5;}



i want them to work at the same time so rain with the putleaps.Some how i still cant get it to work.
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon

Last edited by Kaimetsu; 03-12-2002 at 01:15 PM..
Reply With Quote
  #28  
Old 03-12-2002, 06:49 AM
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
NPC Code:

--Removed by Kaimetsu--
--Respected by PastAustin--


poor god speed, using his script.
this should work...
__________________

!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

Last edited by Saga2001; 03-13-2002 at 12:50 AM..
Reply With Quote
  #29  
Old 03-13-2002, 12:49 AM
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
Quote:
Originally posted by Kaimetsu
GodSpeed might not be here, but I'm sure he doesn't want his scripts posted all around the place, and he certainly doesn't want them stolen for playerworlds.
Well just as a comment, I showed how to fix that, not so it could be used for a playerworld, but to teach someone to script better. La_builder, if i see it on a playerworld you work on, man I would talk smack about that server. I am friends with GodSpeed personally, and I do not think he would really care less, but I will respect the thought and delete it from my previous post, not that it would do anything, because it was already posted by la_builder. La_builder, if you can't script your own weather system, than you don't deserve to use that one.
__________________

!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
  #30  
Old 03-13-2002, 01:57 AM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
aaaaaaaaaaahhhh flipping read example jeez i not meant to use it for my self or something i wanted to post a example caus i didnt feel like posting my own rain thunder time day night script
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #31  
Old 03-13-2002, 02:01 AM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
i feel so omg dumb i should knew that you where begining to say "o my he stole a script" or something


so agian IM NOT STEALING ANYTHING FROM ANYONE {EXAMPLE}
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #32  
Old 03-13-2002, 03:48 AM
la_builder la_builder is offline
Registered User
Join Date: Jan 2002
Location: Holland
Posts: 154
la_builder is on a distinguished road
well after asking three times i got sick of people not understanding me (thats my fault this is my second year english )
so i tought why dont post an EXAMPLE and make my self clear that way.
__________________
Dark Frontier
The enemy is surrounding us all,more evil than a human could ever imagine.

Dark Fontier Coming Soon
Reply With Quote
  #33  
Old 03-13-2002, 11:25 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally posted by la_builder
i feel so omg dumb i should knew that you where begining to say "o my he stole a script" or something


so agian IM NOT STEALING ANYTHING FROM ANYONE {EXAMPLE}
This picture says it all
[EDIT]
The colors got a little messed when I converted it from a bmp to a gif but here's the limit of my talent with gfx =o
[/EDIT]
Attached Thumbnails
Click image for larger version

Name:	editbutton.gif
Views:	104
Size:	25.7 KB
ID:	13202  
Reply With Quote
  #34  
Old 03-14-2002, 01:28 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
Quote:
Originally posted by Kaimetsu
I understood you. You just weren't listening to my responses.
Its true that you don't need to post a huge script to implement small things.
Sorry Kai, I was just trying to help...
__________________

!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
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 11:56 PM.


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