View Single Post
07-03-22, 05:55 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
PLAYER_EQUIPMENT_CHANGED unequip / re-equip

Hi all

I need to check a newly equipped items quality, if it is grey save the current equipment set including the new item, if the item is not grey I want to unequip all and then use the current equipment set.
To do this I track the PLAYER_EQUIPMENT_CHANGED event.
Here is my chunk;

Lua Code:
  1. elseif event == "PLAYER_EQUIPMENT_CHANGED" then
  2.             local equipmentSlot = ...
  3.             IronManSelectionFrame:UnregisterEvent("PLAYER_EQUIPMENT_CHANGED") -- unregister so we don't spam the test
  4.             local isItemGrey, itemQuality = true, 99
  5.             itemQuality = GetInventoryItemQuality("player", equipmentSlot)
  6.             if itemQuality ~= 0 then -- if item is not grey
  7.                 isItemGrey = false
  8.                 removeAllEquipedItems()
  9.             end
  10.             if isItemGrey then
  11.                 for k, v in pairs(C_EquipmentSet.GetEquipmentSetIDs()) do
  12.                     C_EquipmentSet.DeleteEquipmentSet(v) -- delete all equipment sets
  13.                 end
  14.                 C_EquipmentSet.CreateEquipmentSet("TESTING", 1035053) -- create new equipment set
  15.             end
  16.             C_EquipmentSet.UseEquipmentSet(0) -- use current equipment set
  17.             print("PLAYER_EQUIPMENT_CHANGED Event Fired", equipmentSlot, isItemGrey, itemQuality) -- debug --
  18.             IronManSelectionFrame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED") -- re-register after test function

I unregister the PLAYER_EQUIPMENT_CHANGED at the start of the function so it doesn’t spam as the unequip re-equip will fire for each item.
He is my result:


Even though I unregister it still spams yet I cannot understand why, so I am looking for some help in understanding why it won't work, and why the equipment set doesn't update.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote