Thread Tools Display Modes
11-29-14, 03:38 AM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
DataStore and Wowhead_Looter with Followers

Nulgar and I found the same errors in two different AddOns that scan recipe data. DataStore_Crafts and Wowhead_Looter.

My theory, after looking at the former's code is that when you assign a Follower to a building, in our case Ahm to the Enchanter within your Garrison, the AddOns attempt to get recipe link information when the player talks to them.

Of course, your trade skill window opens and instant problems. This is because, I believe, Followers do not have to worry about materials or components, and thus do not have true recipes from which to get links.I am wondering if and how to determine if you are interracting with a Follower, and if yes, exit out so the errors never happen.
  Reply With Quote
11-29-14, 03:57 AM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
All I need is the following pseudo-code. Trouble is, I don't know how to learn if we are interracting with a Follower, or any NPC for that matter.
Code:
if interracting with Follower then
    return
end
*edit * Would this work?
Code:
local followers = C_Garrison.GetFollowers() -- table with all the followers

for i = 1, GameTooltip:Numlines() do
	if GameTooltip[i]:GetText():match(followers.name) then
		return
	end
end

Last edited by myrroddin : 11-29-14 at 04:20 AM. Reason: possible solution?
  Reply With Quote
11-29-14, 06:03 AM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I am very close, I think. I am getting a nested loop error that I can't spot.
Lua Code:
  1. -- experiment to exit out if interacting with a Follower
  2. local followers = followers or {}
  3. table.wipe(followers)
  4. followers = C_Garrison.GetFollowers() -- table with all the followers
  5. local foundFollower = nil
  6.  
  7. for i = 1, GameTooltip:NumLines() do
  8.     for k , v in pairs(followers) do
  9.         if GameTooltipTextLeft..i:GetText():match(tostring(v.name)) then
  10.             foundFollower = true
  11.             return  -- found match
  12.         end
  13.     end
  14. end
  15.    
  16. if foundFollower then return end

And here is the error, and line 482 in the error equates to line 9 above. GameTooltipTextLeft..i <-- not finding i.
Lua Code:
  1. 40x DataStore_Crafts\DataStore_Crafts-r56.lua:482: attempt to index local 'i' (a number value)
  2. DataStore_Crafts\DataStore_Crafts-r56.lua:482: in function <DataStore_Crafts\DataStore_Crafts.lua:452>
  3. DataStore_Crafts\DataStore_Crafts-r56.lua:532: in function <DataStore_Crafts\DataStore_Crafts.lua:529>
  4. DataStore_Crafts\DataStore_Crafts-r56.lua:624: in function <DataStore_Crafts\DataStore_Crafts.lua:617>
  Reply With Quote
11-29-14, 06:40 AM   #4
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
IsNPCCrafting()
__________________
Grab your sword and fight the Horde!
  Reply With Quote
11-29-14, 07:27 AM   #5
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Lua Code:
  1. if _G["GameTooltipTextLeft"..i]:GetText():match(tostring(v.name)) then
  Reply With Quote
11-29-14, 08:11 AM   #6
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Originally Posted by Lombra View Post
IsNPCCrafting()
Thank you, I didn't find that, even after a search. Works like a charm!
Lua Code:
  1. -- experiment to exit out if interacting with a Follower
  2. local followers = followers or {}
  3. table.wipe(followers) -- just in case
  4. followers = C_Garrison.GetFollowers() -- table with all the followers
  5. local foundFollower = nil
  6.  
  7. for i = 1, #followers do
  8.     local id = followers.followerID
  9.     if IsNPCCrafting(id) then
  10.         foundFollower = true
  11.     end
  12. end
  13. if foundFollower then return end
  Reply With Quote
11-29-14, 11:27 AM   #7
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
There are no arguments. Just call it to determine whether the currently open tradeskill window belongs to an(y) NPC.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
11-30-14, 06:08 AM   #8
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
D'oh. That's the trouble with new APIs not being documented. I tried doing a dump, but it was best guess.
  Reply With Quote
12-01-14, 09:48 AM   #9
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by myrroddin View Post
D'oh. That's the trouble with new APIs not being documented. I tried doing a dump, but it was best guess.
Phanx linked me to here maybe this will help you.

Coke
  Reply With Quote
12-01-14, 12:15 PM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Yep, the Blizz UI code is actually a good place to look if an API isn't documented on Wowpedia or WoWProgramming yet. Just don't look at their actual code writing unless you're looking for entertainment.
__________________
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

WoWInterface » Developer Discussions » Lua/XML Help » DataStore and Wowhead_Looter with Followers

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