Hi,
I'm really new to LUA and am trying to write my first basic addon. I'm writing an addon that, upon slash command, will scan your party/raid and tell you if any specified itemIDs are found equipped by party members. However, I'm having trouble getting NotifyInspect() and GetInventoryItemLinks() functionto cooperate.
Previously, I was querying every slot with GetInventoryItemID(), which returned the transmog item ID. This worked perfectly reading the items, albeit not the correct ones, and i was able to process my entire party. As soon as I switched to GetInventoryItemLinks(), everything I query is nil.
I tried adding an event handler to wait for NotifyInspect() to trigger it, but this produced even stranger results, and still did nothing to help the problem. Will include below.
All I want is to record the item ID of every slot of every party member. Any suggestions?
Code:
SLASH_BOOSTFINDER1 = '/boostfinder'; -- Slash command
SlashCmdList["BOOSTFINDER"] = function(msg) --Slash command list
print("Inspecting party.");
InspectParty();
end
function InspectParty()
partySize = GetNumGroupMembers();
partyMember = ""; -- Declare var
if partySize == 0 then
print("Not in a party.");
end
MyEventFrame = CreateFrame("Frame", "MyEventFrame", UIParent)
MyEventFrame:RegisterEvent("INSPECT_READY")
for i = 1, partySize do
if IsInRaid() then partyMember = "raid" else partyMember = "party" end;
partyMember = partyMember .. i
print("Checking " .. partyMember);
if CanInspect(partyMember, showError) == 1 then
if CheckInteractDistance(partyMember, 1) then
print("Can inspect "..partyMember);
NotifyInspect(partyMember); -- Server is queried for inspection
function MyEventFrame_OnEvent(self, event, ...)
BoostCheck(partyMember); -- Performs the check
end
MyEventFrame:SetScript("OnEvent", MyEventFrame_OnEvent);
end
end
end
end
function BoostCheck(partyMember)
for i = 1,17 do
print("Checking " ..partyMember.." item " ..i);
itemLink = GetInventoryItemLink(partyMember, i);
print("Generated item link" .. itemLink);
local itemString = string.match(itemLink, "item[%-?%d:]+");
print("Item string" .. itemString);
local _, itemId, enchantId, jewelId1, jewelId2, jewelId3,
jewelId4, suffixId, uniqueId, linkLevel, reforgeId = strsplit(":", itemString);
if itemLink ~= nil then
if itemId >= 100977 and itemId <= 101309 then
-- if itemId == 104730 then --Temporary
print(UnitName(partyMember) .. " is a boost");
break; --Our work on this character is done
else
print(itemId);
end
end
end
ClearInspectPlayer(); -- Ends the inspect
end