Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: HandsFree on Sun 30/09/2012 11:20:27

Title: Navigating a table [solved]
Post by: HandsFree on Sun 30/09/2012 11:20:27
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
Title: Re: Navigating a table
Post by: Khris on Sun 30/09/2012 14:06:17
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) Select
// header

struct str_message {
  String R[10];
};

// script
str_message Message_C[10];

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

Title: Re: Navigating a table
Post by: Calin Leafshade on Sun 30/09/2012 14:51:51
Or you could use the Lua Plugin, which supports multidimensional tables.
Title: Re: Navigating a table
Post by: HandsFree on Sun 30/09/2012 21:01:11
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).