Hi,
I have item's GUID and need to get the ItemShortcut in player's inventory.
var itemShortcut = ORK.Game.ActiveGroup.Leader.Inventory.Get<ItemShortcut>(itemORKGUID);
The code return null. What is the correct way to get the items in inventory? Or how to get the quantity of the item in inventory?
  • I get the item quantity by:
    var orkItem = ORK.Items.Get(itemORKGUID)
    int count = ORK.Game.ActiveGroup.Leader.Inventory.GetCount(new ItemShortcut(orkItem, 0));

    The quantity parameter of the ItemShortcut constructor confuse me. It creates an ItemShortcut instance with quantity=2 and I thought that this will affect the GetCount() result.
  • The GUID used by the inventory functions is not the same as the item's settings GUID. It's a reference for the item's instance in the inventory.
    Also, using the specific Item sub-inventory will have more functionality available.

    You need to use the item's settings to get items of that kind from the inventory, e.g. by using the guid to get the settings:
    ItemShortcut item = combatant.Inventory.Items.Get(ORK.Items.Get(guid));

    The GetCount function will find items of the same kind and return the total quantity of all those items. The quantity of the passed on ItemShortcut instance is not counted in that.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.