Thread Tools Display Modes
07-23-14, 07:05 PM   #1
Heanthor
A Defias Bandit
Join Date: Jul 2014
Posts: 3
Inspecting your party to download item IDs

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
  Reply With Quote
07-23-14, 09:42 PM   #2
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
The inspect API will fire an event when the inspect data is available. This means you can call the API to start inspecting someone, wait for the reply event, call the next API to inspect someone else.

You can't forcefully queue up these, you must call, event, call, event, e.g. This complicates things further. I can recommend using a inspection library to help you with your own addon, making coding it a bit easier. For example take a look at these; just a couple of examples:

http://www.wowace.com/addons/libinspect/
http://www.wowace.com/addons/libgroupinspect/
__________________
Profile: Curse | Wowhead
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Inspecting your party to download item IDs

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off