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:
function lib:DecodeItemString(itemString)
local bonusIDs = bonusIDs or {}
table_wipe(bonusIDs)
local itemType, itemID, enchantID, gemID1, gemID2, gemID3, gemID4, suffixID, uniqueID, linkLevel, specializationID, upgradeTypeID, instanceDifficultyID, numBonuses, affixes = string_split(":", itemString, 15)
for i = 1, numBonuses do
local bonusID = select(i, string_split(":", affixes))
table_insert(bonusIDs, bonusID..i)
end
local upgradeID = select(numBonuses + 1, string_split(":", affixes))
-- itemType = string_sub(itemType, "|c........", "") -- experimental
-- itemType = string_sub(itemType, "|.?", "")
return itemType, itemID, enchantID, gemID1, gemID2, gemID3, gemID4, suffixID, uniqueID, linkLevel, specializationID, upgradeTypeID, instanceDifficultyID, numBonuses, bonusIDs, upgradeID
end
I am thinking of wrapping the numBonuses thusly:
Lua Code:
numBonuses = to_number(numBonuses)
if numBonuses then
for i = 1, numBonuses do
local bonusID = select(i, string_split(":", affixes))
table_insert(bonusIDs, bonusID..i)
end
end