Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-03-2003, 05:39 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
Post Multidimensional Strings

Now some of you know what these are, but here is a quick overview for those who don't;
Multidimensional strings are string arrays with more than one index (number assigned to a part of the string array). You may have seen the single dimension string arrays graal obviously has;
NPC Code:
 
setstring string,this,is,a,string,array;


but multidimensional arrays would have multiple entries for each of the entries in the above example. (like I said, quick)

Many of you have heard the rants about wanting these neat little things, but few have you know how to improvise them. I am going to show you a couple of different ways and explain the pros and cons of each one as best I can.

#1
altering the name of a string
You can emulate the properties of a multidimensional string array by using the names of the strings to your advantage;
NPC Code:

for (a=0;a<3;a++) {
for (b=0;b<3;b++) {
for (c=0;c<3;c++) {
setstring #v(a)_#v(b)_#v(c),#v(n);
n++;
}
}
}


-manual entering of indecies-
NPC Code:

setstring 0_0,1;
setstring 0_1,2;
setstring 1_0,3;
setstring 1_1,4;

(too much typing for the 3x3x3, so this is 2x2)
Will create a 3x3x3 string array with the indecies denoted in the name of the string. You can call each one the same way it is set
NPC Code:

#v(index1)_#v(index2)_#v(index3);


But of course this method will give you a new string for each entry, which while this may be easier to call, it takes up more memory (bad).

#2
altering name and making use of current string array function
You can shorten the number of strings created by using the built in string array system like so;
NPC Code:

for (a=0;a<3;a++) {
for (b=0;b<3;b++) {
for (c=0;c<3;c++) {
addstring #v(a)_#v(b),#v(n);
n++;
}
}
}


-manual entry-
NPC Code:

setstring 0,0,1;
setstring 0,1,2;
setstring 1,0,3;
setstring 1,1,4;

(again 2x2)
and you can call them like so
NPC Code:

#I(#v(index1)_#v(index2),index3);


this will shorten the number of strings to the dividend of the third index. It's a little more to type, but ohwell.

#3
integrating into current string arrays
this will put the whole string array into one string, it gets a little complicated in calling indecies, but it's worth it.
NPC Code:

setstring index,;
for (a=0;a<3;a++) {
setstring index1,;
for (b=0;b<3;b++) {
setstring index2,;
for (c=0;c<3;c++) {
addstring index2,#v(n);
n++;
}
addstring index1,#s(index2);
}
addstring index,#s(index1);
}


-manual entry-
NPC Code:

setstring string,"""0,1,2"",""3,4,5"",""6,7,8""","""9,10,11" ",""12,13,14"",""15,16,17""","""18,19,20"",""21,22 ,23"",""24,25,26""";

(note the placements of the "" )
and this is one of the ways to call a single entry;
NPC Code:

setstring string,#I(index,0);
setstring string1,#I(string,0);
setstring string2,#I(string1,1);
message #s(string2);



The third way can also be done with spaces and called using tokenize aswell but I've typed too much and need to get some sleep now. I hope this helps someone, and that I didn't make any mistakes... hehe
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial

Last edited by Dach; 04-04-2003 at 01:49 AM..
Reply With Quote
  #2  
Old 04-03-2003, 08:34 PM
Dude6252000 Dude6252000 is offline
More often known as Karsh
Dude6252000's Avatar
Join Date: May 2002
Location: USA.
Posts: 2,603
Dude6252000 is on a distinguished road
Send a message via AIM to Dude6252000
Quote:
Originally posted by Onijustin_P2P
okay....riiiight.....i get it
Was that post really necessary?

I've decided I'm going to start working with that stuff, though. I've been studying off of random scripts I find with those kinds of lights and etc, the multi-dimension ones, and I'm slowly learning how to do this stuff. Thanks for posting this. :O
__________________
BEING AWAY FROM THE FORUMS RULES

http://www.livejournal.com/users/karsheth/
Reply With Quote
  #3  
Old 04-04-2003, 01:59 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
Oh, boy, sorry about all the edits, I didn't have enough time to check everything while posting. All of it will work right, now.

Do take care to note the number of quotations around each entry, if you're not sure how many to put on, try using the for loop technique I did just to make sure (you might want to make sure, since I've tryed a couple of things and I have no idea whats going on).

Oh and Kai, your calling idea doesn't seem to work. It should, but doesn't. We should probably ask Stefan to make it work...
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:37 PM.


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