Thread Tools Display Modes
01-20-20, 10:54 AM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I need better eyes to spot the bug please

I am rewriting FeedTillers to address some long-standing issues and add some functionality. Of course now I ran into bugs, and I can't spot the cause.

The Broker menu isn't displaying when you mouse over the plugin; and when you click the plugin to sort either by Tiller name or Tiller item, I am getting nil errors. Great, so it can't find the item or name. But I can't spot why.

Error #1
Lua Code:
  1. 1x FeedTillers\FeedTillers-@project-version@.lua:93: attempt to compare two nil values
  2. [string "@FeedTillers\FeedTillers-@[email protected]"]:93: in function <FeedTillers\FeedTillers.lua:92>
  3. [string "=[C]"]: in function `sort'
  4. [string "@FeedTillers\FeedTillers-@[email protected]"]:114: in function `OnClick'
  5. [string "@ChocolateBar\Chocolate.lua"]:289: in function <ChocolateBar\Chocolate.lua:286>
  6.  
  7. Locals:
  8. a = <table> {
  9.  y = 33.800000
  10.  x = 48.200000
  11.  itemID = 74654
  12.  questID = 30421
  13.  factionID = 1283
  14. }
  15. b = <table> {
  16.  questID = 30439
  17.  factionID = 1273
  18.  y = 49.200000
  19.  x = 52.600000
  20.  name = "Jogu the Drunk"
  21.  noop = "Jogu's easy to find - gazing into the bottom of a bottle of the cheapest Stormstout Brewery has to offer."
  22.  itemID = 74643
  23.  standingID = 1
  24. }
  25. (*temporary) = nil
  26. (*temporary) = nil
  27. (*temporary) = "attempt to compare two nil values"

Error #2
Lua Code:
  1. 1x FeedTillers\FeedTillers-@project-version@.lua:90: attempt to compare nil with string
  2. [string "@FeedTillers\FeedTillers-@[email protected]"]:90: in function <FeedTillers\FeedTillers.lua:89>
  3. [string "=[C]"]: in function `sort'
  4. [string "@FeedTillers\FeedTillers-@[email protected]"]:114: in function `OnClick'
  5. [string "@ChocolateBar\Chocolate.lua"]:289: in function <ChocolateBar\Chocolate.lua:286>
  6.  
  7. Locals:
  8. a = <table> {
  9.  y = 33.800000
  10.  x = 48.200000
  11.  itemID = 74654
  12.  questID = 30421
  13.  factionID = 1283
  14. }
  15. b = <table> {
  16.  questID = 30439
  17.  factionID = 1273
  18.  y = 49.200000
  19.  x = 52.600000
  20.  name = "Jogu the Drunk"
  21.  noop = "Jogu's easy to find - gazing into the bottom of a bottle of the cheapest Stormstout Brewery has to offer."
  22.  item = "Sauteed Carrots"
  23.  itemID = 74643
  24.  standingID = 1
  25. }
  26. (*temporary) = nil
  27. (*temporary) = "Jogu the Drunk"
  28. (*temporary) = "attempt to compare nil with string"

And the full code
Lua Code:
  1. --[[
  2.     -- file and project errata --
  3.     Project Author:     @project-author@
  4.     Project Date:       @project-date-iso@
  5.     Project Version:    @project-version@
  6.     Project Revision:   @project-revision@
  7.  
  8.     File Author:        @file-author@
  9.     File Date:          @file-date-iso@
  10.     File Revision:      @file-revision@
  11. ]]--
  12.  
  13. local ADDON, _ = ...
  14. local ADDON_TITLE = GetAddOnMetadata(ADDON, "Title")
  15. local TILLERS = GetFactionInfoByID(1272)
  16. local LOCALE = GetLocale()
  17. local event_frame = CreateFrame("frame")
  18. local TomTom = TomTom
  19.  
  20. local L = setmetatable({}, {__index = function(t, k)
  21.     local v = tostring(k)
  22.     rawset(t, k, v)
  23.     return v
  24. end})
  25.  
  26. -- translate the tooltips
  27. --[[
  28. -- don't actually need enUS as that's the default. using this as a reminder
  29. if LOCALE == "enUS" then
  30. L["Click a Tiller's line to set a waypoint in TomTom"] = true
  31. L["Click the plugin to sort by Tiller name or item name"] = true
  32. L["Hold the <Control> key and click to hide Best Friend Tillers"] = true
  33. L["Hold the <Shift> key and click to hide already fed Tillers"] = true
  34. return end
  35. ]]--
  36.  
  37. if LOCALE == "deDE" then
  38. --@localization(locale="deDE", format="lua_additive_table")@
  39. return end
  40.  
  41. if LOCALE == "esES" or LOCALE == "esMX" then
  42. --@localization(locale="esES", format="lua_additive_table")@
  43. return end
  44.  
  45. if LOCALE == "frFR" then
  46. --@localization(locale="frFR", format="lua_additive_table")@
  47. return end
  48.  
  49. if LOCALE == "itIT" then
  50. --@localization(locale="itIT", format="lua_additive_table")@
  51. return end
  52.  
  53. if LOCALE == "koKR" then
  54. --@localization(locale="koKR", format="lua_additive_table")@
  55. return end
  56.  
  57. if LOCALE == "ptBR" then
  58. --@localization(locale="ptBR", format="lua_additive_table")@
  59. return end
  60.  
  61. if LOCALE == "ruRU" then
  62. --@localization(locale="ruRU", format="lua_additive_table")@
  63. return end
  64.  
  65. if LOCALE == "zhCN" then
  66. --@localization(locale="zhCN", format="lua_additive_table")@
  67. return end
  68.  
  69. if LOCALE == "zhTW" then
  70. --@localization(locale="zhTW", format="lua_additive_table")@
  71. return end
  72.  
  73. local qtip = LibStub("LibQTip-1.0")
  74.  
  75. local npcs = {
  76.     { factionID = 1273, itemID = 74643, questID = 30439, x = 52.6, y = 49.2 }, -- Jogu the Drunk
  77.     { factionID = 1275, itemID = 74651, questID = 30386, x = 31.6, y = 58.0 }, -- Ella
  78.     { factionID = 1276, itemID = 74649, questID = 30396, x = 31.0, y = 53.0 }, -- Old Hillpaw
  79.     { factionID = 1277, itemID = 74647, questID = 30402, x = 34.4, y = 46.8 }, -- Chee Chee
  80.     { factionID = 1278, itemID = 74645, questID = 30408, x = 29.6, y = 30.6 }, -- Sho
  81.     { factionID = 1279, itemID = 74642, questID = 30414, x = 44.6, y = 34.0 }, -- Haohan Mudclaw
  82.     { factionID = 1280, itemID = 74652, questID = 30433, x = 45.0, y = 33.8 }, -- Tina Mudclaw
  83.     { factionID = 1281, itemID = 74644, questID = 30390, x = 53.2, y = 51.6 }, -- Gina Mudclaw
  84.     { factionID = 1282, itemID = 74655, questID = 30427, x = 41.6, y = 30.0 }, -- Fish Fellreed
  85.     { factionID = 1283, itemID = 74654, questID = 30421, x = 48.2, y = 33.8 }, -- Farmer Fung
  86. }
  87.  
  88. local tooltip = "NAME"
  89. local sortByName = function(a, b)
  90.     return a.name < b.name
  91. end
  92. local sortByItem = function(a, b)
  93.     return a.item < b.item
  94. end
  95.  
  96. local function UseTomTom(npc)
  97.     local x, y = npc.x, npc.y
  98.     local opts = {title = GetFactionInfoByID(npc.factionID), persistant = true, minimap = true, world = true, crazy = true}
  99.     TomTom:AddWaypoint(376, x, y, opts) -- 376 is the uiMapID for Valley of the Four Winds
  100. end
  101.  
  102. local function CreateBroker()
  103.     LibStub("LibDataBroker-1.1"):NewDataObject(ADDON, {
  104.         type = "data source",
  105.         text = ADDON_TITLE,
  106.         icon = [[Interface/ICONS/Achievement_Profession_ChefHat]],
  107.         OnClick = function(self)
  108.             if IsShiftKeyDown() then
  109.                 FeedTillersDB.hideComplete = not FeedTillersDB.hideComplete
  110.             elseif IsControlKeyDown() then
  111.                 FeedTillersDB.hideBestFriends = not FeedTillersDB.hideBestFriends
  112.             else
  113.                 FeedTillersDB.currentSort = FeedTillersDB.currentSort == "NAME" and "ITEM" or "NAME"
  114.                 sort(npcs, FeedTillersDB.currentSort == "NAME" and sortByName or sortByItem)
  115.             end
  116.  
  117.             self:GetScript("OnLeave")(self)
  118.             self:GetScript("OnEnter")(self)
  119.         end,
  120.         OnEnter = function(self)
  121.             TILLERS = TILLERS or GetFactionInfoByID(1272)
  122.             tooltip = qtip:Acquire("FeedTillersTT", 3, "LEFT", "LEFT", "RIGHT")
  123.             tooltip:AddHeader(TILLERS, ITEMS, COMPLETE)
  124.             local line
  125.             local hideComplete = FeedTillersDB.hideComplete
  126.             local hideBestFriends = FeedTillersDB.hideBestFriends
  127.  
  128.             for i = 1, #npcs do
  129.                 local npc = npcs[i]
  130.                 npc.name, npc.noop, npc.standingID = GetFactionInfoByID(npc.factionID) -- npc.noop is not used by FeedTillers
  131.                 npc.item = npc.item or GetItemInfo(npc.itemID)
  132.                 hideBestFriends = hideBestFriends == true and npc.standingID == 8
  133.  
  134.                 if not npc.item then
  135.                     print("cFFFF0000" .. L["FeedTillers error:"] .. "|r " .. L["the food item is being cached. Please wait and try viewing the display a few times until it is updated."])
  136.                 end
  137.  
  138.                 if not hideBestFriends then
  139.                     if not IsQuestFlaggedCompleted(npc.questID) then
  140.                         -- note "line" is no longer local to this scope!
  141.                         local count = GetItemCount(npc.itemID)
  142.                         line = tooltip:AddLine(npc.name, npc.item, format("%d/%d", count, 5))
  143.                         if TomTom then
  144.                             tooltip:SetScript(line, "OnMouseUp", UseTomTom, npc)
  145.                             tooltip:SetHighlightTexture(1, 1, 1, 0.7)
  146.                         end
  147.  
  148.                         if count < 5 then
  149.                             tooltip:SetLineColor(line, 1, 0.1, 0.1, 0.3)
  150.                         end
  151.                     elseif not hideComplete then
  152.                         line = tooltip:AddLine(npc.name, npc.item, YES)
  153.                         tooltip:SetLineColor(line, 0.1, 1, 0.1, 0.3)
  154.                     end
  155.                 end
  156.             end
  157.             sort(npcs, sortByName)
  158.  
  159.             if not line then
  160.                 hideComplete = nil
  161.                 hideBestFriends = nil
  162.                 self:GetScript("OnLeave")(self)
  163.                 return self:GetScript("OnEnter")(self)
  164.             end
  165.  
  166.             line = tooltip:AddLine(" ") -- blank line
  167.  
  168.             line = tooltip:AddLine(" ")
  169.             tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Click the plugin to sort by Tiller name or item name"], "LEFT", 3)
  170.  
  171.             line = tooltip:AddLine(" ")
  172.             tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Hold the <Shift> key and click to hide already fed Tillers"], "LEFT", 3)
  173.  
  174.             line = tooltip:AddLine(" ")
  175.             tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Hold the <Control> key and click to hide Best Friend Tillers"], "LEFT", 3)
  176.  
  177.             if TomTom then
  178.                 line = tooltip:AddLine(" ")
  179.                 tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Click a Tiller's line to set a waypoint in TomTom"], "LEFT", 3)
  180.             end
  181.  
  182.             tooltip:SmartAnchorTo(self)
  183.             tooltip:Show()
  184.         end,
  185.         OnLeave = function(self)
  186.             if qtip:IsAcquired("FeedTillersTT") then
  187.                 qtip:Release(tooltip)
  188.             end
  189.             tooltip = nil
  190.         end
  191.     })
  192. end
  193.  
  194. event_frame:RegisterEvent("PLAYER_LOGIN")
  195. event_frame:SetScript("OnEvent", function(self, ...)
  196.     if ... == "PLAYER_LOGIN" then
  197.         FeedTillersDB = FeedTillersDB or {}
  198.         FeedTillersDB.hideComplete = FeedTillersDB.hideComplete or false
  199.         FeedTillersDB.currentSort = FeedTillersDB.currentSort or "NAME"
  200.         FeedTillersDB.hideBestFriends = FeedTillersDB.hideBestFriends or false
  201.  
  202.         -- clean up old saved variables
  203.         FeedTillers_hideComplete = nil
  204.         FeedTillers_currentSort = nil
  205.  
  206.         CreateBroker()
  207.     end
  208. end)
  Reply With Quote
01-20-20, 10:58 AM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
When I mouse over the plugin, it turns out I do get an error. Yes, I realize this is from "Broker_Currency" but it is FeedTillers' plugin that is firing the error.
Lua Code:
  1. 1x ...Ons\Broker_Currency\libs\LibQTip-1.0\LibQTip-1.0-46.lua:650: Usage: <unnamed>:SetScript("frameScriptTypeName", function)
  2. [string "=[C]"]: ?
  3. [string "@Broker_Currency\libs\LibQTip-1.0\LibQTip-1.0-46.lua"]:650: in function `SetScript'
  4. [string "@FeedTillers\FeedTillers-@[email protected]"]:144: in function `OnEnter'
  5. [string "@ChocolateBar\Chocolate.lua"]:257: in function <ChocolateBar\Chocolate.lua:228>
  6.  
  7. Locals:
  8. (*temporary) = <unnamed> {
  9.  0 = <userdata>
  10.  regularFont = GameTooltipText {
  11.  }
  12.  columns = <table> {
  13.  }
  14.  scrollChild = <unnamed> {
  15.  }
  16.  colspans = <table> {
  17.  }
  18.  cell_margin_v = 3
  19.  width = 232.344307
  20.  headerFont = GameTooltipHeaderText {
  21.  }
  22.  lines = <table> {
  23.  }
  24.  labelProvider = <table> {
  25.  }
  26.  key = "FeedTillersTT"
  27.  height = 27.034430
  28.  cell_margin_h = 6
  29.  slider = <unnamed> {
  30.  }
  31.  scrollFrame = <unnamed> {
  32.  }
  33. }
  34. (*temporary) = 2
  35. (*temporary) = "OnMouseUp"
  Reply With Quote
01-20-20, 08:36 PM   #3
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Can you list the code on the lines mentioned and/or the functions.

Nevermind, see you posted your addons code. We can only assume Chocolate.lua isn't bugged or there would be more issues regarding it.

I've not used lua sorting myself but took a look at how nUI uses and it looks to be the same functionality. The only thing I can think of is that the sort function isn't validating for a null value. Can you compare null values?
__________________

Last edited by Xrystal : 01-20-20 at 08:48 PM.
  Reply With Quote
01-20-20, 09:56 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
According to LibQtip, AddLine returns a number so at 142:
Code:
line = tooltip:AddLine(npc.name, npc.item, format("%d/%d", count, 5))
then at 144 you:

Code:
tooltip:SetScript(line, "OnMouseUp", UseTomTom, npc)
QTips prototype for it SetScript function is:
Code:
function tipPrototype:SetScript(scriptType, handler)
    RawSetScript(self, scriptType, handler)
    ...
I'm not sure line as the first parameter of the SetScript call is correct.
Code:
tooltip:SetScript("OnMouseUp", UseTomTom)
I don't know LibQTip so maybe I'm missing something.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 01-20-20 at 10:14 PM.
  Reply With Quote
01-20-20, 10:00 PM   #5
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
I think there was a change in this latest patch that affected some broker addons. For example, Broker_Portals will let me click on the portal; item etc... but nothing happens. I looked on the addon page at Curse and saw some complaints.

I know this may not help, or I could completely off base, but it might be worth checking this out.
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
01-21-20, 01:30 AM   #6
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Thanks to you guys and your suggestions, plus looking at ElkFaction's code, I got it almost working. Setting a waypoint in TomTom isn't working, but the display is correct and the mouse works over the menu.

What I had to do:
  • Run an iterator over the npcs table twice for some reason and then sort the list
  • Enable mouse in the OnEnter handler
  • Comment out the OnLeave code
Lua Code:
  1. --[[
  2.     -- file and project errata --
  3.     Project Author:     @project-author@
  4.     Project Date:       @project-date-iso@
  5.     Project Version:    @project-version@
  6.     Project Revision:   @project-revision@
  7.  
  8.     File Author:        @file-author@
  9.     File Date:          @file-date-iso@
  10.     File Revision:      @file-revision@
  11. ]]--
  12.  
  13. local ADDON, _ = ...
  14. local ADDON_TITLE = GetAddOnMetadata(ADDON, "Title")
  15. local TILLERS
  16. local LOCALE = GetLocale()
  17. local event_frame = CreateFrame("frame")
  18. local TomTom = TomTom
  19.  
  20. local L = setmetatable({}, {__index = function(t, k)
  21.     local v = tostring(k)
  22.     rawset(t, k, v)
  23.     return v
  24. end})
  25.  
  26. -- translate the tooltips
  27. --[[
  28. -- don't actually need enUS as that's the default. using this as a reminder
  29. if LOCALE == "enUS" then
  30. L["Click a Tiller's line to set a waypoint in TomTom"] = true
  31. L["Click the plugin to sort by Tiller name or item name"] = true
  32. L["Hold the <Control> key and click to hide Best Friend Tillers"] = true
  33. L["Hold the <Shift> key and click to hide already fed Tillers"] = true
  34. return end
  35. ]]--
  36.  
  37. if LOCALE == "deDE" then
  38. --@localization(locale="deDE", format="lua_additive_table")@
  39. return end
  40.  
  41. if LOCALE == "esES" or LOCALE == "esMX" then
  42. --@localization(locale="esES", format="lua_additive_table")@
  43. return end
  44.  
  45. if LOCALE == "frFR" then
  46. --@localization(locale="frFR", format="lua_additive_table")@
  47. return end
  48.  
  49. if LOCALE == "itIT" then
  50. --@localization(locale="itIT", format="lua_additive_table")@
  51. return end
  52.  
  53. if LOCALE == "koKR" then
  54. --@localization(locale="koKR", format="lua_additive_table")@
  55. return end
  56.  
  57. if LOCALE == "ptBR" then
  58. --@localization(locale="ptBR", format="lua_additive_table")@
  59. return end
  60.  
  61. if LOCALE == "ruRU" then
  62. --@localization(locale="ruRU", format="lua_additive_table")@
  63. return end
  64.  
  65. if LOCALE == "zhCN" then
  66. --@localization(locale="zhCN", format="lua_additive_table")@
  67. return end
  68.  
  69. if LOCALE == "zhTW" then
  70. --@localization(locale="zhTW", format="lua_additive_table")@
  71. return end
  72.  
  73. local qtip = LibStub("LibQTip-1.0")
  74.  
  75. local npcs = {
  76.     { factionID = 1273, itemID = 74643, questID = 30439, x = 52.6, y = 49.2 }, -- Jogu the Drunk
  77.     { factionID = 1275, itemID = 74651, questID = 30386, x = 31.6, y = 58.0 }, -- Ella
  78.     { factionID = 1276, itemID = 74649, questID = 30396, x = 31.0, y = 53.0 }, -- Old Hillpaw
  79.     { factionID = 1277, itemID = 74647, questID = 30402, x = 34.4, y = 46.8 }, -- Chee Chee
  80.     { factionID = 1278, itemID = 74645, questID = 30408, x = 29.6, y = 30.6 }, -- Sho
  81.     { factionID = 1279, itemID = 74642, questID = 30414, x = 44.6, y = 34.0 }, -- Haohan Mudclaw
  82.     { factionID = 1280, itemID = 74652, questID = 30433, x = 45.0, y = 33.8 }, -- Tina Mudclaw
  83.     { factionID = 1281, itemID = 74644, questID = 30390, x = 53.2, y = 51.6 }, -- Gina Mudclaw
  84.     { factionID = 1282, itemID = 74655, questID = 30427, x = 41.6, y = 30.0 }, -- Fish Fellreed
  85.     { factionID = 1283, itemID = 74654, questID = 30421, x = 48.2, y = 33.8 }, -- Farmer Fung
  86. }
  87.  
  88. local tooltip = "NAME"
  89. local sortByName = function(a, b)
  90.     return a.name < b.name
  91. end
  92. local sortByItem = function(a, b)
  93.     return a.item < b.item
  94. end
  95.  
  96. local function UseTomTom(frame, npc)
  97.     local x, y = npc.x, npc.y
  98.     local opts = {title = GetFactionInfoByID(npc.factionID), persistant = true, minimap = true, world = true, crazy = true}
  99.     TomTom:AddWaypoint(376, x, y, opts) -- 376 is the uiMapID for Valley of the Four Winds
  100. end
  101.  
  102. local function CreateBroker()
  103.     LibStub("LibDataBroker-1.1"):NewDataObject(ADDON, {
  104.         type = "data source",
  105.         text = ADDON_TITLE,
  106.         icon = [[Interface/ICONS/Achievement_Profession_ChefHat]],
  107.         OnClick = function(self)
  108.             if IsShiftKeyDown() then
  109.                 FeedTillersDB.hideComplete = not FeedTillersDB.hideComplete
  110.             elseif IsControlKeyDown() then
  111.                 FeedTillersDB.hideBestFriends = not FeedTillersDB.hideBestFriends
  112.             else
  113.                 FeedTillersDB.currentSort = FeedTillersDB.currentSort == "NAME" and "ITEM" or "NAME"
  114.                 sort(npcs, FeedTillersDB.currentSort == "NAME" and sortByName or sortByItem)
  115.             end
  116.  
  117.             self:GetScript("OnLeave")(self)
  118.             self:GetScript("OnEnter")(self)
  119.         end,
  120.         OnEnter = function(self)
  121.             if not TILLERS then
  122.                 TILLERS = GetFactionInfoByID(1272)
  123.                 for i = 1, #npcs do
  124.                     local npc = npcs[i]
  125.                     npc.name = GetFactionInfoByID(npc.factionID)
  126.                 end
  127.                 sort(npcs, sortByName)
  128.             end
  129.  
  130.             tooltip = qtip:Acquire("FeedTillersTT", 3, "LEFT", "LEFT", "RIGHT")
  131.             tooltip:AddHeader(TILLERS, ITEMS, COMPLETE)
  132.             local line
  133.             local hideComplete = FeedTillersDB.hideComplete
  134.             local hideBestFriends = FeedTillersDB.hideBestFriends
  135.  
  136.             for i = 1, #npcs do
  137.                 local npc = npcs[i]
  138.                 npc.name, npc.noop, npc.standingID = GetFactionInfoByID(npc.factionID) -- npc.noop is not used by FeedTillers
  139.                 hideBestFriends = hideBestFriends == true and npc.standingID == MAX_REPUTATION_REACTION
  140.  
  141.                 -- cache the item so we don't have to keep looking it up
  142.                 if not FeedTillersDB[npc.name] then
  143.                     print("|cFFFF0000" .. L["FeedTillers error:"] .. "|r " .. L["the food item is being cached. Please wait and try viewing the display a few times until it is updated."])
  144.                     FeedTillersDB[npc.name] = GetItemInfo(npc.itemID)
  145.                 end
  146.  
  147.                 if not hideBestFriends then
  148.                     if not IsQuestFlaggedCompleted(npc.questID) then
  149.                         -- note "line" is no longer local to this scope!
  150.                         local count = GetItemCount(npc.itemID)
  151.                         line = tooltip:AddLine(npc.name, FeedTillersDB[npc.name], format("%d/%d", count, 5))
  152.                         if TomTom then
  153.                             tooltip:SetLineScript(line, "OnMouseUp", UseTomTom, npc)
  154.                             tooltip:SetHighlightTexture(1, 1, 1, 0.7)
  155.                         end
  156.  
  157.                         if count < 5 then
  158.                             tooltip:SetLineColor(line, 1, 0.1, 0.1, 0.3)
  159.                         end
  160.                     elseif not hideComplete then
  161.                         line = tooltip:AddLine(npc.name, FeedTillersDB[npc.name], YES)
  162.                         tooltip:SetLineColor(line, 0.1, 1, 0.1, 0.3)
  163.                     end
  164.                 end
  165.             end
  166.  
  167.             if not line then
  168.                 hideComplete = nil
  169.                 hideBestFriends = nil
  170.                 self:GetScript("OnLeave")(self)
  171.                 return self:GetScript("OnEnter")(self)
  172.             end
  173.  
  174.             line = tooltip:AddLine(" ") -- blank line
  175.  
  176.             line = tooltip:AddLine(" ")
  177.             tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Click the plugin to sort by Tiller name or item name"], "LEFT", 3)
  178.  
  179.             line = tooltip:AddLine(" ")
  180.             tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Hold the <Shift> key and click to hide already fed Tillers"], "LEFT", 3)
  181.  
  182.             line = tooltip:AddLine(" ")
  183.             tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Hold the <Control> key and click to hide Best Friend Tillers"], "LEFT", 3)
  184.  
  185.             if TomTom then
  186.                 line = tooltip:AddLine(" ")
  187.                 tooltip:SetCell(line, 1, NORMAL_FONT_COLOR_CODE .. L["Click a Tiller's line to set a waypoint in TomTom"], "LEFT", 3)
  188.             end
  189.  
  190.             tooltip:SmartAnchorTo(self)
  191.             tooltip:SetAutoHideDelay(0.1, self)
  192.             tooltip:EnableMouse(true)
  193.             tooltip:Show()
  194.         end,
  195.         OnLeave = function(self)
  196.             --[[
  197.             if qtip:IsAcquired("FeedTillersTT") then
  198.                 qtip:Release(tooltip)
  199.             end
  200.             tooltip = nil
  201.             ]]--
  202.         end
  203.     })
  204. end
  205.  
  206. event_frame:RegisterEvent("PLAYER_LOGIN")
  207. event_frame:SetScript("OnEvent", function(self, ...)
  208.     if ... == "PLAYER_LOGIN" then
  209.         FeedTillersDB = FeedTillersDB or {}
  210.         FeedTillersDB.hideComplete = FeedTillersDB.hideComplete or false
  211.         FeedTillersDB.currentSort = FeedTillersDB.currentSort or "NAME"
  212.         FeedTillersDB.hideBestFriends = FeedTillersDB.hideBestFriends or false
  213.  
  214.         -- clean up old saved variables
  215.         FeedTillers_hideComplete = nil
  216.         FeedTillers_currentSort = nil
  217.  
  218.         CreateBroker()
  219.     end
  220. end)
Attached Thumbnails
Click image for larger version

Name:	FeedTillers WIP1.jpg
Views:	99
Size:	52.8 KB
ID:	9405  
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » I need better eyes to spot the bug please

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