I want to unequip all items, create a naked equipment set, then register the PLAYER_EQUIPMENT_CHANGED event, and then use the naked set to be applied when I try to equip any items.
Here is the unequip function.
Lua Code:
local InventorySlots = {
INVSLOT_AMMO,
INVSLOT_HEAD,
INVSLOT_NECK,
INVSLOT_SHOULDER,
INVSLOT_BODY,
INVSLOT_CHEST,
INVSLOT_WAIST,
INVSLOT_LEGS,
INVSLOT_FEET,
INVSLOT_WRIST,
INVSLOT_HAND,
INVSLOT_FINGER1,
INVSLOT_FINGER2,
INVSLOT_TRINKET1,
INVSLOT_TRINKET2,
INVSLOT_BACK,
-- INVSLOT_MAINHAND,
-- INVSLOT_OFFHAND,
-- INVSLOT_RANGED,
INVSLOT_TABARD
}
local function UnequipAll()
if #InventorySlots <= 0 then
return
end
local slotindex = 1
ClearCursor()
for bag = NUM_TOTAL_EQUIPPED_BAG_SLOTS, 0, -1 do
local free, type = C_Container.GetContainerNumFreeSlots(bag)
free = (type == 0 and free or 0)
for _ = 1, free do
local invslot = InventorySlots[slotindex]
while not GetInventoryItemID("player", invslot) do
if slotindex < #InventorySlots then
slotindex = slotindex + 1
else
return
end
invslot = InventorySlots[slotindex]
end
PickupInventoryItem(invslot);
(bag == 0 and PutItemInBackpack or PutItemInBag)(C_Container.ContainerIDToInventoryID(bag))
if slotindex < #InventorySlots then
slotindex = slotindex + 1
else
return
end
end
end
end
I then have a button the the player clicks to run the unequid function.
Lua Code:
"OnClick",
function()
if not IronManCharacterVariables.isAttemptingIronMan then
UnequipAll()
IronManCharacterVariables.isAttemptingIronMan = true
end
)
C_EquipmentSet.CreateEquipmentSet("IronMan", 1035053)("PLAYER_EQUIPMENT_CHANGED")
This is where I track the event.
Lua Code:
elseif event == "PLAYER_EQUIPMENT_CHANGED" then
if not IronManCharacterVariables.isAttemptingIronMan then
C_EquipmentSet.UseEquipmentSet(0)
end
The issue I have is that it does unequip all but the event triggers even though it has not been registered until after the unequip function, and the naked set never saves.
I have uploaded my full code on
Pastebin.
I have been banging away at this for a couple of weeks without success, so any help would be great.