View Single Post
01/06/24, 12:20 AM   #5
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 409
Originally Posted by vsrs_au View Post
Thanks for the reply, much appreciated.
Originally Posted by vsrs_au View Post

However, this doesn't explain how I have the same item showing in both bags, e.g. in the bank UI in game, the item "Revelry Pie" shows with a stack of 60, then in my SavedVariables file, I have the same item showing in BAG_BANK and in BAG_SUBSCRIBER_BANK, and both have a count of 60, i.e. there's only 1 stack of 60 and it shows in both bags. It looks like GetItemLinkStacks() is returning the same value for that item for both bags, which doesn't make sense to me.

If it's any help, my DumpItem function is as follows:
Code:
function InventoryDump.DumpItem(bagType, count, itemName)
    if bagType == BAG_BANK then
        InventoryDump.savedVariablesAccountWide.Bank[itemName] = count
    elseif bagType == BAG_SUBSCRIBER_BANK then
        InventoryDump.savedVariablesAccountWide.ESOBank[itemName] = count
    elseif bagType == BAG_VIRTUAL then
        InventoryDump.savedVariablesAccountWide.CraftBag[itemName] = count
    elseif bagType == BAG_BACKPACK then
        InventoryDump.savedVariablesPerChar.Backpack[itemName] = count
    end
end
I then have the following in SavedVariables file:
Code:
InventoryAccountWide =
{
    ["EU Megaserver"] = 
    {
        ["@vsrs_au"] = 
        {
            ["$AccountWide"] = 
            {
                ["version"] = 1,
                ["ESOBank"] = 
                {
...
                    ["Revelry Pie"] = 60,
...
                }
                ["Bank"] = 
                {
...
                    ["Revelry Pie"] = 60,
...
                }


The issue here is down to how you are 'counting' the items.
Consider this: If you have two full stacks of say, lockpicks, what would be listed in the saved vars? Or even just two partial stacks of them? Note that when you look at the number of items indicator in a tooltip, it does not differentiate between bank and sub bank.
You could either count them better, or change the table structure so you don't get duplicate entries (or make a cache but that's overkill)
Changing the sv to not differentiate between the bank and sub bank would mean that it would just re-save the same value in the spot for the key, so you'd have one revelry pie amount in the combined bank.
Counting them better would keep the separate entries, so you'd have two entries that add up to the combined total.
However, whichever one you choose, you probably want to re-consider using the item name to save the items. For example, if you have a potion of health, say tripots for tanking and single effect potions for writs and looted potions, then you'd only keep the last item stack size. For example, if you encounter tripots first, you'll save essence of health = 100, then you get to single effect potion and save essence of health = 45 over the existing tripot value of 100. https://wiki.esoui.com/GetSlotStackSize
As far as I'm aware, there isn't really a great way of programmatically designing the table keys to work around this problem. Item IDs are great for many items, but some items share the same item ID despite being different (for example, the aforementioned potions)
Item Link is possible, but many same items do not share the same item link. For example, a tempering alloy in a bank would usually have a different item ID than a tempering alloy in a craft bag.
Unique Item ID I'm pretty sure also does not really work too well, also being too discriminatory for most purposes, but you could experiment with it to see if it works for you.

The best way really is to go a more decision based way. Craft materials use item ID, potions use the level and effect IDs, gear uses the initial portion of the item link or unique ID, etc. Experiment with different item links and keys to find out what works best for you.
  Reply With Quote