Integration with Opsive UIS allows only to add items to main collection

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
christianwiele
Posts: 29
Joined: Sat Mar 27, 2021 7:34 am

Integration with Opsive UIS allows only to add items to main collection

Post by christianwiele »

Hi,

the UIS Lua interface allows to specify an item collection to add a new item to:

Code: Select all

        public virtual void uisAddItem(string itemName, double amount, string inventoryName, string itemCollectionName)
        {
            var item = GetItem(itemName);
            if (item == null) return;
            var inventory = GetInventory(inventoryName);
            if (inventory == null) return;
            var itemCollection = GetItemCollection(inventory, itemCollectionName);
            var itemInfo = new ItemInfo(new ItemAmount(item, (int)amount), itemCollection);
            inventory.AddItem(itemInfo);
        }
but the AddItem method on the inventory will always add the item to the main item collection because the stackTarget is null:

Code: Select all

        public virtual ItemInfo AddItem(ItemInfo itemInfo, ItemStack stackTarget = null)
        {
            if (stackTarget != null && stackTarget.ItemCollection != null && ReferenceEquals(stackTarget.Inventory, this)) {
                return stackTarget.ItemCollection.AddItem(itemInfo, stackTarget);
            }

            return MainItemCollection.AddItem(itemInfo);
        }
This unfortunate because I would like to add items to other collections.

Thanks, Christian
User avatar
Tony Li
Posts: 21984
Joined: Thu Jul 18, 2013 1:27 pm

Re: Integration with Opsive UIS allows only to add items to main collection

Post by Tony Li »

Hi Christian,

I'll update the UIS integration today, send you a patch, and send the updated package to Opsive for their integrations page.
christianwiele
Posts: 29
Joined: Sat Mar 27, 2021 7:34 am

Re: Integration with Opsive UIS allows only to add items to main collection

Post by christianwiele »

Thanks a lot, appreciate the quick response.
User avatar
Tony Li
Posts: 21984
Joined: Thu Jul 18, 2013 1:27 pm

Re: Integration with Opsive UIS allows only to add items to main collection

Post by Tony Li »

Hi,

Please give this a test to make sure it meets your needs:

DS_UISLuaPatch_2021-09-18.unitypackage
christianwiele
Posts: 29
Joined: Sat Mar 27, 2021 7:34 am

Re: Integration with Opsive UIS allows only to add items to main collection

Post by christianwiele »

Thanks a lot, I only tested my use case, but this works fine now.
User avatar
Tony Li
Posts: 21984
Joined: Thu Jul 18, 2013 1:27 pm

Re: Integration with Opsive UIS allows only to add items to main collection

Post by Tony Li »

Great! My test cases all pass, too, so I'll ship this off to Opsive.
Post Reply