Mercurial > wow > askmrrobot
comparison AskMrRobot-Serializer/AskMrRobot-Serializer.lua @ 69:69db1c3025ac v27
fixed some bugs with 6.2 item link format changes, added bib overwolf support
author | yellowfive |
---|---|
date | Mon, 06 Jul 2015 17:39:57 -0700 |
parents | 932885bb1a6f |
children | 6abc0858b45e |
comparison
equal
deleted
inserted
replaced
68:6c523f147709 | 69:69db1c3025ac |
---|---|
1 -- AskMrRobot-Serializer will serialize and communicate character data between users. | 1 -- AskMrRobot-Serializer will serialize and communicate character data between users. |
2 -- This is used primarily to associate character information to logs uploaded to askmrrobot.com. | 2 -- This is used primarily to associate character information to logs uploaded to askmrrobot.com. |
3 | 3 |
4 local MAJOR, MINOR = "AskMrRobot-Serializer", 26 | 4 local MAJOR, MINOR = "AskMrRobot-Serializer", 27 |
5 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR) | 5 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
6 | 6 |
7 if not Amr then return end -- already loaded by something else | 7 if not Amr then return end -- already loaded by something else |
8 | 8 |
9 -- event and comm used for player snapshotting on entering combat | 9 -- event and comm used for player snapshotting on entering combat |
577 | 577 |
578 ---------------------------------------------------------------------------------------- | 578 ---------------------------------------------------------------------------------------- |
579 -- Public Utility Methods | 579 -- Public Utility Methods |
580 ---------------------------------------------------------------------------------------- | 580 ---------------------------------------------------------------------------------------- |
581 | 581 |
582 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:unknown:upgradeId:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r | 582 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:unknown:unknown:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r |
583 -- get an object with all of the parts of the item link format that we care about | 583 -- get an object with all of the parts of the item link format that we care about |
584 function Amr.ParseItemLink(itemLink) | 584 function Amr.ParseItemLink(itemLink) |
585 if not itemLink then return nil end | 585 if not itemLink then return nil end |
586 | 586 |
587 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|") | 587 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|") |
595 item.gemIds = { tonumber(parts[3]), tonumber(parts[4]), tonumber(parts[5]), tonumber(parts[6]) } | 595 item.gemIds = { tonumber(parts[3]), tonumber(parts[4]), tonumber(parts[5]), tonumber(parts[6]) } |
596 item.suffixId = math.abs(tonumber(parts[7])) -- convert suffix to positive number, that's what we use in our code | 596 item.suffixId = math.abs(tonumber(parts[7])) -- convert suffix to positive number, that's what we use in our code |
597 --item.uniqueId = tonumber(parts[8]) | 597 --item.uniqueId = tonumber(parts[8]) |
598 --item.level = tonumber(parts[9]) | 598 --item.level = tonumber(parts[9]) |
599 -- part 10 is unknown atm | 599 -- part 10 is unknown atm |
600 item.upgradeId = tonumber(parts[11]) | 600 -- part 11 is unknown atm |
601 --item.difficultyId = tonumber(parts[12]) | 601 --item.difficultyId = tonumber(parts[12]) |
602 | 602 |
603 local numBonuses = tonumber(parts[13]) | 603 local numBonuses = tonumber(parts[13]) |
604 if numBonuses and numBonuses > 0 then | 604 if numBonuses and numBonuses > 0 then |
605 item.bonusIds = {} | 605 item.bonusIds = {} |
606 for i = 14, 13 + numBonuses do | 606 for i = 14, 13 + numBonuses do |
607 table.insert(item.bonusIds, tonumber(parts[i])) | 607 table.insert(item.bonusIds, tonumber(parts[i])) |
608 end | 608 end |
609 table.sort(item.bonusIds) | 609 table.sort(item.bonusIds) |
610 end | 610 end |
611 | |
612 -- if numBonuses is 0 and there is a number after it, that is the upgrade id for old items now I guess? | |
613 if numBonuses == 0 then | |
614 local upgradeId = tonumber(parts[14]) | |
615 item.upgradeId = upgradeId and upgradeId or 0 | |
616 else | |
617 item.upgradeId = 0 | |
618 end | |
611 | 619 |
612 return item | 620 return item |
613 end | 621 end |
614 | 622 |
615 -- returns true if this is an instance that AskMrRobot supports for logging | 623 -- returns true if this is an instance that AskMrRobot supports for logging |