I have no delved much into them, but how would one go about setting up a custom array?
I need a function that captures a string (tag) into an array, and another to check the array for a specific string. And another to delete a string from the array.
I don't see many array functions to work with.
I could do like NWN and create one using the string functions, but I though DAO has support for arrays?
Of course I could be missing something obvious in the functions list.
Custom arrays?
Débuté par
georage
, déc. 10 2009 03:54
#1
Posté 10 décembre 2009 - 03:54
#2
Posté 10 décembre 2009 - 04:02
string [] my_stringarray; my_stringarray[0]="Yes"; my_stringarray[1]=" We "; my_stringarray[2]="Can!"; int i; string s=""; for (i=0;i<3;i++) s+=my_stringarray[i]; DisplayFloatyMessage(GetHero(),s,FLOATY_MESSAGE,0xFFFF00,10.0);
Modifié par J.O.G, 10 décembre 2009 - 04:07 .
#3
Posté 10 décembre 2009 - 04:23
georage wrote...
I have no delved much into them, but how would one go about setting up a custom array?
As long as you're happy with one dimension arrays, the [] built-in structures will do just fine. Multidimentionnal arrays requires a bit of work, however.
I need a function that captures a string (tag) into an array, and another
to check the array for a specific string. And another to delete a
string from the array.
Of course I could be missing something obvious in the functions list.
Well, there's simply not much array manipulation functions in there, but basic functions are usually quite easy to write anyway. For instance, your second need would basically be covered by a built-in GetStringArrayIndex() function but unlike the object/integer counterparts it's missing, so I just use a simple one to make up for its absence. (and am prolly not the only one ^_^")
Modifié par Phaenan, 10 décembre 2009 - 04:30 .
#4
Posté 10 décembre 2009 - 04:35
Sweet, thanks guys. You saved me a lot of thinking time!
#5
Posté 10 décembre 2009 - 05:02
Ummm ... how would one use the string pulled out of the array when creating an object?
I used a variation of JOGs array to pull a random string from the array ... but I am stuck with this, which does not compile.
CreateObject(OBJECT_TYPE_CREATURE,R+sRandomCritter,GetLocation(oRandWP));
I am looking for something like a concat operator I guess.
I used a variation of JOGs array to pull a random string from the array ... but I am stuck with this, which does not compile.
CreateObject(OBJECT_TYPE_CREATURE,R+sRandomCritter,GetLocation(oRandWP));
I am looking for something like a concat operator I guess.
#6
Posté 10 décembre 2009 - 05:07
That won't work. There is no way of creating a valid resource from a string. So basically, you could put resources in your array and adapt the "looking for a tag function". (adding a simple ResourceToTag() in the comparaison should work)
#7
Posté 10 décembre 2009 - 05:10
I should not have drank my way through that C class.
#8
Posté 10 décembre 2009 - 05:10
pun intended.
#9
Posté 10 décembre 2009 - 05:14
That worked! Thanks!





Retour en haut






