View Single Post
05-28-21, 07:48 AM   #4
Dixon Butz
A Deviate Faerie Dragon
 
Dixon Butz's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 13
Sorry, I think I may have edited that file. Can you take a look?
Here is the error with the original file:


Code:
Message: Interface\AddOns\KBTracker\KBTracker.lua:186: attempt to call method 'SetBackdrop' (a nil value)
Time: Fri May 28 09:45:14 2021
Count: 1
Stack: Interface\AddOns\KBTracker\KBTracker.lua:186: attempt to call method 'SetBackdrop' (a nil value)
[string "@Interface\AddOns\KBTracker\KBTracker.lua"]:186: in function `KBTracker_CreateMainFrame'
[string "@Interface\AddOns\KBTracker\KBTracker.lua"]:61: in function `KBTracker_OnLoad'
[string "@Interface\AddOns\KBTracker\KBTracker.lua"]:48: in function <Interface\AddOns\KBTracker\KBTracker.lua:48>

Locals: backdrop = <table> {
 bgFile = "Interface\DialogFrame\UI-DialogBox-Background"
 tileSize = 32
 edgeFile = "Interface\DialogFrame\UI-DialogBox-Border"
 tile = false
 edgeSize = 20
 insets = <table> {
 }
}
(*temporary) = nil
(*temporary) = KBT_Display_Frame {
 0 = <userdata>
}
(*temporary) = <table> {
 bgFile = "Interface\DialogFrame\UI-DialogBox-Background"
 tileSize = 32
 edgeFile = "Interface\DialogFrame\UI-DialogBox-Border"
 tile = false
 edgeSize = 20
 insets = <table> {
 }
}
(*temporary) = "attempt to call method 'SetBackdrop' (a nil value)"
KBTBlueColor = ""
KBTTopColor = ""
KBTMiddleColor = ""
KBTBottomColor = ""
KBTWhiteColor = ""
Lua Code:
  1. --------------------------------------------------------------THESE COLORS SET THE TOP MIDDLE AND BOTTOM ROW COLORS
  2. local KBTWhiteColor = "|cFFFFFFFF";
  3. local KBTBlueColor = "|cFF0070fF";
  4. local KBTTopColor = "|cFFFFFF00";
  5. local KBTMiddleColor = "|cFFFF0000";
  6. local KBTBottomColor = "|cFF00FF00";
  7. local PlayerName = UnitName("Player");
  8.  
  9. local KBT_WasInBG = false;
  10. local KBT_IsInBG = false;
  11. local KBT_LastBG = "";
  12.  
  13. function KBT_TestFn()
  14.     KBT_Current_KillingBlows = 10;
  15.     KBT_Current_HonorKills = 10;
  16.    
  17.     KBT_Display_HK:SetText( KBTWhiteColor   .. "(KB)\n" ..
  18.                             KBTTopColor     .. KBT_Current_KillingBlows .. "\n" ..
  19.                             KBTMiddleColor  .. KBT_Last_KillingBlows .."\n" ..
  20.                             KBTBottomColor  .. KBT_Total_KillingBlows + KBT_Current_KillingBlows)
  21.    
  22.     KBT_Display_KB:SetText( KBTWhiteColor   .. "(HK)\n" ..
  23.                             KBTTopColor     .. KBT_Current_HonorKills .. "\n" ..
  24.                             KBTMiddleColor  .. KBT_Last_HonorKills .."\n" ..
  25.                             KBTBottomColor  .. KBT_Total_HonorKills + KBT_Current_HonorKills)
  26. end
  27.  
  28. local KBT_ListOfBattlegrounds = {
  29.     "Isle of Conquest",
  30.     "Alterac Valley",
  31.     "Arathi Basin",
  32.     "Eye of the Storm",
  33.     "Warsong Gulch",
  34.     "Strand of the Ancients",
  35.     "Twin Peaks",
  36.     "Battle for Gilneas"
  37. }
  38.  
  39. KBT_Current_KillingBlows = 0;
  40. KBT_Last_KillingBlows = 0;
  41. KBT_Total_KillingBlows = 0;
  42.  
  43. KBT_Current_HonorKills = 0;
  44. KBT_Last_HonorKills = 0;
  45. KBT_Total_HonorKills = 0;
  46.  
  47. KBTracker_OnLoadFunction = CreateFrame("FRAME");
  48. KBTracker_OnLoadFunction:SetScript("OnEvent", function()    KBTracker_OnLoad(); end)
  49. KBTracker_OnLoadFunction:RegisterEvent("VARIABLES_LOADED");
  50.  
  51. function KBTracker_OnLoad()
  52.  
  53.     if KBTrackerDBPC == nil then KBTrackerDBPC = {} end
  54.     if KBTrackerDBPC["x"] == nil then KBTrackerDBPC["x"] = 0 end
  55.     if KBTrackerDBPC["y"] == nil then KBTrackerDBPC["y"] = 0 end
  56.     if KBTrackerDBPC["point"] == nil then KBTrackerDBPC["point"] = "Center" end
  57.  
  58.    
  59.  
  60. -- create the frame to hold the data
  61.     KBTracker_CreateMainFrame()
  62.    
  63. -- create a frame that updates every 5 seconds to update the data
  64.     KBTracker_CreateUpdateFrame()
  65.    
  66.    
  67. -- setup slash commands
  68.     SLASH_KBT1 = "/kbt";
  69.     SLASH_KBT2 = "/hkt";
  70.     SLASH_KBT3 = "/kbtracker";
  71.     SlashCmdList["KBT"] =  KBTracker_Command;
  72. end
  73.  
  74. function KBTracker_CreateUpdateFrame()
  75.     KBT_UpdateTime = time()+10;
  76.     KBT_Update_Frame=CreateFrame("FRAME");
  77.     KBT_Update_Frame:SetScript("OnUpdate", function()
  78.         if time() >= KBT_UpdateTime then
  79.             KBT_UpdateTime = time()+10;
  80.             RequestBattlefieldScoreData()
  81.             KBTracker_ZoneChecker()
  82.             --print(time());
  83.         end;
  84.     end);
  85.    
  86.     KBTracker_UpdateDataFrame = CreateFrame("FRAME");
  87.     KBTracker_UpdateDataFrame:SetScript("OnEvent", function()   KBTracker_UpdateData(); end)
  88.     KBTracker_UpdateDataFrame:RegisterEvent("UPDATE_BATTLEFIELD_SCORE");
  89. end
  90.  
  91. function KBTracker_ZoneChecker()   
  92. local Zone = GetRealZoneText();
  93. local KBT_BGFound = false;
  94. local KBT_NewBG = false;
  95.  
  96.     --print(Zone)
  97.    
  98.     for i=1,#KBT_ListOfBattlegrounds do
  99.         if Zone == KBT_ListOfBattlegrounds[i] then
  100.             --print(KBT_ListOfBattlegrounds[i]);
  101.             KBT_BGFound = true;
  102.         end
  103.     end
  104.    
  105.     if KBT_WasInBG == true and KBT_BGFound == true and KBT_LastBG ~= Zone then
  106.         KBT_NewBG = true;
  107.     end
  108.    
  109.     if KBT_WasInBG == false and KBT_BGFound == true then
  110.         KBT_NewBG = true;
  111.     end
  112.    
  113.     if KBT_NewBG == true then
  114.         --print("|cff0070ffNew BG found")
  115.        
  116.         KBT_Total_KillingBlows = KBT_Total_KillingBlows + KBT_Current_KillingBlows;
  117.         KBT_Total_HonorKills   = KBT_Total_HonorKills   + KBT_Current_HonorKills;
  118.        
  119.         KBT_Last_KillingBlows = KBT_Current_KillingBlows;
  120.         KBT_Last_HonorKills   = KBT_Current_HonorKills;
  121.        
  122.         KBT_Current_KillingBlows = 0;
  123.         KBT_Current_HonorKills   = 0;
  124.        
  125.         KBT_LastBG = Zone;
  126.     end
  127.    
  128.     KBT_WasInBG = KBT_BGFound;
  129. end
  130.  
  131. function KBTracker_UpdateData()
  132. local Max = GetNumBattlefieldScores();
  133.  
  134.     if Max > 0 then
  135.         for i=1,Max do
  136.             local name, killingBlows, honorKills, _ = GetBattlefieldScore(i);
  137.             if name == PlayerName then
  138.                 --print(name)
  139.                 --print(killingBlows)
  140.                 --print(honorKills)
  141.                 --print(GetBattlefieldScore(i));
  142.                
  143.                
  144.                 if killingBlows > KBT_Current_KillingBlows then
  145.                     KBT_Current_KillingBlows = killingBlows;
  146.                 end
  147.                
  148.                 if honorKills > KBT_Current_HonorKills then
  149.                     KBT_Current_HonorKills   = honorKills;
  150.                 end
  151.                
  152.                 KBT_Display_HK:SetText( KBTWhiteColor   .. "(KB)\n" ..
  153.                                         KBTTopColor     .. KBT_Current_KillingBlows .. "\n" ..
  154.                                         KBTMiddleColor  .. KBT_Last_KillingBlows .."\n" ..
  155.                                         KBTBottomColor  .. KBT_Total_KillingBlows + KBT_Current_KillingBlows)
  156.                
  157.                 KBT_Display_KB:SetText( KBTWhiteColor   .. "(HK)\n" ..
  158.                                         KBTTopColor     .. KBT_Current_HonorKills .. "\n" ..
  159.                                         KBTMiddleColor  .. KBT_Last_HonorKills .."\n" ..
  160.                                         KBTBottomColor  .. KBT_Total_HonorKills + KBT_Current_HonorKills)
  161.             end
  162.         end
  163.     end
  164. end
  165.  
  166. function KBTracker_CreateMainFrame()
  167.     local backdrop = {
  168.         bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",  -- path to the background texture
  169.         edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",  -- path to the border texture
  170.         tile = false,    -- true to repeat the background texture to fill the frame, false to scale it
  171.         tileSize = 32,  -- size (width or height) of the square repeating background tiles (in pixels)
  172.         edgeSize = 20,  -- thickness of edge segments and square size of edge corners (in pixels)
  173.         insets = {    -- distance from the edges of the frame to those of the background texture (in pixels)
  174.             left = 4,
  175.             right = 4,
  176.             top = 4,
  177.             bottom = 4
  178.         }
  179.     }
  180.    
  181. -- create the frame
  182.     KBT_Display_Frame=CreateFrame("FRAME","KBT_Display_Frame",UIParent);
  183.     KBT_Display_Frame:SetWidth(135);
  184.     KBT_Display_Frame:SetHeight(65);
  185.     KBT_Display_Frame:SetPoint(KBTrackerDBPC["point"],KBTrackerDBPC["x"],KBTrackerDBPC["y"]);
  186.     KBT_Display_Frame:SetBackdrop(backdrop);
  187.     --KBT_Display_Frame:Hide()
  188.    
  189. -- This allows the frame to be moved
  190.     KBT_Display_Frame:SetMovable(true)
  191.     KBT_Display_Frame:EnableMouse(true)
  192.     KBT_Display_Frame:SetScript("OnMouseDown",function()
  193.         KBT_Display_Frame:StartMoving()
  194.     end)
  195.     KBT_Display_Frame:SetScript("OnMouseUp",function()
  196.         KBT_Display_Frame:StopMovingOrSizing()
  197.  
  198.         local point, relativeTo, relativePoint, xOfs, yOfs = KBT_Display_Frame:GetPoint()
  199.         KBTrackerDBPC["point"] = point;
  200.         KBTrackerDBPC["x"] = xOfs;
  201.         KBTrackerDBPC["y"] = yOfs;
  202.     end)
  203.    
  204. -- create the font strings
  205.     KBT_Display_Types =  KBT_Display_Frame:CreateFontString("KBT_Display_Types" ,"ARTWORK","GameFontNormal");
  206.     KBT_Display_Types:SetPoint("TopLeft", KBT_Display_Frame, "TopLeft", 5, -8)
  207.     KBT_Display_Types:SetText(  KBTBlueColor    .. "KBT     \n" ..
  208.                                 KBTTopColor     .. "This BG:\n" ..
  209.                                 KBTMiddleColor  .. "Last BG:\n" ..
  210.                                 KBTBottomColor  .. "Session:")
  211.     KBT_Display_Types:SetJustifyH("Right")
  212.    
  213.     KBT_Display_HK =  KBT_Display_Frame:CreateFontString("KBT_Display_HK" ,"ARTWORK","GameFontNormal");
  214.     KBT_Display_HK:SetPoint("TopLeft", KBT_Display_Frame, "TopLeft", 55, -8)
  215.     KBT_Display_HK:SetText( KBTWhiteColor   .. "(KB)\n" ..
  216.                             KBTTopColor     .. KBT_Current_KillingBlows .. "\n" ..
  217.                             KBTMiddleColor  .. KBT_Last_KillingBlows .."\n" ..
  218.                             KBTBottomColor  .. KBT_Total_KillingBlows)
  219.     KBT_Display_HK:SetJustifyH("Center")
  220.    
  221.     KBT_Display_KB =  KBT_Display_Frame:CreateFontString("KBT_Display_KB" ,"ARTWORK","GameFontNormal");
  222.     KBT_Display_KB:SetPoint("TopLeft", KBT_Display_Frame, "TopLeft", 90, -8)
  223.     KBT_Display_KB:SetText( KBTWhiteColor   .. "(HK)\n" ..
  224.                             KBTTopColor     .. KBT_Current_HonorKills .. "\n" ..
  225.                             KBTMiddleColor  .. KBT_Last_HonorKills .."\n" ..
  226.                             KBTBottomColor  .. KBT_Total_HonorKills)
  227.     KBT_Display_KB:SetJustifyH("Center")
  228. end
  229.  
  230. function KBTracker_Command(cmd)
  231.     if cmd == "center" then
  232.         KBT_Display_Frame:ClearAllPoints();
  233.         KBT_Display_Frame:SetPoint("Center");
  234.     elseif cmd == "show" then
  235.         if KBT_Display_Frame:IsShown() then
  236.             KBT_Display_Frame:Hide();
  237.         else
  238.             KBT_Display_Frame:Show();
  239.         end
  240.     else
  241.         print(KBTBlueColor .. "Killing Blow Tracker")
  242.         print("Commands:")
  243.         print("show - Toggle the tracker frame")
  244.         print("center - Reset the position of the window")
  245.     end
  246. end
  247.  
  248. local KBT_DataObj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("KB Tracker", {
  249.     text = "KBT",
  250.     type = "data source",
  251.     icon = "Interface\\Icons\\spell_deathknight_subversion",
  252.     OnClick = function(clickedframe, button)
  253.         if button == "LeftButton" then
  254.             if KBT_Display_Frame:IsShown() then
  255.                 KBT_Display_Frame:Hide();
  256.             else
  257.                 KBT_Display_Frame:Show();
  258.             end
  259.         elseif button == "RightButton" then
  260.             KBT_Display_Frame:ClearAllPoints();
  261.             KBT_Display_Frame:SetPoint("Center");
  262.         end
  263.     end,
  264. })
  265.  
  266. if KBT_DataObj ~= nil then
  267.  
  268.     function KBT_DataObj:OnTooltipShow()
  269.         self:AddLine(KBTBlueColor .. "Killing Blow Tracker\n\n" .. KBTWhiteColor .. "Left Click: Toggle Window\nRight Click: Recenter Window")
  270.     end
  271.  
  272.     function KBT_DataObj:OnEnter()
  273.         GameTooltip:SetOwner(self, "ANCHOR_NONE")
  274.         GameTooltip:SetPoint("TOPLEFT", self, "BOTTOMLEFT")
  275.         GameTooltip:ClearLines()
  276.         KBT_DataObj.OnTooltipShow(GameTooltip)
  277.         GameTooltip:Show()
  278.     end
  279.  
  280.     function KBT_DataObj:OnLeave()
  281.         GameTooltip:Hide()
  282.     end
  283. end
  Reply With Quote