Adventure Game Studio

AGS Development => Site & Forum Reports => Topic started by: eri0o on Wed 12/07/2017 01:48:50

Title: About managed structs and structs
Post by: eri0o on Wed 12/07/2017 01:48:50
Hey,

The wiki needs an entry explaining managed structs and how to make array of them.

The wiki page is here: http://www.adventuregamestudio.co.uk/wiki/Referencing_custom_struct_types

The content I want to add is below, but I don't have clearance to be able to add content to the wiki:

Simple struct declaration

Code (ags) Select

struct Pos {
int x;
int y;
}

Pos initialPosition;
Pos importantPosition[3];


This kind of struct though can't be passed as argument of a function.

Managed Struct

Code (ags) Select

managed struct Pos {
int x;
int y;
}

Pos * initialPosition;
Pos * importantPosition;

//we can't use 'initialPosition = new Pos;' in the body, it needs to be in a function

function initialisePositions(){
    initialPosition = new Pos;
    importantPosition = new Pos[3];
    importantPosition[0] = new Pos;
    importantPosition[1] = new Pos;
    importantPosition[2] = new Pos;
   
}

function moveDancingTo(Pos * destination){

    // do something with destination

}



Managed strucs allow passing structs as parameters
Title: Re: About managed structs and structs
Post by: AGA on Wed 12/07/2017 05:46:34
Hey, sorry I didn't reply to your PM yet.  I'm having difficulty working out why you aren't able to log in to the wiki.  All forum users should be able to, so I'm not sure what's stopping you from doing it.  As soon as I work it out, I'll let you know!
Title: Re: About managed structs and structs
Post by: eri0o on Sat 26/05/2018 15:22:12
Hey AGA, I still can't post in the wiki.