ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Items leaving inventory are not identified (https://www.esoui.com/forums/showthread.php?t=4547)

@AlphaLemming 04/07/15 03:01 AM

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?

Baertram 04/07/15 04:12 AM

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.

@AlphaLemming 04/07/15 04:53 AM

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?

Garkin 04/07/15 05:33 AM

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

@AlphaLemming 04/07/15 05:48 AM

Very nice Garkin, this will save me 400 lines of code and loops in CraftStore and AlphaLoot. Hope this works.
Thank you & danke Baertram.

@AlphaLemming 04/08/15 03:02 PM

Garkin, is there a way to get the itemlink from the oldSlot-variable?

Garkin 04/08/15 03:19 PM

Quote:

Originally Posted by @AlphaLemming (Post 20306)
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)

@AlphaLemming 04/08/15 03:37 PM

Thats exactly what i need. Thank you again.


All times are GMT -6. The time now is 07:25 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI