Thread Tools Display Modes
04-27-13, 06:37 AM   #1
Nim13
A Kobold Labourer
Join Date: Apr 2013
Posts: 1
NotifyInspect and its behaviour

Hi,

I just started with this LUA stuff, and came across a strange problem. I already read about the change intruduced in 3.3.5 that it's not guaranteed that you get data when calling NotifyInspect.

How can this be solved? NotifyInspect only triggers UNIT_INVENTORY_CHANGED and INSPECT_READY as far as I know. So, basicly what I'm doing right now is something like this:

Code:
if CheckInteractDistance(unit, 1) == 1 and CanInspect(unit) == 1 then
   x:RegisterEvent("INSPECT_READY")
   NotifyInspect(unit)
   x:SetScript("OnEvent",function(self,event,...)

   if event == "INSPECT_READY" then
      for i = 1, 17 do
         ...do stuff with items
      end
   end
   end)
end
This code is placed in a function and is called when I click a button. However, as I stated before, sometimes I don't get any items, sometimes one, and sometimes maybe three.

The problem I have is, that I don't know how to wait for new data. I thought there should be some event indicating that data is arriving for unit-x, but I did not find any information about that.

Maybe anoyone can point me into the right direction how I can make sure, that all data has been sent from the server before I start working with that data.

thanks in advance,
Nim
  Reply With Quote
04-27-13, 08:13 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Creating a new event handler every time you inspect someone seems quite wasteful.

As for the actual logic, though, I can't really comment as I've never done anything with the inspect system, but you may want to take a look at some other addons that do it successfully, such as Examiner (core.lua, lines 573 onward) or TipTacTalents, and look at how they handle the problem.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
04-28-13, 02:22 AM   #3
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
You can use this guide for talent checking: http://www.wowinterface.com/forums/s...d.php?p=167585
  Reply With Quote
04-28-13, 12:34 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
That thread is very out of date.

When calling NotifyInstpect(), cache the UnitID of the unit you wish to get the info for and register for the event INSPECT_READY. When INSPECT_READY fires, check the UnitID provided by the event's first returned arg. If the UnitID matches the one you cached, then the inspect data is for the unit you queried. (Checking the unit is a good habit to get into, since you may have other addons installed that inspect as well.) Once you get the data you need from INSPECT_READY, then unregister that event from your frame.

As Phanx noted, do not create a new event handler every time you call NotifyInspect(). In addition to the addons she linked you, you can also look at my addon TipTop. Function TalentQuery() in tiptop.lua is at line 409. Then look at lines 428-430. My event handler for the addon is at line 523, with the INSPECT_READY logic at lines 526-530. When the event fires, you can see that it calls my function TalentText() which is located at line 440. This function then unregisters the INSPECT_READY event at line 454.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh


Last edited by Seerah : 04-28-13 at 12:35 PM. Reason: forgot to link to TipTop
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » NotifyInspect and its behaviour


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