Use struct instance in struct?

Started by NsMn, Fri 07/08/2009 18:04:23

Previous topic - Next topic

NsMn

Hello,

I'm, again, a bit stuck in scripting. I wanted to do something like this:

Code: ags

struct Streetgroup{
String Colorname;
int Colornumber;
[...]
};

struct Street{
int price;
[...]
Streetgroup OwningGroup;

}

...so that I can call a function like MuseumStreet.OwningGroup.Colornumber; .

But, AGS doesn't allow me to do something like the line "Streetgroup OwningGroup;" in another struct - but, obviously, It works with the build-in structs like GUI* or Character*.

Is there really no way to do this?



DoorKnobHandle

No, AGS just doesn't allow structs within structs or any workarounds.

You can code your own plugins using C++ and use that feature or just do as I do and regularly fall to you knees in front of CJ and beg for this to be the next big feature! :)

monkey0506

The reason "it works with the buil[t]-in structs like GUI* or Character*" is because those aren't instances of a struct, they're pointers. :P

However, AGS doesn't currently allow pointers to custom struct types so that wouldn't work either.

If by chance you have a global array of the Streetgroup struct (which will be the only instances of the struct) then you could change OwningGroup to an int and then do:

Code: ags
street_groups[MuseumStreet.OwningGroup].Colornumber = 13;

SMF spam blocked by CleanTalk