How to Return Item From ItemType

Thanks for the reply Justin!

I'm having some trouble using the SlotIDs for GetItem(int slotID, ItemType itemType), or possibly just in using the GetItem() function. Any pointers on using that?

For example:

Code:
public CurrentInventoryItem GetItemTypeInfo (ItemType itemType, Item item = null){
    if(!item)
    {
        for(int i = 0; i < m_Inventory.SlotCount; i++)
        {
            Debug.Log ("i: " + i);
            item = m_InventoryBase.GetItem(i, itemType);
        }
    }

    if (item)
         Debug.Log ("Got an Item!!!!!!!!!!!!!!!!!!!!!!!!!");
    else if (!item)
         Debug.Log ("NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!");
    
    CurrentInventoryItem inventoryItem = new CurrentInventoryItem(itemType.name, itemType.ID, item, itemType);

    return inventoryItem;
}

... and I'm calling it like this:

Code:
m_CurrentInventoryList_Weapons.Add (GetItemTypeInfo (itemType));

...but it doesn't seem to return the ItemType's Item. I'm hoping to pass the Item (for ItemTypes that have it) to a list for my inventory system, but as far as I know, I need the Item so I can get the ItemActions to check for things like if the weapon is a ShootableWeapon (itemAction is ShootableWeapon):

1540177055957.png
 
Last edited:
In that script you are looping through updating item variable every iteration so it will always assign the item in the last slot, which is probably going to be null.
 
Top