Page 1 of 1

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

Posted: Sat Sep 18, 2021 3:40 am
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

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

Posted: Sat Sep 18, 2021 8:34 am
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.

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

Posted: Sat Sep 18, 2021 10:32 am
by christianwiele
Thanks a lot, appreciate the quick response.

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

Posted: Sat Sep 18, 2021 12:09 pm
by Tony Li
Hi,

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

DS_UISLuaPatch_2021-09-18.unitypackage

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

Posted: Sat Sep 18, 2021 1:36 pm
by christianwiele
Thanks a lot, I only tested my use case, but this works fine now.

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

Posted: Sat Sep 18, 2021 2:21 pm
by Tony Li
Great! My test cases all pass, too, so I'll ship this off to Opsive.