What is this ?
As per request as well as to whoever may find it useful, here is a collection of lua routines to 'decode' and extract useful information from item links in the LotRO chat.
See this thread for background information regarding the problem that spawned this:
http://forums.lotro.com/showthread.p...th-missing-IDs
How to use
- Unzip the archive into a location of your choice
- Alter paths in '__init__.lua' to the correct location (since Turbine's 'import' does not handle relative paths, sadly)
In your project:
- Import the relevant folder (ie: import "
myname.
myplugin.ItemLinkDecode"; )
- Call DecodeLinkData( data, isLI ) on a string extracted from the chat. 'data' must be an encoded string from an item link, either from <ExamineIA:IAInfo:*> or <ExamineItemInstance:ItemInfo:*>
eg:
Code:
local data, name = string.match( chatLine, "<ExamineIA:IAInfo:(.-)>(%b[])<\\ExamineIA>" )
local result = ItemLinkDecode.DecodeLinkData( data, true);
or
Code:
local data, name = string.match( chatLine, "<ExamineItemInstance:ItemInfo:(.-)>(%b[])<\\ExamineItemInstance>"
local result = ItemLinkDecode.DecodeLinkData( data, false);
The function returns a table with the following fields:
itemIIDLow - instance item ID, least significant 32 bits
itemIIDHigh - instance item ID, most significant 32 bits
itemGID - generic item ID
itemCraftedBy - name of the crafter
itemBoundToLow - ID of player / account / placeholder ID to which the item is bound, least significant 32 bits
itemBoundToHigh - ID of player / account / placeholder ID to which the item is bound, most significant 32 bits
itemTrueLevel - true level of the item, can be > level to equip
itemName - name of the (crafted) item
itemLevel - level of the item (to equip)
itemUpgrades - number of upgrades (crystals)
itemWorth - worth of the item (in copper coins)
itemQuantity - number of items in stack (if relevant)
itemStorageInfo - where the item is stored (32bits, needs further decoding)
itemDye - color of the item
itemBindToAccount - whether the item binds to account
itemBindOnAcquire - whether the item binds on acquire
itemArmour - armour value of the item
liName - name of LI as named by the player (as opposed to crafted name)
liTitleID - ID to a LI title if applied
liLegacies - a table of legacies { { ID-1, rank-1 }, { ID-2, rank-2 } ... {ID-n, rank-n) }
liRelics - a table of relics { { ID-1, slot-1 }, { ID-2, slot-2 } .. {ID-n, slot-n} }, where 'slot' is a number between 1-4 refering to setting/gem/rune/crafted.
liStats - a table of stats { ID-1, ID-2, ... ID-n }
liPointsSpent - legendary points that have been spent
liPointsLeft - legendary points that are left to spend
liDPSRank - rank of the DPS legacy if a melee/ranged weapon
liDefaultLegacyID - ID of the 'default' legacy if not a melee/ranged weapon (Tactical Damage Rating, Tactical Healing Rating, Shield Use, etc)
liDefaultLegacyRank - rank of the afore mentioned 'default' legacy if not a melee/ranged weapon
liLevel - Level of the LI (1-70)
liMaxHit - max hit of melee damage range, in single precision floating point format (IEEE 754-2008) (represented as a 32 bits integer), for 'tactical' weapons (LM staff, minstrel weapon, RK stone).
- Min hit and dps can be computed thus:
- Min hit = 3/5 of max hit.
- DPS = (4/5 of max hit) / (attack duration of weapon) - attack duration is 2.5s for 2h, 1.9s for 1h
Code snippet using my plugin
HereBeDragons to browse results from links posted to the chat:
Code:
import "myname.myplugin.ItemLinkDecode";
import "Equendil.LuaExplorer.DefaultBrowser";
local chatHook = function (sender, args)
local LIData, name = string.match( args.Message, "<ExamineIA:IAInfo:(.*)>(%b[])<\\ExamineIA>" );
if LIData ~= nil then
local result = ItemLinkDecode.DecodeLinkData( LIData, true );
Equendil.LuaExplorer.Explore( name, result );
return;
end
local itemData, name = string.match( args.Message, "<ExamineItemInstance:ItemInfo:(.*)>(%b[])<\\ExamineItemInstance>" );
if itemData ~= nil then
local result = ItemLinkDecode.DecodeLinkData( itemData, false );
Equendil.LuaExplorer.Explore( name, result );
end
end
-- install the chat hook
if type(Turbine.Chat.Received) == "table" then
table.insert( Turbine.Chat.Received, chatHook );
else
local existingHook = Turbine.Chat.Received;
Turbine.Chat.Received = { chatHook, existingHook };
end
Attribution
The implementation of the zlib inflate algorithm was written by
David Manura. Check the license in "inflate.lua".
Feel free to copy, alter, use or re-distribute this package, crediting the author would be nice, however (("Equendil" @ http://www.lotrointerface.com/list.php?skinnerid=4226).