Thread Tools Display Modes
04/07/15, 03:01 AM   #1
@AlphaLemming
 
@AlphaLemming's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 122
Items leaving inventory are not identified

If a item is destroyed,refined,moved to other bag, the events deliver no response about the bagId and slotId.
Only if moved in a valid bag there is a second response with the new bagId/slotId but not the old.

Is there a way to identify the item which was destroyed/moved?

Up to now i made a snapshot of the whole inventory at login with all valid items and compare it with new inventory after a event was fired. But this is not 100% secure...
Any ideas?
  Reply With Quote
04/07/15, 04:12 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,971
I'm not sure if theis event is called all the time if an item gets destroyed, researched, refined, deconstructed, but maybe it helps?

--Will normally be called if item get's picked up by drag&drop for example, but should be used too if an item gets locked by some function
EVENT_INVENTORY_SLOT_LOCKED

Doesn't EVENT_INVENTORY_SINGLE_SLOT_UPDATE work for you, or is it only called AFTER the item is destroyed and you don#t have the information of bagId and slotIndex anymore then?

Otherwise you might have to hook all the possible functions, or events, where items can be "destroyed", like EVENT_CRAFT_START for example or EVENT_MOUSE_REQUEST_DESTROY_ITEM etc.
But some of them do not provide you the bagId and slotIndex of the current item.
  Reply With Quote
04/07/15, 04:53 AM   #3
@AlphaLemming
 
@AlphaLemming's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 122
EVENT_INVENTORY_SINGLE_SLOT_UPDATE returns only a bagId/slotId if there was a valid target bag:

BACKPACK > BANK = 2 returns nil/nil and targetBag/targetSlot
BACKPACK > NIRVANA = nil/nil

EVENT_MOUSE_REQUEST_DESTROY_ITEM does not return bag or slot.
EVENT_INVENTORY_SLOT_LOCKED i don't know, can try it ... but when it is called?
  Reply With Quote
04/07/15, 05:33 AM   #4
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Shared inventory fires callback when slot (item) is removed:

Lua Code:
  1. local function OnSlotRemoved(bagId, slotIndex, oldSlotData)
  2.     --do some stuff here
  3. end
  4.  
  5. SHARED_INVENTORY:RegisterCallback("SlotRemoved", OnSlotRemoved)


http://esodata.uesp.net/current/src/...y.lua.html#254
  Reply With Quote
04/07/15, 05:48 AM   #5
@AlphaLemming
 
@AlphaLemming's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 122
Very nice Garkin, this will save me 400 lines of code and loops in CraftStore and AlphaLoot. Hope this works.
Thank you & danke Baertram.
  Reply With Quote
04/08/15, 03:02 PM   #6
@AlphaLemming
 
@AlphaLemming's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 122
Garkin, is there a way to get the itemlink from the oldSlot-variable?
  Reply With Quote
04/08/15, 03:19 PM   #7
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by @AlphaLemming View Post
Garkin, is there a way to get the itemlink from the oldSlot-variable?
Table oldSlotData doesn't contain itemlink and if item doesn't exist, you can't get its itemlink.

However, if you need an itemlink, lets use workaround. I did something like that in my changes to Lost Treasure addon. Register for callback "SlotAdded" and then add itemlink to the slot table (in LT I'm adding itemId).

Lua Code:
  1. local function OnSlotAdded(bagId, slotIndex, slotData)
  2.     slotData.itemLink = GetItemLink(bagId, slotIndex)
  3. end
  4.  
  5. local function OnSlotRemoved(bagId, slotIndex, oldSlotData)
  6.     d(zo_strformat("Item <<t:1>> was removed from the inventory.", oldSlotData.itemLink)
  7. end
  8.  
  9. SHARED_INVENTORY:RegisterCallback("SlotAdded", OnSlotAdded)
  10. SHARED_INVENTORY:RegisterCallback("SlotRemoved", OnSlotRemoved)
  Reply With Quote
04/08/15, 03:37 PM   #8
@AlphaLemming
 
@AlphaLemming's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 122
Thats exactly what i need. Thank you again.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Items leaving inventory are not identified


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