New issue... I've dialed in the randomize buttons so that I can do any individual button, but there's a catch. The individual buttons (shoulder, helm, etc) work totally perfect... ***IF*** that slot is currently selected as the active mog slot in the wardrobe interface. If it is not, or if I try to do multiple pieces at once (using the transmog all slots button) then each one may or may not function. I can't quite figure out what's causing it, but my guess is that it has to do with the for loop at the bottom of my code that checks if an matching sourceID is known and then uses that one if it is. I get the feeling that section is causing the issue, but can't figure out how/why. Any great advice?
Code:
-- BUTTON CODE
local button = CreateFrame("Button", "ClownSuitButton", WardrobeTransmogFrame.Inset,"UIPanelButtonTemplate") -- Randomize All Button
button:SetWidth(120)
button:SetHeight(25)
button:SetPoint("BOTTOMLEFT",450,0)
button:RegisterForClicks("AnyUp")
button:SetText("Clown Suit")
button:SetScript("OnClick", function() equipClownSuit() end)
button:SetFrameLevel(button:GetFrameLevel() + 1)
local button = CreateFrame("Button", "ClearClownSuitButton", WardrobeTransmogFrame.Inset,"UIPanelButtonTemplate") -- Clear All Button
button:SetWidth(120)
button:SetHeight(25)
button:SetPoint("BOTTOMLEFT",595,0)
button:RegisterForClicks("AnyUp")
button:SetText("Clear Pending")
button:SetScript("OnClick", function() C_Transmog.ClearPending() end)
button:SetFrameLevel(button:GetFrameLevel() + 1)
local button = CreateFrame("Button", "HelmButton", WardrobeTransmogFrame.Inset,"UIPanelButtonTemplate") -- Helm Button
button:SetWidth(25)
button:SetHeight(25)
button:SetPoint("BOTTOMLEFT",40,415)
button:RegisterForClicks("AnyUp")
button:SetText("+")
button:SetScript("OnClick", function() setSlotToClown(1,1) end)
button:SetFrameLevel(button:GetFrameLevel() + 1)
local button = CreateFrame("Button", "ShoulderButton", WardrobeTransmogFrame.Inset,"UIPanelButtonTemplate") -- Shoulder Button
button:SetWidth(25)
button:SetHeight(25)
button:SetPoint("BOTTOMLEFT",40,365)
button:RegisterForClicks("AnyUp")
button:SetText("+")
button:SetScript("OnClick", function() setSlotToClown(2,3) end)
button:SetFrameLevel(button:GetFrameLevel() + 1)
-- Build rest of buttons once shoulder code is working
-- RANDOMIZE CODE FOR EVERYTHING
function equipClownSuit()
setSlotToClown(1,1) -- Helm
setSlotToClown(2,3) -- Shoulder
setSlotToClown(4,5) -- Chest
setSlotToClown(9,6) -- Waist
setSlotToClown(10,7) -- Legs
setSlotToClown(11,8) -- Feet
setSlotToClown(7,9) -- Wrist
setSlotToClown(8,10) -- Hands
setSlotToClown(3,15) -- Back
setSlotToClown(6,19) -- Tabard
end
-- RANDOMIZE CODE FOR INDIVIDUAL SLOTS
function setSlotToClown(clownSlotID,mogSlotID)
C_TransmogCollection.ClearSearch() -- empties out the search trash to ensure we get a full list [working]
local knownMogCount = C_TransmogCollection.GetCategoryCollectedCount(clownSlotID) -- Gets a count of how many visuals are known [working]
local randomArmorToUse = random(0,knownMogCount) -- chooses a random number to grab a random armor [working]
local listOfArmors = C_TransmogCollection.GetCategoryAppearances(clownSlotID) -- Creates a table of appearences (.visualID)
local tempArmor = C_TransmogCollection.GetAppearanceSources(listOfArmors[randomArmorToUse].visualID) -- Gets the .sourceID table of the random armor
local visualIdToUse -- Searches through the appearances until a known one is found
for i, source in pairs(tempArmor) do
if source.isCollected then
visualIdToUse = i -- then sets the visualIdToUse to a known sourceID
break
end
end
C_Transmog.SetPending(mogSlotID, LE_TRANSMOG_TYPE_APPEARANCE, tempArmor[visualIdToUse].sourceID) -- Sets pending armor slot item to a working sourceID
end