Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Chrisz: Storing a hell of a lot of info.... (https://forums.graalonline.com/forums/showthread.php?t=31116)

user13-xo 06-08-2002 02:32 AM

Chrisz: Storing a hell of a lot of info....
 
Chrisz: How can i store LOADS of info in a string.... like
client.boxes="box1" "box7"
and then.... arf make it so i can select what box i have?
and no im not asking for scripts just i havent ever done
anything liek this..... :confused:

user13-xo 06-08-2002 03:00 AM

=o Idea....
 
i could set each one as.... set hasbox1! :D

buuuut.... How would i access em all?? Without doing a HUGE EEK
script....

if (hasbox#v(this.box))
Obviously that dont work.... any ways around it? :X

Spanko 06-08-2002 03:24 AM

String arrays and for loops are what you seek.

String arrays are basically string which can contain multiple parts of informatoin in an easily accesible way, string arrays should be explained in newfeatures.txt somewhere (Which should be in your Graal folder), and a for loop is basically for (before loop action;condition to stop performing;End of loop action), or to make an example of cade which works the same as the for loop:
NPC Code:
if (created) {
before loop action;
while (condition to stop performing) {
Other stuff;
end of loop action;
}
}


Is actually equal to:
NPC Code:
if (created) {
for (before loop action;condition to stop performing;end of loop action) {
other stuff;
}
}



With a for loop in combination with a string you can also make use of the sarraylen(sarrayname) function to make the for loop exactly check all entries in the string array.


I hope that helps. :)

user13-xo 06-08-2002 03:37 AM

O.o String arry = non-p2p?
 
I have heard of loops (duh) but string arrays?? i heard of lists too but still string arrays? :O Can u explain or will i have to ponder....

Spanko 06-08-2002 03:40 AM

Re: O.o String arry = non-p2p?
 
Quote:

Originally posted by user13-xo
I have heard of loops (duh) but string arrays?? i heard of lists too but still string arrays? :O Can u explain or will i have to ponder....
This is the excerpt from newfeatures.txt about string arrays:

Quote:

- String arrays! they are saved in normal flags/string
variables and look like 'myarray=123,"45",67,"8,9"'
Commands/Functions:
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) - gives you the string on place 'index'
Most of them speak for themselves, at least in my opinion.

user13-xo 06-08-2002 03:55 AM

lmao
 
O.o im retarded lol i know what they are now..... i never knew they were called string arrays O.o X.x But that dont explain how i should make the damn npc look....

if (keydown(1) && this.box>0) {
this.box-=1;
tokenize client.boxs;
while (!strcontains(#t(this.box),box#v(this.box))) {
this.box-=1;
}
}

See O.o so i can make like a selector like if you dont have a box
it misses it out.... =?

Saga2001 06-08-2002 08:19 AM

Re: lmao
 
Quote:

Originally posted by user13-xo
O.o im retarded lol i know what they are now..... i never knew they were called string arrays O.o X.x But that dont explain how i should make the damn npc look....

if (keydown(1) && this.box>0) {
this.box-=1;
tokenize client.boxs;
while (!strcontains(#t(this.box),box#v(this.box))) {
this.box-=1;
}
}

See O.o so i can make like a selector like if you dont have a box
it misses it out.... =?

nuuuuuu! don't use tokenize!
use this:
addstring list, string;
and to access a string in the string array use:
#I(list, index);

Warcaptain 06-10-2002 08:22 PM

tokenize2 ,,#s(this.boxes);
this.foundbox=false;
for (i=0;i<tokenscount;i++;){
if (strequals(#t(i),wat ur trying to find here)){
this.foundbox=true;
}
}
if (this.foundbox==true){
say2 you found me loser;
}else say2 you didnt fine me lol;


All times are GMT +2. The time now is 04:31 PM.

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