Nested Variable

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

beneee
Posts: 15
Joined: Tue May 14, 2013 8:18 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Nested Variable

Postby beneee » Tue Mar 19, 2019 7:34 pm

Hi All,

Hopefully this is not a duplicate question as i have searched and I have the terminology correct but i am trying to get a nested variable working, here is a crude example of the code that I am attempting to get working.

- Variables -
ActiveTeam = 1
Team1Colour = Red
Team2Colour = Green
Team3Colour = Blue

- Program Output -
Your team Colour = Team(ActiveTeam)Colour

I really hope that makes sense.

Thanks
Ben

User avatar
Benj
Matrix Staff
Posts: 14323
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4412 times
Been thanked: 4130 times
Contact:

Re: Nested Variable

Postby Benj » Wed Mar 20, 2019 10:41 am

Hello,

It sounds like you maybe need a multi dimensional array.

TeamColours[2][3]

Would give you two teams each with three colour values.

You would then reference like this.

Red = TeamColours[ActiveTeam][0]
Green = TeamColours[ActiveTeam][1]
Blue = TeamColours[ActiveTeam][2]