Accessing the Item-sets at run-time through code.

River

New member
Hi Support,

I'm happy enough with the UCControler . However I decided not to use the UInventory system but use my own.

I wish to know at runtime which item is in each slot (left and right hand, slot [0] and slot [1]) for all the item sets in the item-set collection on the player. Is there an optimal way to get this information?

So I would use these handles to then be able to set which item-set is active based on changes in my own UI. (E.g. adding a pistol to the characters hand in my inv-UI would find the corresponding item-set number for 'the pistol' and then 'equip-unequip' that item-set during run-time). Run-time access is required since pick-ups/drops might change the order in the item-set.

This I know can be done - I'm hoping you have some helpful tips to achieved this (useful getters?), or even better perhaps have some example code to share. Other general approaches which might be more wise are welcome.

Many thanks,

ps. do items and objects have string ref IDs? E.g. 'My_Assualt_Rifle' is nice and all, but how can this string be used to search / compare items? In other words how would I know if e.g. 'My_Assualt_Rifle' is present in the player inventory during runtime?
 
Last edited:
I'd recommend looking through ItemSetManagerBase. Lists of ItemSets are organised by item category (e.g. Items, Left/Right Hand Secondary Grenades) into CategoryItemSet. Each CategoryItemSet has ItemSetList, which is a list of type ItemSet. And each ItemSet has Slots, which is an array of type ItemDefinitionBase (of length 2 if you're using the basic 2 slots). So, you can get a reference to the character's ItemSetManager, get the relevant CategoryItemSet, then iterate through its ItemSetList.

ItemTypes have a unique (within its collection) id. Once you've got an ItemType (ItemType inherits from ItemDefinitionBase, s if you've got an ItemDefinition, you can cast it to ItemType), you can access the ID property, which is a uint. You can also use ToString() to get the name of the ItemType.
 
Many thanks Andrew,

I started on this yesterday myself apparently in the correct direction: getting the ItemSetManagerBase and the list of itemSets. I thought I was at the slot-level already but indeed got out only the item, Left/Right Hand secondary grenades. I understand I need to go deeper to the ItemSetLists and their slots.

Indeed although not planning to use I did actually purchased the Ultimate Inventory. Is there a ready made scripty to do the above, which I can dig-out e.g. from the UI scripts? - time is critical and would be a shame to do double work.

Cheers,
 
Inventories can get complicated pretty quickly so especially if you already have our inventory system then I recommend using that. There are a lot of use cases that it covers and it is really extensible. Feel free to post in the inventory forum and Santiago will be able to help out with any specifics.
 
Top