Navigating a table [solved]

Started by HandsFree, Sun 30/09/2012 11:20:27

Previous topic - Next topic

HandsFree

I'm trying to store messages on different subjects in a table and wanted to do something like:
String Message [10, 10];
And then use counters for row and column to find/set the texts:
lblText.Text = Message[iColumn, iRow].
Apparently this isn't supported (yet?).

From the manual it doesn't look like I can use a struct this way.
Is there a way I can do something like this? Navigating a table using two counters?

thanks

Khris

AGS doesn't support multi-dimensional arrays yet.

You can either declare Message[100] and calculate the index:
Message[iRow*10 + iColumn]

or you can "fake" it with a struct:

Code: ags
// header 

struct str_message {
  String R[10];
};

// script
str_message Message_C[10];

// inside some function
lblText.Text = Message_C[iColumn].R[iRow];


Calin Leafshade

Or you could use the Lua Plugin, which supports multidimensional tables.

HandsFree

Thanks, for now the first option (calculating) works fine. I didn't understand from the manual that you can use an array like that with a struct BTW (with an index after the dot).

SMF spam blocked by CleanTalk