Thread Tools Display Modes
05-27-21, 08:36 PM   #1
Dixon Butz
A Deviate Faerie Dragon
 
Dixon Butz's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 13
Backdrop Fix Help

I have seen the code change posted for backdrops. I don't have a clue. Can anyone help me fix this very old abandoned addon? It's very small. KBTracker.
Probably and easy fix for those that know .lua I have tried.
Been using it forever. Worked in classic too.

This is the lua error on login:

Code:
Message: Interface\AddOns\KBTracker\KBTracker.lua:169: attempt to index global 'tframe' (a nil value)
Time: Thu May 27 22:32:14 2021
Count: 1
Stack: Interface\AddOns\KBTracker\KBTracker.lua:169: attempt to index global 'tframe' (a nil value)
[string "@Interface\AddOns\KBTracker\KBTracker.lua"]:169: 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> {
 backdropColor = <table> {
 }
 edgeSize = 14
 tileEdge = false
 backdropBorderColor = <table> {
 }
 tileSize = 16
 edgeFile = "Interface\DialogFrame\UI-DialogBox-Border"
 tile = false
 bgFile = "Interface\FrameGeneral\UI-Background-Rock"
 insets = <table> {
 }
}
(*temporary) = nil
(*temporary) = <table> {
 backdropColor = <table> {
 }
 edgeSize = 14
 tileEdge = false
 backdropBorderColor = <table> {
 }
 tileSize = 16
 edgeFile = "Interface\DialogFrame\UI-DialogBox-Border"
 tile = false
 bgFile = "Interface\FrameGeneral\UI-Background-Rock"
 insets = <table> {
 }
}
(*temporary) = 2.500000
(*temporary) = nil
(*temporary) = <table> {
 backdropColor = <table> {
 }
 edgeSize = 14
 tileEdge = false
 backdropBorderColor = <table> {
 }
 tileSize = 16
 edgeFile = "Interface\DialogFrame\UI-DialogBox-Border"
 tile = false
 bgFile = "Interface\FrameGeneral\UI-Background-Rock"
 insets = <table> {
 }
}
(*temporary) = <function> defined =[C]:-1
(*temporary) = <table> {
 backdropColor = <table> {
 }
 bgFile = "Interface\FrameGeneral\UI-Background-Rock"
 tile = false
 backdropBorderColor = <table> {
 }
 tileSize = 16
 edgeFile = "Interface\DialogFrame\UI-DialogBox-Border"
 tileEdge = false
 edgeSize = 14
 insets = <table> {
 }
}
(*temporary) = "insets"
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = <table> {
 top = 2.500000
 right = 2.500000
 left = 2.500000
 bottom = 2.500000
}
(*temporary) = "attempt to index global 'tframe' (a nil value)"
KBTBlueColor = ""
KBTTopColor = ""
KBTMiddleColor = ""
KBTBottomColor = ""
KBTWhiteColor = ""
This is the whole KBTracker.lua


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 f = CreateFrame("Frame", nil, UIParent, BackdropTemplateMixin and "BackdropTemplate")
  168.  
  169.         tile = false,    -- true to repeat the background texture to fill the frame, false to scale it
  170.           -- size (width or height) of the square repeating background tiles (in pixels)
  171.           -- thickness of edge segments and square size of edge corners (in pixels)
  172.             -- distance from the edges of the frame to those of the background texture (in pixels)
  173.  
  174.  
  175.  
  176.  
  177. -- create the frame
  178.     KBT_Display_Frame:SetWidth(135);
  179.     KBT_Display_Frame:SetHeight(65);
  180.     KBT_Display_Frame:SetPoint(KBTrackerDBPC["point"],KBTrackerDBPC["x"],KBTrackerDBPC["y"]);
  181.     KBT_Display_Frame:SetBackdrop(backdrop);
  182.     --KBT_Display_Frame:Hide()
  183.    
  184. -- This allows the frame to be moved
  185.     KBT_Display_Frame:SetMovable(true)
  186.     KBT_Display_Frame:EnableMouse(true)
  187.     KBT_Display_Frame:SetScript("OnMouseDown",function()
  188.         KBT_Display_Frame:StartMoving()
  189.     end)
  190.     KBT_Display_Frame:SetScript("OnMouseUp",function()
  191.         KBT_Display_Frame:StopMovingOrSizing()
  192.  
  193.         local point, relativeTo, relativePoint, xOfs, yOfs = KBT_Display_Frame:GetPoint()
  194.         KBTrackerDBPC["point"] = point;
  195.         KBTrackerDBPC["x"] = xOfs;
  196.         KBTrackerDBPC["y"] = yOfs;
  197.     end)
  198.    
  199. -- create the font strings
  200.     KBT_Display_Types =  KBT_Display_Frame:CreateFontString("KBT_Display_Types" ,"ARTWORK","GameFontNormal");
  201.     KBT_Display_Types:SetPoint("TopLeft", KBT_Display_Frame, "TopLeft", 5, -8)
  202.     KBT_Display_Types:SetText(  KBTBlueColor    .. "KBT     \n" ..
  203.                                 KBTTopColor     .. "This BG:\n" ..
  204.                                 KBTMiddleColor  .. "Last BG:\n" ..
  205.                                 KBTBottomColor  .. "Session:")
  206.     KBT_Display_Types:SetJustifyH("Right")
  207.    
  208.     KBT_Display_HK =  KBT_Display_Frame:CreateFontString("KBT_Display_HK" ,"ARTWORK","GameFontNormal");
  209.     KBT_Display_HK:SetPoint("TopLeft", KBT_Display_Frame, "TopLeft", 55, -8)
  210.     KBT_Display_HK:SetText( KBTWhiteColor   .. "(KB)\n" ..
  211.                             KBTTopColor     .. KBT_Current_KillingBlows .. "\n" ..
  212.                             KBTMiddleColor  .. KBT_Last_KillingBlows .."\n" ..
  213.                             KBTBottomColor  .. KBT_Total_KillingBlows)
  214.     KBT_Display_HK:SetJustifyH("Center")
  215.    
  216.     KBT_Display_KB =  KBT_Display_Frame:CreateFontString("KBT_Display_KB" ,"ARTWORK","GameFontNormal");
  217.     KBT_Display_KB:SetPoint("TopLeft", KBT_Display_Frame, "TopLeft", 90, -8)
  218.     KBT_Display_KB:SetText( KBTWhiteColor   .. "(HK)\n" ..
  219.                             KBTTopColor     .. KBT_Current_HonorKills .. "\n" ..
  220.                             KBTMiddleColor  .. KBT_Last_HonorKills .."\n" ..
  221.                             KBTBottomColor  .. KBT_Total_HonorKills)
  222.     KBT_Display_KB:SetJustifyH("Center")
  223. end
  224.  
  225. function KBTracker_Command(cmd)
  226.     if cmd == "center" then
  227.         KBT_Display_Frame:ClearAllPoints();
  228.         KBT_Display_Frame:SetPoint("Center");
  229.     elseif cmd == "show" then
  230.         if KBT_Display_Frame:IsShown() then
  231.             KBT_Display_Frame:Hide();
  232.         else
  233.             KBT_Display_Frame:Show();
  234.         end
  235.     else
  236.         print(KBTBlueColor .. "Killing Blow Tracker")
  237.         print("Commands:")
  238.         print("show - Toggle the tracker frame")
  239.         print("center - Reset the position of the window")
  240.     end
  241. end
  242.  
  243. local KBT_DataObj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("KB Tracker", {
  244.     text = "KBT",
  245.     type = "data source",
  246.     icon = "Interface\\Icons\\spell_deathknight_subversion",
  247.     OnClick = function(clickedframe, button)
  248.         if button == "LeftButton" then
  249.             if KBT_Display_Frame:IsShown() then
  250.                 KBT_Display_Frame:Hide();
  251.             else
  252.                 KBT_Display_Frame:Show();
  253.             end
  254.         elseif button == "RightButton" then
  255.             KBT_Display_Frame:ClearAllPoints();
  256.             KBT_Display_Frame:SetPoint("Center");
  257.         end
  258.     end,
  259. })
  260.  
  261. if KBT_DataObj ~= nil then
  262.  
  263.     function KBT_DataObj:OnTooltipShow()
  264.         self:AddLine(KBTBlueColor .. "Killing Blow Tracker\n\n" .. KBTWhiteColor .. "Left Click: Toggle Window\nRight Click: Recenter Window")
  265.     end
  266.  
  267.     function KBT_DataObj:OnEnter()
  268.         GameTooltip:SetOwner(self, "ANCHOR_NONE")
  269.         GameTooltip:SetPoint("TOPLEFT", self, "BOTTOMLEFT")
  270.         GameTooltip:ClearLines()
  271.         KBT_DataObj.OnTooltipShow(GameTooltip)
  272.         GameTooltip:Show()
  273.     end
  274.  
  275.     function KBT_DataObj:OnLeave()
  276.         GameTooltip:Hide()
  277.     end
  278. end
  Reply With Quote
05-27-21, 09:27 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
There's no mention of tframe in the code you posted and the error and the code don't seem to match up.

Maybe the error and the code are from different clients? Error in Classic, code from Retail or some other combination?
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
05-28-21, 03:44 AM   #3
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
I concur with Fizzle. I even tried looking for the addon to look at the code in its completeness but it isn't on here or Curse.

Did you copy ALL of the code from KBTracker.lua ? Or block by block ? Maybe you missed a few lines out unknowingly or deliberately thinking it wasn't relevant.
__________________
  Reply With Quote
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
05-28-21, 08:08 AM   #5
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Line 182 should be changed from

Lua Code:
  1. KBT_Display_Frame=CreateFrame("FRAME","KBT_Display_Frame",UIParent);

to be

Lua Code:
  1. KBT_Display_Frame=CreateFrame("FRAME","KBT_Display_Frame",UIParent, BackdropTemplateMixin and "BackdropTemplate");
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
05-28-21, 09:13 AM   #6
Dixon Butz
A Deviate Faerie Dragon
 
Dixon Butz's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 13
Originally Posted by Fizzlemizz View Post
Line 182 should be changed from

Lua Code:
  1. KBT_Display_Frame=CreateFrame("FRAME","KBT_Display_Frame",UIParent);

to be

Lua Code:
  1. KBT_Display_Frame=CreateFrame("FRAME","KBT_Display_Frame",UIParent, BackdropTemplateMixin and "BackdropTemplate");
That is genius! Thx so much!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Backdrop Fix Help

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