Thread Tools Display Modes
02/09/17, 04:31 AM   #1
ArtOfShred
 
ArtOfShred's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 103
[outdated] itemlink return on GetLastCraftingResultItemInfo (resultIndex)

Currently I've managed to create Chat Announcements for item gain/loss except through that of crafting, banking or destroying items in LUI. These are all complete with working item links, and in relevant cases player links as well.

I've moved on to attempting to add something for crafting and found this function:

Code:
GetLastCraftingResultItemInfo(number resultIndex)
    Returns: string name, textureName icon, number stack, number sellPrice, boolean meetsUsageRequirement, number equipType, number ItemType itemType, number itemStyle, number quality, number ItemUISoundCategory soundCategory, number itemInstanceId
It's extremely useful because I can interate through resultIndex numbers to find all the items that were produced as a result of the last construct/deconstruct, but there's no way I'm aware of to generate an itemlink with any of this information provided. The best I could do is use zo_stringformat and put some brackets and colorize items based off their quality to make them look like an item tooltip at least. There's also no way to differentiate between constructing and deconstructing, but that's not as much of an issue since we can fudge around that by checking the itemType.

I also tried to look into adding the same functionality for Banking and couldn't find anything at all I thought would work, doesn't seem to be any event we can use for adding or removing items from the bank. Any chance it would be possible to add these events for bank item withdraw/deposits and expand the Guild Bank ones?

Thanks!

EDIT: Just realized it doesn't seem like there's a way to get an item you deconstructed either, just the resulting items. Might be something nice to have as well.
 
02/11/17, 08:13 AM   #2
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 408
I'd actually like to second this. However, I think the slotId of the newly created item would be more helpful. You can still get the itemlink using that, and you also know exactly what was crafted. (Say you have 10 of one type of glyph in your bag)

For something being deconstructed, an item link should probably be fine.
 
02/11/17, 10:17 AM   #3
Klingo
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 16
Originally Posted by ArtOfShred View Post
Code:
GetLastCraftingResultItemInfo(number resultIndex)
    Returns: string name, textureName icon, number stack, number sellPrice, boolean meetsUsageRequirement, number equipType, number ItemType itemType, number itemStyle, number quality, number ItemUISoundCategory soundCategory, number itemInstanceId
It's extremely useful because I can interate through resultIndex numbers to find all the items that were produced as a result of the last construct/deconstruct, but there's no way I'm aware of to generate an itemlink with any of this information provided.
If I understand you correct, you want the ItemLink of the most recent crafted item?
For that I also don't see an easy/simple way to do, but the function you mentioned returns you the ItemType as well as the name of it. So theoretically you could loop through all items in the backpack and check if the ItemType and name do match. If they do, you can get the itemLink with the below function since you know the bagId (i.e. the backpack) as well as the slotIndex (from the loop). Alternative, you might also be able to use "GetItemInstanceId(number bagId, number slotIndex) Returns: number:nilable id" and then companre the id with the one from your method.
Code:
GetItemLink(number bagId, number slotIndex, number LinkStyle linkStyle)
    Returns: string link
It's not the nicest solution, but I can't think of a better alternative, off the top of my head.

Originally Posted by ArtOfShred View Post
I also tried to look into adding the same functionality for Banking and couldn't find anything at all I thought would work, doesn't seem to be any event we can use for adding or removing items from the bank. Any chance it would be possible to add these events for bank item withdraw/deposits and expand the Guild Bank ones?
Just an idea: with the following three events, you know when the player has the bank open and when any inventory slot was updated. Witht his you could make some deductions on whether an item was deposited or withdrawn from the bank (based on the "stackCountChange"). The only problem I see here is with splitting or merging item stacks, as these would also trigger the event. Maybe you could use "GetNumBagFreeSlots(number Bag bagId) Returns: number freeSlots" to also also check whether the number of free slots in the bank changed.
Code:
EVENT_OPEN_BANK (number eventCode) 
EVENT_CLOSE_BANK (number eventCode)
EVENT_INVENTORY_SINGLE_SLOT_UPDATE (integer eventCode,number bagId, number slotId, boolean isNewItem, number itemSoundCategory, number inventoryUpdateReason, number stackCountChange)
 
02/12/17, 08:15 AM   #4
ArtOfShred
 
ArtOfShred's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 103
Originally Posted by Klingo View Post
snip
Hey thanks for all the suggestions!

I was actually looking into indexing the inventory earlier today to do something like this, and I got it figured out. And it works for crafting/laundering too.

Basically have a function for open/closing of Bank/Guild Bank/Fence/Crafting Station and it registers a different event for EVENT_INVENTORY_SINGLE_SLOT_UPDATE and uses a function to index the contents of my bag and bank where relevant. Then any changes to those slots has context sensitive messages sent to a print function that gathers further info on the item based off the itemlink.

I haven't finalized the implementation yet, but now that I have this enabled, I'm pretty sure I have 100% coverage for inventory change events with LUI now (Except transfer from craft bag to normal bag, but there's no loss present there so not necessary).

I even went as far as adding a function for EVENT_INVENTORY_ITEM_DESTROYED that sets a variable to true, and if the next EVENT_INVENTORY_SINGLE_SLOT_UPDATE reads that variable, it will print the item destroyed.

BTW, this is the function for indexing the inventory, can just run this on initialization and also call it before opening a bank, etc:

The 3 forms of information extracted here are all we need, any other information can be pulled from the itemlink if sent to another function.

Code:
function CA.IndexInventory()

-- Bag 1 = player bag, bag 2 = bank, bag 3 = guild bank, bag 5 = crafting bag (too big to index)

local bagsize = GetBagSize(1)

    for i = 1,bagsize do
        local icon, stack = GetItemInfo(1, i)
        local bagitemlink = GetItemLink(1, i, LINK_STYLE_DEFAULT)
        if bagitemlink ~= "" then
            g_InventoryStacks[i] = { icon=icon, stack=stack, itemlink=bagitemlink}
        end
    end
    
end

Last edited by ArtOfShred : 02/12/17 at 08:20 AM.
 
02/14/17, 11:05 AM   #5
AssemblerManiac
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 51
I'd like to +1 this one too.

When deconstructing an item, we do get an EVENT_INVENTORY_SINGLE_SLOT_UPDATE event, but the ItemLink is empty when it was the last item from the stack.

How about having the slot update event include the item link all the time? When qty=0, you'll know it's the last one. IIfA needs this so I can more easily zero out qtys associated with an itemlink without having to resort to saving/searching the bag/slot just to find out what the itemlink previously was.


-----------
Shred - you really should be using the bag identifiers (BAG_BACKPACK, BAG_BANK, BAG_GUILDBANK, etc) instead of hardcoded numbers.
 

ESOUI » Developer Discussions » Wish List » [outdated] itemlink return on GetLastCraftingResultItemInfo (resultIndex)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off