Multi dimensional arrays (Square Bracket Syntax)

I’ll try and check it in the next day or so.

Are you aware of the cslib project?

It contains a number of extremely useful libraries including cslib_array, which will likely have a easier solution. You may care to check it out.

You could also solve your particular problem via cslib using cslib_object, which simulates an array of objects.

e.g.
Step 1: define your fairy ‘object’

*create fairy_field_1 “name”
*create fairy_field_2 “type”
*create fairy_field_3 “greeting”
*create fairy_field_max 3

Step 2: create a place to hold the current fairy instance

*create fairy_name “”
*create fairy_type “”
*create fairy_greeting “”

Step 3: create some fairies

*create fairy_1_name “Beth”
*create fairy_1_type “nice”
*create fairy_1_greeting “Oh, so pleased to meet you.”

*create fairy_2_name “Slavos”
*create fairy_2_type “naughty”
*create fairy_2_greeting “Wadda you want?”

etc

Step 4: get your fairy e.g.
*gosub_scene cslib_object get fairy 2

fairy_name will now be “Slavos”
fairy_type will now be “naughty”
fairy_greeting will now be “Wadda you want?”

You can also get it by any field:
*gosub_scene cslib_object get_by_field fairy “name” “Slavos”
which will have the same effect.

4 Likes