Integration with Opsive UIS allows only to add items to main collection
Posted: Sat Sep 18, 2021 3:40 am
Hi,
the UIS Lua interface allows to specify an item collection to add a new item to:
but the AddItem method on the inventory will always add the item to the main item collection because the stackTarget is null:
This unfortunate because I would like to add items to other collections.
Thanks, Christian
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);
}
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);
}
Thanks, Christian