Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: strazer on Sat 15/05/2004 22:24:40

Title: Nesting structs/arrays (Solved)
Post by: strazer on Sat 15/05/2004 22:24:40
Here's an example:

Global script

struct Type1 {
   int list;
   int position;
};
Type1 letter[2];

struct Type2 {
   int entries[20];
};
Type2 lists[10];

on_key_press

// init values for this example
letter[1].list = 1;
letter[1].position = 5;
lists[1].entries[5] = 666;

int result = lists[letter[1].list].entries[letter[1].position];
Display("%d", result); // returns 0

int templist = letter[1].list;
int tempposition = letter[1].position;
result = lists[templist].entries[tempposition];
Display("%d", result); // returns 666

It's not a problem since there's an easy workaround, but I'm curious as to why it behaves this way?

EDIT: Fixed since v2.62 Beta 1
Title: Re: Nesting structs/arrays
Post by: stuh505 on Sat 15/05/2004 23:51:09
heh, that is wierd.  funny thing is, this works:

int result = lists[letter[1].list].entries[5];
Display("%d", result); // returns 666
Title: Re: Nesting structs/arrays
Post by: Scorpiorus on Sun 16/05/2004 14:36:35
Hehe, yet another reason why arrays and structs are unofficial.
Title: Re: Nesting structs/arrays
Post by: Pumaman on Sun 16/05/2004 21:42:32
Interesting, I'll look into it.