Thread Tools Display Modes
07-09-16, 05:39 PM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Fixing LibUtilities' itemString breakdown

I'm back from vacation, and now to fix the DecodeItemString API in LibUtilities-1.0. It was pointed out in this forum thread that the return values were not correct. Some are in the wrong place, others simply don't seem to exist (return values 16+ ?).

Where I am stumbling is Wowpedia's documentation for itemString, which I thought I had followed. I know that all the "0" values have been replaced with empty strings "", but that shouldn't have much effect.

Yes, I have upvalued some API, so, for example, tonumber() is to_number() in my code.
Lua Code:
  1. function lib:DecodeItemString(itemString)
  2.     local bonusIDs = bonusIDs or {}
  3.     table_wipe(bonusIDs)
  4.    
  5.     local itemType, itemID, enchantID, gemID1, gemID2, gemID3, gemID4, suffixID, uniqueID, linkLevel, specializationID, upgradeTypeID, instanceDifficultyID, numBonuses, affixes = string_split(":", itemString, 15)
  6.    
  7.     for i = 1, numBonuses do
  8.         local bonusID = select(i, string_split(":", affixes))
  9.         table_insert(bonusIDs, bonusID..i)
  10.     end
  11.    
  12.     local upgradeID = select(numBonuses + 1, string_split(":", affixes))
  13.    
  14.     -- itemType = string_sub(itemType, "|c........", "") -- experimental
  15.     -- itemType = string_sub(itemType, "|.?", "")
  16.    
  17.     return itemType, itemID, enchantID, gemID1, gemID2, gemID3, gemID4, suffixID, uniqueID, linkLevel, specializationID, upgradeTypeID, instanceDifficultyID, numBonuses, bonusIDs, upgradeID
  18. end
I am thinking of wrapping the numBonuses thusly:
Lua Code:
  1. numBonuses = to_number(numBonuses)
  2.  
  3. if numBonuses then
  4.     for i = 1, numBonuses do
  5.         local bonusID = select(i, string_split(":", affixes))
  6.         table_insert(bonusIDs, bonusID..i)
  7.     end
  8. end
  Reply With Quote
07-10-16, 08:52 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Will need more testing than I have done already, but in theory the changes in revision 15+ should work.

http://www.wowace.com/addons/libutilities-1-0/
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Fixing LibUtilities' itemString breakdown


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off