Item slot == null?

Cheapshampoo

New member
Thanks for taking time to look at my question. I'm wondering a good way to check if nothing is in a slot. I'm not sure how to write it. I have this.

var HelmItemCollection = Helm_Inventory.GetItemCollection(0) as ItemSlotCollection;
var EquippedHelm = HelmItemCollection.GetItemInfoAtSlot(0);
if (EquippedHelm != null)
print(EquippedHelm);
{
Do Stuff
}


When I run that with nothing in slot I get this from print.

0 Item is NULL || ItemCollection(Main) Helm Inventory Collection || ItemStack(-1360789048)[ 0 Item is NULL in ItemCollection(Main) Helm Inventory Collection]

How can I call that return null?
 
GetItemInfoAtSlot retuns an ItemInfo.

An ItemInfo is a struct not a class. that means it cannot be null.
In your case EquippedHelm is an ItemInfo.

If you want to check that there is no item there you have two choices.

Code:
if(EquippedHelm == ItemInfo.None){
    //Empty
}

//OR

if(EquippedHelm.Amount == 0){
    //Empty
}

This isn't exactly the same but for your purpose either should be fine.

I'd recommend renaming "EquippedHelm" to "EquippedHelmItemInfo" so you are explicit about naming things in a way that make sense for their type
 
Top