GetNumLootItems doesn't tell you anything about the individual items to be looted; it only tells you how many items to show in the list of items to loot. You can then pass values from 1-
n, where
n is the number it gave you, into
GetLootSlotInfo to get information about each item, including how many of it are there.
I'd strongly suggest you look at the code of other addons that do things like this, or even the default UI, to get an idea of how to use these functions. There's also lots of detailed documentation on sites like Wowprogramming.com (which Cybeloras linked you to) and Wowpedia.org that tells you exactly what each function does and how to use it, so you don't have to guess or spend hours on trial-and-error attempts.
Edit:
Code:
local currentItem
local f = CreateFrame("Frame")
f:RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", "player")
f:SetScript("OnEvent", function(self, event, ...)
if event == "UNIT_SPELLCAST_SUCCEEDED" then
local unit, spell, rank, lineID, spellID = ...
if spellID == 13262 then
self:RegisterEvent("ITEM_LOCK_CHANGED")
self:RegisterEvent("LOOT_OPENED")
end
elseif event == "ITEM_LOCK_CHANGED" then
local bag, slot = ...
local texture, count, locked, quality, readable, lootable, link = GetContainerItemInfo(bag, slot)
if locked then
currentItem = link
else
currentItem = nil
self:UnregisterEvent("ITEM_LOCK_CHANGED")
self:UnregisterEvent("LOOT_OPENED")
end
elseif event == "LOOT_OPENED" then
print("Loot from disenchanting", currentItem)
for i = 1, GetNumLootItems() do
local lootType = GetLootSlotType(i)
local texture, item, quantity, quality, locked = GetLootSlotInfo(i)
if lootType == 2 then
print("Money:", item)
else
print(GetLootSlotLink(i), "x", quantity)
end
end
end
end)
Order of events goes:
1. UNIT_SPELLCAST_SUCCEEDED (player finishes casting Disenchant)
2. ITEM_LOCK_CHANGED (target item becomes locked)
3. LOOT_OPENED (loot window opens)
4. ITEM_LOCK_CHANGED (target item becomes unlocked after loot window closes)