Large read-only 2d array of strings.

Information and Discussion Relating to NWN2 Scripting and Coding

Moderators: Moderator, Developer, DM

NegInfinity
Posts: 2449
Joined: Wed Feb 05, 2014 11:24 am

Large read-only 2d array of strings.

Unread post by NegInfinity »

I need to add somewhat large global read-only 2d array of strings to module. Shouldn't be tied to any object, needs to be global.

C/C++ code equivalent:

Code: Select all

const char * table1[][5] = {
 {"asdf", "asdf", "asdf", "asdf", "asdf"},
 {"asdf", "asdf", "asdf", "asdf", "asdf"},
 ....
};

//or 
std::string table2[][5] = {
 {"asdf", "asdf", "asdf", "asdf", "asdf"},
 {"asdf", "asdf", "asdf", "asdf", "asdf"},
 ....
};
I don't need to update values, only read them.

How do I do that?

I could, of course, jam all data into one long string and use string manipulation routines, but it is probably going to be fairly slow (linear search to access element).

The game use 2da files... can I make my own 2da, load it and access its contents? Or do I have to use Get/Set LocalArray String/Int functions?
NegInfinity
Posts: 2449
Joined: Wed Feb 05, 2014 11:24 am

Re: Large read-only 2d array of strings.

Unread post by NegInfinity »

Nevermind, found Get2DAString .

However, if there are other options, I'd like to hear about them.

Return to “NWN2 Scripting”