View Single Post
10/12/14, 05:21 PM   #4
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Or maybe it wasn't a type-o.
Does it still work if you do something like:
Lua Code:
  1. return _lItemLink and GetMyLinkItemInfo(_lItemLink) or GetItemInfo(_iBagId, _iSlotId)


Sorry I should have just posted the actual code to begin with.

The idea is to call one function GetMyItemInfo(..) to get an items info whether you pass in a bag,slot or link:
Lua Code:
  1. local function GetMyLinkItemInfo(_lItemLink)
  2.     local sIcon, iSellPrice, bMeetsUsageRequirement, iEquipType, iItemStyle = GetItemLinkInfo(_lItemLink)
  3.     local iItemQuality = GetItemLinkQuality(_lItemLink)
  4. -- I know iStack & bLocked are not defined & return nil --
  5. -- I'm ok with that, nothing wrong with doing that right ? --
  6.     return sIcon, iStack, iSellPrice, bMeetsUsageRequirement, bLocked, iEquipType, iItemStyle, iItemQuality
  7. end
  8.  
  9. local function GetMyItemInfo(_iBagId, _iSlotId, _lItemLink)
  10. -- These two below work
  11.     --return GetMyLinkItemInfo(_lItemLink)
  12.     --return GetItemInfo(_iBagId, _iSlotId)
  13. -- But this one doesn't
  14.     return _lItemLink and GetMyLinkItemInfo(_lItemLink) or GetItemInfo(_iBagId, _iSlotId)
  15. end
and then calling the following fails:
Lua Code:
  1. -- Whether I call it with a bagId, slotId or Link they both fail at the same place --
  2.     local sIcon, iStack, iSellPrice, bMeetsUsageRequirement, bLocked, iEquipType, iItemStyle, iItemQuality = GetmyItemInfo(iBagId, iSlotId, nil)
  3.     local sIcon, iStack, iSellPrice, bMeetsUsageRequirement, bLocked, iEquipType, iItemStyle, iItemQuality = GetmyItemInfo(nil, nil, lLink)
  4.  
  5.     d("sIcon: "..sIcon)
  6. -- I know iStack can be nil if I pass in a link, thats ok --
  7.     if iStack then d("iStack: "..iStack) else d("iStack: Nil") end
  8.  
  9. --***************************************************--
  10. -- iSellPrice: Fails with "Operator .. not supported for string .. nil" --
  11.     d("iSellPrice: "..iSellPrice)
  12. --***************************************************--
  13.  
  14.  
  15.     d("bMeetsUsageRequirement: "..tostring(bMeetsUsageRequirement))
  16. -- I know bLocked can be nil if I pass in a link, thats ok --
  17.     if bLocked then d("bLocked: "..tostring(bLocked)) else d("bLocked: Nil") end
  18.     d("iEquipType: "..iEquipType)
  19.     d("iItemStyle: "..iItemStyle)
  20.     d("iItemQuality: "..iItemQuality)
  Reply With Quote