If any of you have had to deal with getting item info in the past you will love the new item api. I have a bag addon that I use (my version isn't public) and always had problems getting the correct item level since GetItemInfo hadn't been fixed to deal with scaling item level. The new API made it really easy all it took was a few lines.
Lua Code:
local item = Item:CreateFromBagAndSlot(bagID, slotID)
if ( item ) then
ilevel = item:GetCurrentItemLevel()
end
I'm creating from the bagID and slotID because the code was already setup that way but you can also set it up from an item link, equipment slot, or the new item location mixin.
Lua Code:
--[[static]] function Item:CreateFromItemLocation(itemLocation)
if type(itemLocation) ~= "table" or type(itemLocation.HasAnyLocation) ~= "function" or not itemLocation:HasAnyLocation() then
error("Usage: Item:CreateFromItemLocation(notEmptyItemLocation)", 2);
end
local item = CreateFromMixins(ItemMixin);
item:SetItemLocation(itemLocation);
return item;
end
--[[static]] function Item:CreateFromBagAndSlot(bagID, slotIndex)
if type(bagID) ~= "number" or type(slotIndex) ~= "number" then
error("Usage: Item:CreateFromBagAndSlot(bagID, slotIndex)", 2);
end
local item = CreateFromMixins(ItemMixin);
item:SetItemLocation(ItemLocation:CreateFromBagAndSlot(bagID, slotIndex));
return item;
end
--[[static]] function Item:CreateFromEquipmentSlot(equipmentSlotIndex)
if type(equipmentSlotIndex) ~= "number" then
error("Usage: Item:CreateFromEquipmentSlot(equipmentSlotIndex)", 2);
end
local item = CreateFromMixins(ItemMixin);
item:SetItemLocation(ItemLocation:CreateFromEquipmentSlot(equipmentSlotIndex));
return item;
end
--[[static]] function Item:CreateFromItemLink(itemLink)
if type(itemLink) ~= "string" then
error("Usage: Item:CreateFromItemLink(itemLinkString)", 2);
end
local item = CreateFromMixins(ItemMixin);
item:SetItemLink(itemLink);
return item;
end
I'm still looking into the new api so that is probably just scratching the surface of what you can do with it. If you want the full details you can find them in ItemDocumentation.lua in the API folder and under Item.lua in FrameXML\ObjectAPI.