Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Superman95 on Sat 10/09/2005 04:18:40

Title: Properties
Post by: Superman95 on Sat 10/09/2005 04:18:40
How does one use properties on an object?

For instance, if I assign a property to a character, can I access it from code?

Also, If i create a struct how can I persist the struct when the game is save.  i.e. save the users experience points when he saves his game.  I know I can use Global Ints...but what's the point in using a struct if i have to update the global int everytime anyway.
Title: Re: Properties
Post by: That Guy on Sat 10/09/2005 05:31:32
QuoteFor instance, if I assign a property to a character, can I access it from code?

Yes, although AFAIK properties are read-only.  You have to set them in the editor.

QuoteAlso, If i create a struct how can I persist the struct when the game is save.  i.e. save the users experience points when he saves his game.

Pretty much all of your variables are stored when you save your game, although if this extends to the values within structs I can't say for sure.

Just out of curiosity, why would you need a struct just for experience points?
Title: Re: Properties
Post by: Superman95 on Sat 10/09/2005 05:52:08
actually, I don't...the struct looks like this...

struct Statistics
{
  int Strength;
  int Intelligence;
  int Agility;
  int Vitality;
  int Luck;
  int Magic;
  int WeaponUse;
  int Parry;
  int Dodge;
  int Stealth;
.....
};

you get the idea.  I didn't really like the idea of having global ints for all of them..
What I actually wanted to do was write a OO module to handle as much of the RPG elements as I could.  the problem with global ints is collisions...the person using the module would have to know those global ints are used by this module.

What i wanted was to be able to include datablock(s) with the saved game.  which would be very handy for other things.  like tracking spells  or who knows.
Title: Re: Properties
Post by: Pumaman on Sat 10/09/2005 13:08:44
To access a character property, just use:

cCharName.GetProperty

As for save games, all of your script data is automatically saved in the save game file. Are you having a problem with it?
Title: Re: Properties
Post by: Superman95 on Sat 10/09/2005 16:02:35
Actually, I haven't tried it yet....but I will that's cool.  And i'm guessing it doesn't matter if it's in a module or not

Title: Re: Properties
Post by: Superman95 on Sun 11/09/2005 17:14:27
while, we're on the subject, I have a suggestion related to properties.

In the editor, it would be more user friendly to have the property editor work more like Access.  Where it's like a table with an empty row at the bottom for inserting.  Perhaps a table for each type.  Like a table for the text types and another table for the int types.  It would seem faster to enter properties.
Title: Re: Properties
Post by: monkey0506 on Sun 11/09/2005 20:53:59
I have a suggestion.  For every Object/Hotspot/Character/Room in the game that has a custom property set to it, make it a writeable Property of said Object/Hotspot/Character/Room.

For example, if I have the character EGO (cEgo), then I add a custom "number" property, Health, to him, it would make it a lot easier if I could do cEgo.Health = 5; instead of a) having to use the GetProperty function and b) not being able to change the value of the property.

I realize it's not a trivial task, but it would be nice.
Title: Re: Properties
Post by: Rui 'Trovatore' Pires on Sun 11/09/2005 22:46:39
[off-topic] Every time I look at the title of this thread my mind finishes the sentence: "...a friend of Socrates." [/off-topic]