Question: Adding Custom Properties to the Character/Object/Inv etc entities.

Started by Pod, Thu 07/07/2005 23:15:24

Previous topic - Next topic

Pod

Hi,I haven't started implementing my game with AGS yet, but I'm just checking out the available solutions. In my game, I'll need to store a couple more attributes [propeties] about the characters/objects/hotspots/inv items etc. Basically, what I need to know is this:

In AGS is it possible to extend the attributes of an object?  ie, on this page in the manual[1], it lists all available properties. Would it be possible to add my own properties to the character type?

If not, is it possible to make a new inherited type, which the game will handle?

Cheers.

Ashera

AGS supports "properties", which are read-only boolean, integer, or string values associated with game entities. You can create and change them using the "Properties" button in the editor. Properties are shared across all game entities (e.g., both rooms and characters can have the property "room label" even though it only applies to rooms).
In the script, these are accessed using entityName.GetProperty("bool/int property name") and entityName.GetPropertyText("string property name", stringToPutItIn).

strazer

Yes, these custom properties cannot be changed at runtime at the moment (tracker).

As for adding properties to built-in types (character, objects, etc.):
Quote from: Pumaman on Mon 28/02/2005 19:47:30
You cannot extend built-in types, no. This is a possibility for a future version.

Depending on what you want to do exactly, you could use a combination of structs and arrays:

Code: ags

// script header

struct MyCharacterStruct {
  bool Wet; // 0 (false) by default
  int Money; // 0 by default
};



Code: ags

// main script

MyCharacterStruct MyCharacter[AGS_MAX_CHARACTERS];


Code: ags

  // some script

  MyCharacter[cEgo.ID].Wet = true;
  MyCharacter[cEgo.ID].Money = 78;

Pod

Thanks for the replies, you two.
It's a pity they're non extendable! The struct 'workaround' may suit my needs. I was thinking that if I couldn't do it, I could do something similiar. Cheers guys.

SMF spam blocked by CleanTalk