Author Topic: About managed structs and structs  (Read 224 times)  Share 

About managed structs and structs
« on: 12 Jul 2017, 01:48 »
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: Adventure Game Studio
  1. struct Pos {
  2.  int x;
  3.  int y;
  4. }
  5.  
  6. Pos initialPosition;
  7. Pos importantPosition[3];
  8.  

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

Managed Struct

Code: Adventure Game Studio
  1. managed struct Pos {
  2.  int x;
  3.  int y;
  4. }
  5.  
  6. Pos * initialPosition;
  7. Pos * importantPosition;
  8.  
  9. //we can't use 'initialPosition = new Pos;' in the body, it needs to be in a function
  10.  
  11. function initialisePositions(){
  12.     initialPosition = new Pos;
  13.     importantPosition = new Pos[3];
  14.     importantPosition[0] = new Pos;
  15.     importantPosition[1] = new Pos;
  16.     importantPosition[2] = new Pos;
  17.    
  18. }
  19.  
  20. function moveDancingTo(Pos * destination){
  21.  
  22.     // do something with destination
  23.  
  24. }
  25.  


Managed strucs allow passing structs as parameters

AGA

  • Adventure Game Aficionado
  • Administrator
  • Mittens Deity
  • ¡Qué alí­vio!
    • Lifetime Achievement Award Winner
    •  
  • AGA worked on a game that was nominated for an AGS Award!
Re: About managed structs and structs
« Reply #1 on: 12 Jul 2017, 05:46 »
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!