Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Sledgy on Mon 20/01/2014 19:14:53

Title: How to get description of inventory item?
Post by: Sledgy on Mon 20/01/2014 19:14:53
GetTextProperty and GetInvPropertyText don't works!

AGS says, property 'description' doesn't exist. WTF?
Title: Re: How to get description of inventory item?
Post by: Ghost on Mon 20/01/2014 19:41:20
If you want to read a text property, you need to create it first, and use the name you give it when you read it.

For example:
InventoryItem *i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
String str = i.GetProperty("propName");

WILL work and return the text stored in "propName", but only if you first create such a property.

But you can just use the Name of an inventory item. That's actually easier. 99% of all people do that and never need to go WTF at all.
Title: Re: How to get description of inventory item?
Post by: Khris on Mon 20/01/2014 20:36:36
Just to be clear: GetProperty and GetTextProperty are used to read custom properties; the built-in properties are accessed directly (using dot notation).
Granted, the current setup is a bit confusing, because the "Name" property in the editor is the script object's variable name (like "iBox"), while the "Description" property (like "box full of WTF") is actually accessed by iBox.Name in scripts.
The example in the manual makes it even worse, because it actually says inventory[2].GetTextProperty("Description").
Still, chill.
Title: Re: How to get description of inventory item?
Post by: Sledgy on Tue 21/01/2014 20:03:19
Khris, exactly!

"Name" and "Description" must be different things. And I used hint from manual and got error

Thanks