View Single Post
11/03/15, 01:15 PM   #12
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
All three methods will work: EVENT_INVENTORY_SINGLE_SLOT_UPDATE, OnSharedSingleSlotUpdate, & OnWornSlotUpdate.

I'm not sure if you tested it recently or if your comments about it not working properly were based on tests you did in the past, because I can tell you that in the past OnSharedSingleSlotUpdate use to NOT fire for unequipping items and OnWornSlotUpdate use to NOT fire for equipping items. But they changed the way it works and now both fire whether your equipping or unequipping via any method: double-click, drag & drop, or using the context menu.

You are correct that OnWornSlotUpdate does fire twice if you drag an item out of an equipment slot & drop it into the inventory slot. It fires once for the drag out of the equipment slot & once for the drop into the inventory slot. Any other method (including dragging items into the slot) only fires it once.

However, EVENT_INVENTORY_SINGLE_SLOT_UPDATE, OnWornSlotUpdate also fire for durability Updates. For EVENT_INVENTORY_SINGLE_SLOT_UPDATE you can't use the updateReason to filter it out because, for example, when you repair an item (and at other times) it fires both reasons INVENTORY_UPDATE_REASON_DURABILITY_CHANGE & INVENTORY_UPDATE_REASON_DEFAULT, but this one does not fire for durability updates, only when the item in the slot changes.
Lua Code:
  1. SHARED_INVENTORY:RegisterCallback("SingleSlotInventoryUpdate", OnSharedSingleSlotUpdate)

Last edited by circonian : 11/03/15 at 01:25 PM.
  Reply With Quote