How to get description of inventory item?

Started by Sledgy, Mon 20/01/2014 19:14:53

Previous topic - Next topic

Sledgy

GetTextProperty and GetInvPropertyText don't works!

AGS says, property 'description' doesn't exist. WTF?

Ghost

#1
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.

Khris

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.

Sledgy

Khris, exactly!

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

Thanks

SMF spam blocked by CleanTalk