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:
-- these are called upon SINGLE slot and FULL update
("SlotRemoved", bagId, slotIndex, existingSlotData)
("SlotAdded", bagId, slotIndex, slotData)
("SlotUpdated", bagId, slotIndex, slotData)
-- this is called upon SINGLE slot update
("SingleSlotInventoryUpdate", bagId, slotIndex)
-- the callback doesn't include slotData, you can get it like this:
local slotData = SHARED_INVENTORY:GenerateSingleSlotData(bagId, slotIndex)
-- this is called upon FULL update with BAG_BACKPACK and BAG_WORN,
-- and also upon guild bank events with BAG_GUILDBANK (twice?! must test)
("FullInventoryUpdate", bagId)
-- you can scan the whole bag like this:
local bagCache = SHARED_INVENTORY:GenerateFullSlotData(nil, bagId)
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:
local blacklist = { interact = true }
local needUpdate = false
local function doUpdate()
needUpdate = false
...
end
local function canUpdate()
local scene = SCENE_MANAGER:GetCurrentScene()
return not scene or not blacklist[scene:GetName()]
end
EVENT_MANAGER:RegisterForEvent("junker", EVENT_INVENTORY_FULL_UPDATE,
function()
if canUpdate() then
doUpdate()
else
needUpdate = true
end
end)
SCENE_MANAGER:RegisterCallback("SceneStateChanged",
function(scene, oldState, newState)
if needUpdate and canUpdate() then
doUpdate()
end
end)