Thread Tools Display Modes
Prev Previous Post   Next Post Next
03/10/15, 05:52 AM   #19
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
I got a bit lost. Could someone please explain the whole guard interaction to me? They don't break your skull like they say they would, if you broke the law?

So the problem is with add-ons doing stuff on inventory slot/full update? Some ideas:

* Use SHARED_INVENTORY
Lua Code:
  1. -- these are called upon SINGLE slot and FULL update
  2. ("SlotRemoved", bagId, slotIndex, existingSlotData)
  3. ("SlotAdded", bagId, slotIndex, slotData)
  4. ("SlotUpdated", bagId, slotIndex, slotData)
  5.  
  6. -- this is called upon SINGLE slot update
  7. ("SingleSlotInventoryUpdate", bagId, slotIndex)
  8. -- the callback doesn't include slotData, you can get it like this:
  9. local slotData = SHARED_INVENTORY:GenerateSingleSlotData(bagId, slotIndex)
  10.  
  11. -- this is called upon FULL update with BAG_BACKPACK and BAG_WORN,
  12. -- and also upon guild bank events with BAG_GUILDBANK (twice?! must test)
  13. ("FullInventoryUpdate", bagId)
  14. -- you can scan the whole bag like this:
  15. local bagCache = SHARED_INVENTORY:GenerateFullSlotData(nil, bagId)
  16. for slotIndex, slotData in pairs(bagCache) do ...

* Add-ons tinkering with items, e.g. junkers, should IMO never, ever, do that in response to full update. This includes SHARED_INVENTORY's SlotAdded/Updated callbacks. If you want to implement forced re-scan feature, add a button, or a keybind, or a slash command.

* If you need to do something upon full backpack update, maybe you could delay that until out of certain scenes:
Lua Code:
  1. local blacklist = { interact = true }
  2. local needUpdate = false
  3.  
  4. local function doUpdate()
  5.   needUpdate = false
  6.   ...
  7. end
  8.  
  9. local function canUpdate()
  10.   local scene = SCENE_MANAGER:GetCurrentScene()
  11.   return not scene or not blacklist[scene:GetName()]
  12. end
  13.  
  14. EVENT_MANAGER:RegisterForEvent("junker", EVENT_INVENTORY_FULL_UPDATE,
  15. function()
  16.   if canUpdate() then
  17.     doUpdate()
  18.   else
  19.     needUpdate = true
  20.   end
  21. end)
  22.  
  23. SCENE_MANAGER:RegisterCallback("SceneStateChanged",
  24. function(scene, oldState, newState)
  25.   if needUpdate and canUpdate() then
  26.     doUpdate()
  27.   end
  28. end)
  Reply With Quote
 

ESOUI » AddOns » AddOn Help/Support » 3 hours to track down the CTD


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