Aller au contenu

Photo

Custom arrays?


  • Veuillez vous connecter pour répondre
8 réponses à ce sujet

#1
georage

georage
  • Members
  • 247 messages
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.

#2
J.O.G

J.O.G
  • Members
  • 355 messages

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
Phaenan

Phaenan
  • Members
  • 315 messages

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
georage

georage
  • Members
  • 247 messages
Sweet, thanks guys. You saved me a lot of thinking time!

#5
georage

georage
  • Members
  • 247 messages
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.




#6
Phaenan

Phaenan
  • Members
  • 315 messages
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
georage

georage
  • Members
  • 247 messages
I should not have drank my way through that C class.

#8
georage

georage
  • Members
  • 247 messages
pun intended.

#9
georage

georage
  • Members
  • 247 messages
That worked! Thanks!