View Single Post
06-28-16, 01:14 AM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
This is probably more complicated than it needs to be.
Lua Code:
  1. local InventorySlots = {
  2.     ['INVTYPE_HEAD'] = 1,
  3.     ['INVTYPE_NECK'] = 2,
  4.     ['INVTYPE_SHOULDER'] = 3,
  5.     ['INVTYPE_BODY'] = 4,
  6.     ['INVTYPE_CHEST'] = 5,
  7.     ['INVTYPE_ROBE'] = 5,
  8.     ['INVTYPE_WAIST'] = 6,
  9.     ['INVTYPE_LEGS'] = 7,
  10.     ['INVTYPE_FEET'] = 8,
  11.     ['INVTYPE_WRIST'] = 9,
  12.     ['INVTYPE_HAND'] = 10,
  13.     ['INVTYPE_CLOAK'] = 15,
  14.     ['INVTYPE_WEAPON'] = 16,
  15.     ['INVTYPE_SHIELD'] = 17,
  16.     ['INVTYPE_2HWEAPON'] = 16,
  17.     ['INVTYPE_WEAPONMAINHAND'] = 16,
  18.     ['INVTYPE_RANGED'] = 16,
  19.     ['INVTYPE_RANGEDRIGHT'] = 16,
  20.     ['INVTYPE_WEAPONOFFHAND'] = 17,
  21.     ['INVTYPE_HOLDABLE'] = 17,
  22.     -- ['INVTYPE_TABARD'] = 19,
  23. }
  24.  
  25. local model = CreateFrame('DressUpModel')
  26. function GetItemAppearance(itemLink)
  27.     local itemID, _, _, slotName = GetItemInfoInstant(itemLink)
  28.     if itemLink == itemID then
  29.         itemLink = 'item:' .. itemID
  30.     end
  31.     local slot = InventorySlots[slotName]
  32.     if not slot or not IsDressableItem(itemLink) then return end
  33.     model:SetUnit('player')
  34.     model:Undress()
  35.     model:TryOn(itemLink, slot)
  36.     local sourceID = model:GetSlotTransmogSources(slot)
  37.     if sourceID then
  38.         local categoryID, appearanceID, canEnchant, texture, isCollected, itemLink = C_TransmogCollection.GetAppearanceSourceInfo(sourceID)
  39.         return appearanceID, isCollected, sourceID
  40.     end
  41. end
  42.  
  43. function PlayerHasAppearance(appearanceID)
  44.     local sources = C_TransmogCollection.GetAppearanceSources(appearanceID)
  45.     if sources then
  46.         for i, source in pairs(sources) do
  47.             if source.isCollected then
  48.                 return true
  49.             end
  50.         end
  51.     end
  52. end
  53.  
  54. function PlayerCanCollectAppearance(appearanceID)
  55.     local sources = C_TransmogCollection.GetAppearanceSources(appearanceID)
  56.     if sources then
  57.         for i, source in pairs(sources) do
  58.             if C_TransmogCollection.PlayerCanCollectSource(source.sourceID) then
  59.                 return true
  60.             end
  61.         end
  62.     end
  63. end
  64.  
  65. function CanTransmogItem(itemLink)
  66.     local itemID = GetItemInfoInstant(itemLink)
  67.     if itemID then
  68.         local canBeChanged, noChangeReason, canBeSource, noSourceReason = C_Transmog.GetItemInfo(itemID)
  69.         return canBeSource, noSourceReason
  70.     end
  71. end

Last edited by semlar : 07-04-16 at 10:31 AM.