Hi everyone, just wondering if anyone knows how to manually read the contents on an item property so that it can be saved in a variable and used to display its contents on label? That would also help in using the variables content to do checks (i.e.: if property contents is "Clean" then show clean Icon in the UI properties panel, if content is "dirty" then display dirty icon in the UI properties panel, etc).
My items will have from 1 to 3 properties (depending on the type), each property will have several states. I'll have a pane where an icon appears to let the player know of the properties of the item (and the current state, again, imagine a property state as dirty, clean, ruined, etc). If an Item doesn't have one of the 3 properties I want the icon for that property to either not appear or to get grayed out. I think I have an idea of how to do it, but I need to know how to get the content of the item's property. I'll try to take a look at the scripting guide but if anyone knows already and can tell me, that would be a lot of help.
Anyways, as usual, any advice would be greatly appreciated.
Comments
AC.InvItem myItem = AC.KickStarter.runtimeInventory.GetItem (3); // The item with ID = 3
InvVar myProperty = myItem.GetProperty (2); // The property with ID = 2;
string valueAsText = myProperty.GetValue ();
AC.KickStarter.runtimeInventory.selectedItem;
Also be aware that hoverItem (and so also myCurrentItem) will not always be filled, so you must also do a null check for it. If you don't want to return an empty string when this is the case, you can instead store the string whenever it's non-empty:
private string PropertyAsText;
string GetMyProperty (int propertyID)
{
//get selected item ID
AC.InvItem myCurrentItem = AC.KickStarter.runtimeInventory.hoverItem;
if (myCurrentItem != null)
{
//get the right property
InvVar myProperty = myCurrentItem.GetProperty (propertyID);
//get the property content into a string
PropertyAsText = myProperty.GetValue ();
}
//return the property value
return PropertyAsText;
}