Thread Tools Display Modes
08-16-16, 04:24 PM   #1
badness
A Cliff Giant
 
badness's Avatar
Join Date: May 2010
Posts: 74
caelNameplates

Hey guys, so since pre-patch as you know nameplates have changed a huge amount so I've decided to finally take on updating it and take over the addon. I'm still learning lua but I can mostly find my way around and I would appreciate some guidance in updating this addon.
Here is the code for the addon:
Lua Code:
  1. local addonName, ns = ...
  2.  
  3. local caelNamePlates = CreateFrame("Frame", nil, UIParent)
  4. caelNamePlates:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end)
  5.  
  6. --if not IsAddOnLoaded("caelCore") then
  7.     SetCVar("bloattest", 0) -- 1 might make nameplates larger but it fixes the disappearing ones.
  8.     SetCVar("bloatnameplates", 0) -- 1 makes nameplates larger depending on threat percentage.
  9.     SetCVar("bloatthreat", 0) -- 1 makes nameplates resize depending on threat gain/loss. Only active when a mob has multiple units on its threat table.
  10. --end
  11. --[[
  12. local barTexture = caelMedia.files.statusBarC
  13. local iconTexture = caelMedia.files.buttonNormal
  14. local raidIcons = caelMedia.files.raidIcons
  15. local overlayTexture = [=[Interface\Tooltips\Nameplate-Border]=]
  16. local font, fontSize, fontOutline = caelMedia.fonts.CAELNAMEPLATE_FONT, 8
  17. ]]
  18. local barTexture = [=[Interface\AddOns\caelNameplates\media\normtexc]=]
  19. --local iconTexture = [=[Interface\AddOns\caelNameplates\media\buttonnormal]=]
  20. local raidIcons = [=[Interface\AddOns\caelNameplates\media\raidicons]=]
  21. local overlayTexture = [=[Interface\Tooltips\Nameplate-Border]=]
  22. --local font, fontSize, fontOutline = caelMedia.fonts.CAELNAMEPLATE_FONT, 8
  23. local font = STANDARD_TEXT_FONT
  24. local fontSize = 10
  25. local fontOutline = "THINOUTLINE"
  26.  
  27. local backdrop = {
  28.         bgFile   =  [=[Interface\ChatFrame\ChatFrameBackground]=],
  29.         edgeFile =  [=[Interface\AddOns\caelNameplates\media\glowTex3]=],
  30.         edgeSize =  2,
  31.         insets   =  { left = 2, right = 2, top = 2, bottom = 2 },
  32.     }
  33.  
  34. local select = select
  35.  
  36. --local pixelScale = caelLib.scale
  37.  
  38. local UpdateTime = function(self, curValue)
  39.     local minValue, maxValue = self:GetMinMaxValues()
  40.     if self.channeling then
  41.         self.time:SetFormattedText("%.1f ", curValue)
  42.     else
  43.         self.time:SetFormattedText("%.1f ", maxValue - curValue)
  44.     end
  45. end
  46.  
  47. local ThreatUpdate = function(self, elapsed)
  48.     self.elapsed = self.elapsed + elapsed
  49.     if self.elapsed >= 0.2 then
  50.         if not self.oldglow:IsShown() then
  51.             self.healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)
  52.         else
  53.             local r, g, b = self.oldglow:GetVertexColor()
  54.             if g + b == 0 then
  55.                 self.healthBar.hpGlow:SetBackdropBorderColor(1, 0, 0)
  56.             else
  57.                 self.healthBar.hpGlow:SetBackdropBorderColor(1, 1, 0)
  58.             end
  59.         end
  60.  
  61.         self.healthBar:SetStatusBarColor(self.r, self.g, self.b)
  62.  
  63.         self.elapsed = 0
  64.     end
  65. end
  66.  
  67. local UpdatePlate = function(self)
  68.     local r, g, b = self.healthBar:GetStatusBarColor()
  69.     local newr, newg, newb
  70.     if g + b == 0 then
  71.         -- Hostile unit
  72.         newr, newg, newb = 1, 0.1, 0.1
  73.         self.healthBar:SetStatusBarColor(1, 0.1, 0.1)
  74.     elseif r + b == 0 then
  75.         -- Friendly unit
  76.         newr, newg, newb = 0.1, 1, 0.1
  77.         self.healthBar:SetStatusBarColor(0.1, 1, 0.1)
  78.     elseif r + g == 0 then
  79.         -- Friendly player
  80.         newr, newg, newb = 0.31, 0.45, 0.63
  81.         self.healthBar:SetStatusBarColor(0.31, 0.45, 0.63)
  82.     elseif 2 - (r + g) < 0.05 and b == 0 then
  83.         -- Neutral unit
  84.         newr, newg, newb = 1, 1, 0 --0.86, 0.83, 0.47
  85.         self.healthBar:SetStatusBarColor(1, 1, 0)
  86.     else
  87.         -- Hostile player - class colored.
  88.         newr, newg, newb = r, g, b 
  89.     end
  90.  
  91.     self.r, self.g, self.b = newr, newg, newb
  92.  
  93.     self.healthBar:ClearAllPoints()
  94.     self.healthBar:SetPoint("CENTER", self.healthBar:GetParent())
  95.     self.healthBar:SetHeight(7)
  96.     self.healthBar:SetWidth(100)
  97.  
  98.     self.healthBar.hpBackground:SetVertexColor(self.r * 0.22, self.g * 0.22, self.b * 0.22, 18)
  99.     self.castBar.IconOverlay:SetVertexColor(self.r, self.g, self.b)
  100.  
  101.     self.castBar:ClearAllPoints()
  102.     self.castBar:SetPoint("TOP", self.healthBar, "BOTTOM", 0, -5)
  103.     self.castBar:SetHeight(4)
  104.     self.castBar:SetWidth(100)
  105.  
  106.     self.highlight:ClearAllPoints()
  107.     self.highlight:SetAllPoints(self.healthBar)
  108.  
  109.     local oldName = self.oldname:GetText()
  110.     local newName = (string.len(oldName) > 20) and string.gsub(oldName, "%s?(.[\128-\191]*)%S+%s", "%1. ") or oldName -- "%s?(.)%S+%s"
  111.  
  112.     self.name:SetText(newName)
  113.  
  114.     local level, elite, mylevel = tonumber(self.level:GetText()), self.elite:IsShown(), UnitLevel("player")
  115.     self.level:ClearAllPoints()
  116.     self.level:SetPoint("RIGHT", self.healthBar, "LEFT", -1, 1)
  117.     if self.boss:IsShown() then
  118.         self.level:SetText("B")
  119.         self.level:SetTextColor(0.8, 0.05, 0)
  120.         self.level:Show()
  121.     elseif not elite and level == mylevel then
  122.         self.level:Hide()
  123.     else
  124.         self.level:SetText(level..(elite and "+" or ""))
  125.     end
  126. end
  127.  
  128. local FixCastbar = function(self)
  129.     self.castbarOverlay:Hide()
  130.  
  131.     self:SetHeight(3)
  132.     self:ClearAllPoints()
  133.     self:SetPoint("TOP", self.healthBar, "BOTTOM", 0, -5)
  134. end
  135.  
  136. local ColorCastBar = function(self, shielded)
  137.     if shielded then
  138.         self:SetStatusBarColor(0.8, 0.05, 0)
  139.         self.cbGlow:SetBackdropBorderColor(0.75, 0.75, 0.75)
  140.     else
  141.         self.cbGlow:SetBackdropBorderColor(0, 0, 0)
  142.     end
  143. end
  144.  
  145. local OnSizeChanged = function(self, width, height)
  146.     if floor(height) ~= 3 then
  147.         self.needFix = true
  148.     end
  149. end
  150.  
  151. local OnShow = function(self)
  152.     self.channeling  = UnitChannelInfo("target")
  153.  
  154.     if self.needFix then
  155.         FixCastbar(self)
  156.         if floor(self:GetHeight()) ~= 3 then
  157. --          print("B) wrong size "..floor(self:GetHeight()))
  158.         end
  159.     end
  160.  
  161.     ColorCastBar(self, self.shieldedRegion:IsShown())
  162.     self.IconOverlay:Show()
  163. end
  164.  
  165. local OnValueChanged = function(self, curValue)
  166.     UpdateTime(self, curValue)
  167.  
  168.     if self.needFix then
  169.         FixCastbar(self)
  170.         if floor(self:GetHeight()) ~= 5 then
  171. --          print("C) wrong size "..floor(self:GetHeight()))
  172.         end
  173.         self.needFix = nil
  174.     end
  175. end
  176.  
  177. local OnHide = function(self)
  178.     self.highlight:Hide()
  179.     self.healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)
  180. end
  181.  
  182. local OnEvent = function(self, event, unit)
  183.     if unit == "target" then
  184.         if self:IsShown() then
  185.             ColorCastBar(self, event == "UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
  186.         end
  187.     end
  188. end
  189.  
  190. local CreatePlate = function(frame)
  191.      
  192.     frame.done = true
  193.    
  194.     frame.barFrame, frame.nameFrame = frame:GetChildren()
  195.     frame.healthBar, frame.absorbBar, frame.castBar = frame.barFrame:GetChildren()
  196.  
  197.     local healthBar, castBar = frame.healthBar, frame.castBar
  198.     local glowRegion, overlayRegion, highlightRegion, levelTextRegion, bossIconRegion, raidIconRegion, stateIconRegion = frame.barFrame:GetRegions()
  199.     local _, castbarOverlay, shieldedRegion, spellIconRegion = castBar:GetRegions()
  200.     local nameTextRegion = frame.nameFrame:GetRegions()
  201.  
  202.     frame.oldname = nameTextRegion
  203.     nameTextRegion:Hide()
  204.  
  205.     local newNameRegion = frame:CreateFontString()
  206.     newNameRegion:SetPoint("CENTER", healthBar, "CENTER", 0, 10)
  207.     newNameRegion:SetFont(font, fontSize, fontOutline)
  208.     newNameRegion:SetTextColor(0.84, 0.75, 0.65)
  209.     newNameRegion:SetShadowOffset(1.25, -1.25)
  210.     frame.name = newNameRegion
  211.  
  212.     frame.level = levelTextRegion
  213.     levelTextRegion:SetFont(font, fontSize, fontOutline)
  214.     levelTextRegion:SetShadowOffset(1.25, -1.25)
  215.  
  216.     healthBar:SetStatusBarTexture(barTexture)
  217.  
  218.     healthBar.hpBackground = healthBar:CreateTexture(nil, "BACKGROUND")
  219.     healthBar.hpBackground:SetAllPoints()
  220.     healthBar.hpBackground:SetTexture(barTexture)
  221.  
  222.     healthBar.hpGlow = CreateFrame("Frame", nil, healthBar)
  223.     healthBar.hpGlow:SetFrameLevel(healthBar:GetFrameLevel() -1 > 0 and healthBar:GetFrameLevel() -1 or 0)
  224.     healthBar.hpGlow:SetPoint("TOPLEFT", healthBar, "TOPLEFT", -2, 2)
  225.     healthBar.hpGlow:SetPoint("BOTTOMRIGHT", healthBar, "BOTTOMRIGHT", 2, -2)
  226.     healthBar.hpGlow:SetBackdrop(backdrop)
  227.     healthBar.hpGlow:SetBackdropColor(0, 0, 0, 0)
  228.     healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)
  229.  
  230.     castBar.castbarOverlay = castbarOverlay
  231.     castBar.healthBar = healthBar
  232.     castBar.shieldedRegion = shieldedRegion
  233.     castBar:SetStatusBarTexture(barTexture)
  234.  
  235.     castBar:HookScript("OnShow", OnShow)
  236.     castBar:HookScript("OnSizeChanged", OnSizeChanged)
  237.     castBar:HookScript("OnValueChanged", OnValueChanged)
  238.     castBar:HookScript("OnEvent", OnEvent)
  239.     castBar:RegisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE")
  240.     castBar:RegisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
  241.  
  242.     castBar.time = castBar:CreateFontString(nil, "ARTWORK")
  243.     castBar.time:SetPoint("RIGHT", castBar, "LEFT", -2, 0)
  244.     castBar.time:SetFont(font, fontSize, fontOutline)
  245.     castBar.time:SetTextColor(0.84, 0.75, 0.65)
  246.     castBar.time:SetShadowOffset(1.25, -1.25)
  247.  
  248.     castBar.cbBackground = castBar:CreateTexture(nil, "BACKGROUND")
  249.     castBar.cbBackground:SetAllPoints()
  250.     castBar.cbBackground:SetTexture(barTexture)
  251.     castBar.cbBackground:SetVertexColor(0.25, 0.25, 0.25, 0.75)
  252.  
  253.     castBar.cbGlow = CreateFrame("Frame", nil, castBar)
  254.     castBar.cbGlow:SetFrameLevel(castBar:GetFrameLevel() -1 > 0 and castBar:GetFrameLevel() -1 or 0)
  255.     castBar.cbGlow:SetPoint("TOPLEFT", castBar, -2, 2)
  256.     castBar.cbGlow:SetPoint("BOTTOMRIGHT", castBar, 2, -2)
  257.     castBar.cbGlow:SetBackdrop(backdrop)
  258.     castBar.cbGlow:SetBackdropColor(0, 0, 0, 0)
  259.     castBar.cbGlow:SetBackdropBorderColor(0, 0, 0)
  260.  
  261.     castBar.HolderA = CreateFrame("Frame", nil, castBar)
  262.     castBar.HolderA:SetFrameLevel(castBar.HolderA:GetFrameLevel() + 1)
  263.     castBar.HolderA:SetAllPoints()
  264.  
  265.     spellIconRegion:ClearAllPoints()
  266.     spellIconRegion:SetParent(castBar.HolderA)
  267.     spellIconRegion:SetPoint("LEFT", castBar, 8, 0)
  268.     spellIconRegion:SetSize(0.1, 0.1)
  269.  
  270.     castBar.HolderB = CreateFrame("Frame", nil, castBar)
  271.     castBar.HolderB:SetFrameLevel(castBar.HolderA:GetFrameLevel() + 2)
  272.     castBar.HolderB:SetAllPoints()
  273.  
  274.     castBar.IconOverlay = castBar.HolderB:CreateTexture(nil, "OVERLAY")
  275.     castBar.IconOverlay:SetPoint("TOPLEFT", spellIconRegion, -1.5, 1.5)
  276.     castBar.IconOverlay:SetPoint("BOTTOMRIGHT", spellIconRegion, 1.5, -1.5)
  277.     castBar.IconOverlay:SetTexture(iconTexture)
  278.  
  279.     highlightRegion:SetTexture(barTexture)
  280.     highlightRegion:SetVertexColor(0.25, 0.25, 0.25)
  281.     frame.highlight = highlightRegion
  282.  
  283.     raidIconRegion:ClearAllPoints()
  284.     raidIconRegion:SetPoint("RIGHT", healthBar, 25, 2)
  285.     raidIconRegion:SetSize(20, 20)
  286.     raidIconRegion:SetTexture(raidIcons)   
  287.  
  288.     frame.oldglow = glowRegion
  289.     frame.elite = stateIconRegion
  290.     frame.boss = bossIconRegion
  291.  
  292.     glowRegion:SetTexture(nil)
  293.     overlayRegion:SetTexture(nil)
  294.     shieldedRegion:SetTexture(nil)
  295.     castbarOverlay:SetTexture(nil)
  296.     stateIconRegion:SetAlpha(0)
  297.     bossIconRegion:SetTexture(nil)
  298.  
  299.     UpdatePlate(frame)
  300.     frame:SetScript("OnShow", UpdatePlate)
  301.     frame:SetScript("OnHide", OnHide)
  302.  
  303.     frame.elapsed = 0
  304.     frame:SetScript("OnUpdate", ThreatUpdate)
  305. end
  306. --[[
  307. local CheckFrames = function(num, ...)
  308.     for i = 1, num do
  309.         local frame = select(i, ...)
  310.         if frame:GetName() and frame:GetName():find("NamePlate%d") and not frame.done then
  311.             CreatePlate(frame)
  312.             frame.done = true
  313.         end
  314.     end
  315. end
  316. ]]
  317. local numKids = 0
  318. local lastUpdate = 0
  319. local index = 1
  320. local OnUpdate = function(self, elapsed)
  321.     lastUpdate = lastUpdate + elapsed
  322.  
  323.     if lastUpdate > 0.1 then
  324.         lastUpdate = 0
  325.  
  326.         local newNumKids = WorldFrame:GetNumChildren()
  327.         if newNumKids ~= numKids then
  328.             numKids = WorldFrame:GetNumChildren()
  329.             for i = index, numKids do
  330.                 local frame = select(i, WorldFrame:GetChildren())
  331.                 local name = frame:GetName()
  332.  
  333.                 if name and name:find("NamePlate") and not frame.done then
  334.                     --StyleFrame(frame)
  335.                     CreatePlate(frame)
  336.                     index = i
  337.                 end
  338.             end
  339.         end
  340.     end
  341. end
  342. caelNamePlates:SetScript("OnUpdate", OnUpdate)
  343. --[[
  344. caelNameplates.eventFrame:SetScript("OnUpdate", function(self, elapsed)
  345.     lastUpdate = lastUpdate + elapsed
  346.  
  347.     if lastUpdate > 0.1 then
  348.         local newNumKids = WorldFrame:GetNumChildren()
  349.  
  350.         if newNumKids ~= numKids then
  351.             CheckFrames(newNumKids, WorldFrame:GetChildren())
  352.  
  353.             for i = numKids + 1, newNumKids do
  354.                 local frame = select(i, WorldFrame:GetChildren())
  355.  
  356.                 if frame:GetName() and frame:GetName():find("NamePlate%d") then
  357.                     CreatePlate(frame)
  358.                 end
  359.             end
  360.  
  361.             numKids = newNumKids
  362.         end
  363.         lastUpdate = 0
  364.     end
  365. end)]]
  366. --[[
  367. caelNameplates.eventFrame:SetScript("OnEvent", function(self, event, ...)
  368.     if type(self[event]) == "function" then
  369.         return self[event](self, event, ...)
  370.     end
  371. end)
  372.  
  373. function caelNameplates.eventFrame:PLAYER_REGEN_ENABLED()
  374.     SetCVar("nameplateShowEnemies", 0)
  375. end
  376.  
  377. function caelNameplates.eventFrame:PLAYER_REGEN_DISABLED()
  378.     SetCVar("nameplateShowEnemies", 1)
  379. end
  380.  
  381. caelNameplates.eventFrame:RegisterEvent("ADDON_LOADED")
  382. function caelNameplates.eventFrame:ADDON_LOADED(event, addon)
  383.     if addon and addon:lower() == "caelnameplates" then
  384.         if not caelNameplatesDB then
  385.             caelNameplatesDB = {autotoggle = true}
  386.         end
  387.        
  388.         caelNameplates.settings = caelNameplatesDB
  389.        
  390.         if caelNameplates.settings.autotoggle then
  391.             self:RegisterEvent("PLAYER_REGEN_ENABLED")
  392.             self:RegisterEvent("PLAYER_REGEN_DISABLED")
  393.         end
  394.     end
  395. end
  396.  
  397. SlashCmdList["caelNameplates"] = function(parameters)
  398.     if parameters == "autotoggle" then
  399.         local newsetting = not caelNameplates.settings.autotoggle
  400.         caelNameplates.settings.autotoggle = newsetting
  401.        
  402.         local func = newsetting and "RegisterEvent" or "UnregisterEvent"
  403.        
  404.         caelNameplates.eventFrame[func](caelNameplates.eventFrame, "PLAYER_REGEN_ENABLED")
  405.         caelNameplates.eventFrame[func](caelNameplates.eventFrame, "PLAYER_REGEN_DISABLED")
  406.         print("Auto toggling of nameplates based on combat state " .. (caelNameplates.settings.autotoggle and "|cff00ff00enabled|r." or "|cffff0000disabled|r."))
  407.     end
  408. end
  409.  
  410. SLASH_caelNameplates1 = "/caelnameplates"
  411. ]]
It isn't showing when enabled and it isn't giving any lua errors, so I assume the first step would be to change all the SetTextures to SetVertexColor but after that I'm pretty much lost. What would be my next step after that?
  Reply With Quote
08-16-16, 04:44 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
I'm not sure your debugger is working, this is the error I got:

Code:
1x caelNamePlate\caelNamePlate.lua:7: Couldn't find CVar named 'bloattest'
[C]: in function `SetCVar'
caelNamePlate\caelNamePlate.lua:7: in main chunk

Locals:
(*temporary) = "bloattest"
(*temporary) = 0
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-16-16, 05:55 PM   #3
badness
A Cliff Giant
 
badness's Avatar
Join Date: May 2010
Posts: 74
Yea funny enough I just got that error but wasn't showing before...strange. How can I fix it?
  Reply With Quote
08-17-16, 04:31 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can't "fix" it -- that CVar just doesn't exist anymore. Your only option is to remove the line that tries to set its value. I'm pretty sure all 3 of those CVars have been removed, not just the first one.
__________________
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
08-17-16, 05:30 AM   #5
badness
A Cliff Giant
 
badness's Avatar
Join Date: May 2010
Posts: 74
Got this after that:
Code:
Message: Interface\AddOns\caelNameplates\caelNamePlates.lua:202: attempt to index field 'nameFrame' (a nil value)
Time: 08/17/16 07:28:50
Count: 1
Stack: Interface\AddOns\caelNameplates\caelNamePlates.lua:202: in function <Interface\AddOns\caelNameplates\caelNamePlates.lua:192>
Interface\AddOns\caelNameplates\caelNamePlates.lua:337: in function <Interface\AddOns\caelNameplates\caelNamePlates.lua:322>

Locals: frame = NamePlate1 {
 namePlateUnitToken = "nameplate1"
 driverFrame = NamePlateDriverFrame {
 }
 UnitFrame = NamePlate1UnitFrame {
 }
 done = true
 ApplyOffsets = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:288
 castBar = <unnamed> {
 }
 healthBar = <unnamed> {
 }
 OnRemoved = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:275
 OnAdded = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:266
 absorbBar = <unnamed> {
 }
 barFrame = NamePlate1UnitFrame {
 }
 0 = <userdata>
 OnOptionsUpdated = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:282
}
healthBar = <unnamed> {
 0 = <userdata>
 r = 0.99999779462814
 otherHealPrediction = <unnamed> {
 }
 overAbsorbGlow = <unnamed> {
 }
 g = 0.99999779462814
 barTexture = <unnamed> {
 }
 totalAbsorbOverlay = <unnamed> {
 }
 b = 0
 myHealAbsorbLeftShadow = <unnamed> {
 }
 myHealAbsorb = <unnamed> {
 }
 myHealPrediction = <unnamed> {
 }
 border = <unnamed> {
 }
 totalAbsorb = <unnamed> {
 }
 background = <unnamed> {
 }
 overHealAbsorbGlow = <unnamed> {
 }
 myHealAbsorbRightShadow = <unnamed> {
 }
}
castBar = <unnamed> {
 0 = <userdata>
 GetPadding = <function> defined @Interface\SharedXML\LayoutFrame.lua:9
 GetBaseYOffset = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:345
 SetTargetYOffset = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:333
 CalculateFrameSize = <function> defined @Interface\SharedXML\LayoutFrame.lua:27
 AddLayoutChildren = <function> defined @Interface\SharedXML\LayoutFrame.lua:18
 spacing = 4
 fixedHeight = 14
 OnUpdate = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:325
 GetTargetYOffset = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:337
 targetYOffset = 0
 OnLoad = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:311
 UpdateAnchor = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:349
 Layout = <function> defined @Interface\SharedXML\LayoutFrame.lua:56
 UpdateBuffs = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:367
 OnEvent = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:319
 unit = "nameplate1"
 BuffFrameUpdateTime = 0.2
 baseYOffset = 0
 filter = "HARMFUL|INCLUDE_NAME_PLATE_ONLY"
 buffList = <table> {
 }
 LayoutChildren = <function> defined @Interface\SharedXML\LayoutFrame.lua:130
 SetBaseYOffset = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:341
 ShouldShowBuff = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:359
}
glowRegion = <unnamed> {
 0 = <userdata>
}
overlayRegion = <unnamed> {
 0 = <userdata>
}
highlightRegion = nil
levelTextRegion = nil
bossIconRegion = nil
raidIconRegion = nil
stateIconRegion = nil
_ = nil
castbarOverlay = nil
shieldedRegion = nil
spellIconRegion = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = "attempt to index field 'nameFrame' (a nil value)"
font = "Fonts\FRIZQT__.TTF"
fontSize = 10
fontOutline = "THINOUTLINE"
barTexture = "Interface\AddOns\caelNameplates\media\normtexc"
backdrop = <table> {
 insets = <table> {
 }
 bgFile = "Interface\ChatFrame\ChatFrameBackground"
 edgeSize = 2
 edgeFile = "Interface\AddOns\caelNameplat
  Reply With Quote
08-17-16, 06:13 AM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Short version:
It's probably easier just to delete everything and start over from scratch, since you're going to have to rewrite 90% of your code anyway.

Long version:

This is not how you identify nameplate children/regions anymore:

lua Code:
  1. frame.barFrame, frame.nameFrame = frame:GetChildren()
  2.     frame.healthBar, frame.absorbBar, frame.castBar = frame.barFrame:GetChildren()
  3.  
  4.     local healthBar, castBar = frame.healthBar, frame.castBar
  5.     local glowRegion, overlayRegion, highlightRegion, levelTextRegion, bossIconRegion, raidIconRegion, stateIconRegion = frame.barFrame:GetRegions()
  6.     local _, castbarOverlay, shieldedRegion, spellIconRegion = castBar:GetRegions()
  7.     local nameTextRegion = frame.nameFrame:GetRegions()

All of the objects on a nameplate are accessible through named keys now. See here:
https://www.townlong-yak.com/framexm...Plates.xml#289

This is no longer relevant either:
lua Code:
  1. local numKids = 0
  2. local lastUpdate = 0
  3. local index = 1
  4. local OnUpdate = function(self, elapsed)
  5.     lastUpdate = lastUpdate + elapsed
  6.  
  7.     if lastUpdate > 0.1 then
  8.         lastUpdate = 0
  9.  
  10.         local newNumKids = WorldFrame:GetNumChildren()
  11.         if newNumKids ~= numKids then
  12.             numKids = WorldFrame:GetNumChildren()
  13.             for i = index, numKids do
  14.                 local frame = select(i, WorldFrame:GetChildren())
  15.                 local name = frame:GetName()
  16.  
  17.                 if name and name:find("NamePlate") and not frame.done then
  18.                     --StyleFrame(frame)
  19.                     CreatePlate(frame)
  20.                     index = i
  21.                 end
  22.             end
  23.         end
  24.     end
  25. end
  26. caelNamePlates:SetScript("OnUpdate", OnUpdate)

This should work now:

lua Code:
  1. hooksecurefunc(NamePlateDriverFrame, "OnNamePlateCreated", function(_, frame)
  2.     CreatePlate(frame.UnitFrame)
  3. end)
  4.  
  5. hooksecurefunc(NamePlateDriverFrame, "ApplyFrameOptions", function(_, frame, unit)
  6.     UpdatePlate(frame.UnitFrame)
  7. end)

Other changes you'll need to make:

Your "CreatePlate" function should only create any new objects you want to add. It should not:

- assign existing objects to keys (eg. don't write "nameplate.healthBar = <something>")
- overwrite existing keys (look what exists before adding keys for your custom objects)

Your "UpdatePlate" function will need to be updated to refer to the existing keys for default objects.
__________________
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
08-18-16, 05:35 PM   #7
badness
A Cliff Giant
 
badness's Avatar
Join Date: May 2010
Posts: 74
Originally Posted by Phanx View Post
Short version:
It's probably easier just to delete everything and start over from scratch, since you're going to have to rewrite 90% of your code anyway.

Long version:

This is not how you identify nameplate children/regions anymore:

lua Code:
  1. frame.barFrame, frame.nameFrame = frame:GetChildren()
  2.     frame.healthBar, frame.absorbBar, frame.castBar = frame.barFrame:GetChildren()
  3.  
  4.     local healthBar, castBar = frame.healthBar, frame.castBar
  5.     local glowRegion, overlayRegion, highlightRegion, levelTextRegion, bossIconRegion, raidIconRegion, stateIconRegion = frame.barFrame:GetRegions()
  6.     local _, castbarOverlay, shieldedRegion, spellIconRegion = castBar:GetRegions()
  7.     local nameTextRegion = frame.nameFrame:GetRegions()

All of the objects on a nameplate are accessible through named keys now. See here:
https://www.townlong-yak.com/framexm...Plates.xml#289

This is no longer relevant either:
lua Code:
  1. local numKids = 0
  2. local lastUpdate = 0
  3. local index = 1
  4. local OnUpdate = function(self, elapsed)
  5.     lastUpdate = lastUpdate + elapsed
  6.  
  7.     if lastUpdate > 0.1 then
  8.         lastUpdate = 0
  9.  
  10.         local newNumKids = WorldFrame:GetNumChildren()
  11.         if newNumKids ~= numKids then
  12.             numKids = WorldFrame:GetNumChildren()
  13.             for i = index, numKids do
  14.                 local frame = select(i, WorldFrame:GetChildren())
  15.                 local name = frame:GetName()
  16.  
  17.                 if name and name:find("NamePlate") and not frame.done then
  18.                     --StyleFrame(frame)
  19.                     CreatePlate(frame)
  20.                     index = i
  21.                 end
  22.             end
  23.         end
  24.     end
  25. end
  26. caelNamePlates:SetScript("OnUpdate", OnUpdate)

This should work now:

lua Code:
  1. hooksecurefunc(NamePlateDriverFrame, "OnNamePlateCreated", function(_, frame)
  2.     CreatePlate(frame.UnitFrame)
  3. end)
  4.  
  5. hooksecurefunc(NamePlateDriverFrame, "ApplyFrameOptions", function(_, frame, unit)
  6.     UpdatePlate(frame.UnitFrame)
  7. end)

Other changes you'll need to make:

Your "CreatePlate" function should only create any new objects you want to add. It should not:

- assign existing objects to keys (eg. don't write "nameplate.healthBar = <something>")
- overwrite existing keys (look what exists before adding keys for your custom objects)

Your "UpdatePlate" function will need to be updated to refer to the existing keys for default objects.
I figured it would be a difficult task as a beginner but I really love this addon and want to make it work before legion launch also it might be abit easier to read through someone's code and edit and change rather than rewrite.

I've removed the parts you told me were irrelevant and added the function you gave, now I'm working on the CreatePlate function, since it shouldn't assign existing objects do I just remove all of the "nameplate.healthBar = <something>" or assign them differently?

As for overwriting existing keys which ones do I have overwritten?
  Reply With Quote
08-18-16, 08:35 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by badness View Post
... since it shouldn't assign existing objects do I just remove all of the "nameplate.healthBar = <something>" or assign them differently?
If <something> there was a health bar, just remove that -- there's already a health bar, so you don't need to create anything for that, and it's already under the "healthBar" key, so you don't need to assign it to a key.

Originally Posted by badness View Post
As for overwriting existing keys which ones do I have overwritten?
I don't know all the nameplate child key names off the top of my head. You'll have to go through the default nameplate code and see what's there. If you are overwriting anything it should also be fairly obvious in-game (once the addon is actually loading without errors).
__________________
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
08-19-16, 04:18 PM   #9
badness
A Cliff Giant
 
badness's Avatar
Join Date: May 2010
Posts: 74
Lua Code:
  1. --[[    $Id: caelNameplates.lua 2819 2012-11-30 11:03:27Z [email][email protected][/email] $    ]]
  2.  
  3. local addonName, ns = ...
  4.  
  5. local caelNamePlates = CreateFrame("Frame", nil, UIParent)
  6. caelNamePlates:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end)
  7.  
  8. --[[ if not IsAddOnLoaded("caelCore") then
  9.     --SetCVar("bloattest", 0) -- 1 might make nameplates larger but it fixes the disappearing ones.
  10.     --SetCVar("bloatnameplates", 0) -- 1 makes nameplates larger depending on threat percentage.
  11.     --SetCVar("bloatthreat", 0) -- 1 makes nameplates resize depending on threat gain/loss. Only active when a mob has multiple units on its threat table.
  12. --end
  13.  
  14. local barTexture = caelMedia.files.statusBarC
  15. local iconTexture = caelMedia.files.buttonNormal
  16. local raidIcons = caelMedia.files.raidIcons
  17. local overlayTexture = [=[Interface\Tooltips\Nameplate-Border]=]
  18. local font, fontSize, fontOutline = caelMedia.fonts.CAELNAMEPLATE_FONT, 8
  19. --]]
  20. local barTexture = [=[Interface\AddOns\caelNameplates\media\normtexc]=]
  21. --local iconTexture = [=[Interface\AddOns\caelNameplates\media\buttonnormal]=]
  22. local raidIcons = [=[Interface\AddOns\caelNameplates\media\raidicons]=]
  23. local overlayTexture = [=[Interface\Tooltips\Nameplate-Border]=]
  24. --local font, fontSize, fontOutline = caelMedia.fonts.CAELNAMEPLATE_FONT, 8
  25. local font = STANDARD_TEXT_FONT
  26. local fontSize = 10
  27. local fontOutline = "THINOUTLINE"
  28.  
  29. local backdrop = {
  30.         bgFile   =  [=[Interface\ChatFrame\ChatFrameBackground]=],
  31.         edgeFile =  [=[Interface\AddOns\caelNameplates\media\glowTex3]=],
  32.         edgeSize =  2,
  33.         insets   =  { left = 2, right = 2, top = 2, bottom = 2 },
  34.     }
  35.  
  36. local select = select
  37.  
  38. --local pixelScale = caelLib.scale
  39.  
  40. local UpdateTime = function(self, curValue)
  41.     local minValue, maxValue = self:GetMinMaxValues()
  42.     if self.channeling then
  43.         self.time:SetFormattedText("%.1f ", curValue)
  44.     else
  45.         self.time:SetFormattedText("%.1f ", maxValue - curValue)
  46.     end
  47. end
  48.  
  49. local ThreatUpdate = function(self, elapsed)
  50.     self.elapsed = self.elapsed + elapsed
  51.     if self.elapsed >= 0.2 then
  52.         if not self.oldglow:IsShown() then
  53.             self.healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)
  54.         else
  55.             local r, g, b = self.oldglow:GetVertexColor()
  56.             if g + b == 0 then
  57.                 self.healthBar.hpGlow:SetBackdropBorderColor(1, 0, 0)
  58.             else
  59.                 self.healthBar.hpGlow:SetBackdropBorderColor(1, 1, 0)
  60.             end
  61.         end
  62.  
  63.         self.healthBar:SetStatusBarColor(self.r, self.g, self.b)
  64.  
  65.         self.elapsed = 0
  66.     end
  67. end
  68.  
  69. local UpdatePlate = function(self)
  70.     local r, g, b = self.healthBar:GetStatusBarColor()
  71.     local newr, newg, newb
  72.     if g + b == 0 then
  73.         -- Hostile unit
  74.         newr, newg, newb = 1, 0.1, 0.1
  75.         self.healthBar:SetStatusBarColor(1, 0.1, 0.1)
  76.     elseif r + b == 0 then
  77.         -- Friendly unit
  78.         newr, newg, newb = 0.1, 1, 0.1
  79.         self.healthBar:SetStatusBarColor(0.1, 1, 0.1)
  80.     elseif r + g == 0 then
  81.         -- Friendly player
  82.         newr, newg, newb = 0.31, 0.45, 0.63
  83.         self.healthBar:SetStatusBarColor(0.31, 0.45, 0.63)
  84.     elseif 2 - (r + g) < 0.05 and b == 0 then
  85.         -- Neutral unit
  86.         newr, newg, newb = 1, 1, 0 --0.86, 0.83, 0.47
  87.         self.healthBar:SetStatusBarColor(1, 1, 0)
  88.     else
  89.         -- Hostile player - class colored.
  90.         newr, newg, newb = r, g, b 
  91.     end
  92.  
  93.     self.r, self.g, self.b = newr, newg, newb
  94.  
  95.     self.healthBar:ClearAllPoints()
  96.     self.healthBar:SetPoint("CENTER", self.healthBar:GetParent())
  97.     self.healthBar:SetHeight(7)
  98.     self.healthBar:SetWidth(100)
  99.  
  100.     self.healthBar.hpBackground:SetVertexColor(self.r * 0.22, self.g * 0.22, self.b * 0.22, 18)
  101.     self.castBar.IconOverlay:SetVertexColor(self.r, self.g, self.b)
  102.  
  103.     self.castBar:ClearAllPoints()
  104.     self.castBar:SetPoint("TOP", self.healthBar, "BOTTOM", 0, -5)
  105.     self.castBar:SetHeight(4)
  106.     self.castBar:SetWidth(100)
  107.  
  108.     self.highlight:ClearAllPoints()
  109.     self.highlight:SetAllPoints(self.healthBar)
  110.  
  111.     local oldName = self.oldname:GetText()
  112.     local newName = (string.len(oldName) > 20) and string.gsub(oldName, "%s?(.[\128-\191]*)%S+%s", "%1. ") or oldName -- "%s?(.)%S+%s"
  113.  
  114.     self.name:SetText(newName)
  115.  
  116.     local level, elite, mylevel = tonumber(self.level:GetText()), self.elite:IsShown(), UnitLevel("player")
  117.     self.level:ClearAllPoints()
  118.     self.level:SetPoint("RIGHT", self.healthBar, "LEFT", -1, 1)
  119.     if self.boss:IsShown() then
  120.         self.level:SetText("B")
  121.         self.level:SetTextColor(0.8, 0.05, 0)
  122.         self.level:Show()
  123.     elseif not elite and level == mylevel then
  124.         self.level:Hide()
  125.     else
  126.         self.level:SetText(level..(elite and "+" or ""))
  127.     end
  128. end
  129.  
  130. local FixCastbar = function(self)
  131.     self.castbarOverlay:Hide()
  132.  
  133.     self:SetHeight(3)
  134.     self:ClearAllPoints()
  135.     self:SetPoint("TOP", self.healthBar, "BOTTOM", 0, -5)
  136. end
  137.  
  138. local ColorCastBar = function(self, shielded)
  139.     if shielded then
  140.         self:SetStatusBarColor(0.8, 0.05, 0)
  141.         self.cbGlow:SetBackdropBorderColor(0.75, 0.75, 0.75)
  142.     else
  143.         self.cbGlow:SetBackdropBorderColor(0, 0, 0)
  144.     end
  145. end
  146.  
  147. local OnSizeChanged = function(self, width, height)
  148.     if floor(height) ~= 3 then
  149.         self.needFix = true
  150.     end
  151. end
  152.  
  153. local OnShow = function(self)
  154.     self.channeling  = UnitChannelInfo("target")
  155.  
  156.     if self.needFix then
  157.         FixCastbar(self)
  158.         if floor(self:GetHeight()) ~= 3 then
  159. --          print("B) wrong size "..floor(self:GetHeight()))
  160.         end
  161.     end
  162.  
  163.     ColorCastBar(self, self.shieldedRegion:IsShown())
  164.     self.IconOverlay:Show()
  165. end
  166.  
  167. local OnValueChanged = function(self, curValue)
  168.     UpdateTime(self, curValue)
  169.  
  170.     if self.needFix then
  171.         FixCastbar(self)
  172.         if floor(self:GetHeight()) ~= 5 then
  173. --          print("C) wrong size "..floor(self:GetHeight()))
  174.         end
  175.         self.needFix = nil
  176.     end
  177. end
  178.  
  179. local OnHide = function(self)
  180.     self.highlight:Hide()
  181.     self.healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)
  182. end
  183.  
  184. local OnEvent = function(self, event, unit)
  185.     if unit == "target" then
  186.         if self:IsShown() then
  187.             ColorCastBar(self, event == "UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
  188.         end
  189.     end
  190. end
  191.  
  192. local CreatePlate = function(frame)
  193.      
  194.     frame.done = true
  195.     --[[
  196.     frame.barFrame, frame.nameFrame = frame:GetChildren()
  197.     frame.healthBar, frame.absorbBar, frame.castBar = frame.barFrame:GetChildren()
  198.  
  199.     local healthBar, castBar = frame.healthBar, frame.castBar
  200.     local glowRegion, overlayRegion, highlightRegion, levelTextRegion, bossIconRegion, raidIconRegion, stateIconRegion = frame.barFrame:GetRegions()
  201.     local _, castbarOverlay, shieldedRegion, spellIconRegion = castBar:GetRegions()
  202.     local nameTextRegion = frame.nameFrame:GetRegions()
  203. --]]
  204.     frame.oldname = nameTextRegion
  205.     nameTextRegion:Hide()
  206.  
  207.     local newNameRegion = frame:CreateFontString()
  208.     newNameRegion:SetPoint("CENTER", healthBar, "CENTER", 0, 10)
  209.     newNameRegion:SetFont(font, fontSize, fontOutline)
  210.     newNameRegion:SetTextColor(0.84, 0.75, 0.65)
  211.     newNameRegion:SetShadowOffset(1.25, -1.25)
  212.     frame.name = newNameRegion
  213.  
  214.     frame.level = levelTextRegion
  215.     levelTextRegion:SetFont(font, fontSize, fontOutline)
  216.     levelTextRegion:SetShadowOffset(1.25, -1.25)
  217.  
  218.     healthBar:SetStatusBarTexture(barTexture)
  219.  
  220.     healthBar.hpBackground = CreateTexture(nil, "BACKGROUND")
  221.     healthBar.hpBackground:SetAllPoints()
  222.     healthBar.hpBackground:SetTexture(barTexture)
  223.  
  224.     healthBar.hpGlow = CreateFrame("Frame", nil, healthBar)
  225.     healthBar.hpGlow:SetFrameLevel(self:GetFrameLevel() -1 > 0 and self:GetFrameLevel() -1 or 0)
  226.     healthBar.hpGlow:SetPoint("TOPLEFT", healthBar, "TOPLEFT", -2, 2)
  227.     healthBar.hpGlow:SetPoint("BOTTOMRIGHT", healthBar, "BOTTOMRIGHT", 2, -2)
  228.     healthBar.hpGlow:SetBackdrop(backdrop)
  229.     healthBar.hpGlow:SetBackdropColor(0, 0, 0, 0)
  230.     healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)
  231.  
  232.     castBar.castbarOverlay = castbarOverlay
  233.     castBar.healthBar = healthBar
  234.     castBar.shieldedRegion = shieldedRegion
  235.     castBar:SetStatusBarTexture(barTexture)
  236.  
  237.     castBar:HookScript("OnShow", OnShow)
  238.     castBar:HookScript("OnSizeChanged", OnSizeChanged)
  239.     castBar:HookScript("OnValueChanged", OnValueChanged)
  240.     castBar:HookScript("OnEvent", OnEvent)
  241.     castBar:RegisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE")
  242.     castBar:RegisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
  243.  
  244.     castBar.time = CreateFontString(nil, "ARTWORK")
  245.     castBar.time:SetPoint("RIGHT", castBar, "LEFT", -2, 0)
  246.     castBar.time:SetFont(font, fontSize, fontOutline)
  247.     castBar.time:SetTextColor(0.84, 0.75, 0.65)
  248.     castBar.time:SetShadowOffset(1.25, -1.25)
  249.  
  250.     castBar.cbBackground = CreateTexture(nil, "BACKGROUND")
  251.     castBar.cbBackground:SetAllPoints()
  252.     castBar.cbBackground:SetTexture(barTexture)
  253.     castBar.cbBackground:SetVertexColor(0.25, 0.25, 0.25, 0.75)
  254.  
  255.     castBar.cbGlow = CreateFrame("Frame", nil, castBar)
  256.     castBar.cbGlow:SetFrameLevel(self:GetFrameLevel() -1 > 0 and self:GetFrameLevel() -1 or 0)
  257.     castBar.cbGlow:SetPoint("TOPLEFT", castBar, -2, 2)
  258.     castBar.cbGlow:SetPoint("BOTTOMRIGHT", castBar, 2, -2)
  259.     castBar.cbGlow:SetBackdrop(backdrop)
  260.     castBar.cbGlow:SetBackdropColor(0, 0, 0, 0)
  261.     castBar.cbGlow:SetBackdropBorderColor(0, 0, 0)
  262.  
  263.     castBar.HolderA = CreateFrame("Frame", nil, castBar)
  264.     castBar.HolderA:SetFrameLevel(self:GetFrameLevel() + 1)
  265.     castBar.HolderA:SetAllPoints()
  266.  
  267.     spellIconRegion:ClearAllPoints()
  268.     spellIconRegion:SetParent(HolderA)
  269.     spellIconRegion:SetPoint("LEFT", castBar, 8, 0)
  270.     spellIconRegion:SetSize(0.1, 0.1)
  271.  
  272.     castBar.HolderB = CreateFrame("Frame", nil, castBar)
  273.     castBar.HolderB:SetFrameLevel(self:GetFrameLevel() + 2)
  274.     castBar.HolderB:SetAllPoints()
  275.  
  276.     castBar.IconOverlay = CreateTexture(nil, "OVERLAY")
  277.     castBar.IconOverlay:SetPoint("TOPLEFT", spellIconRegion, -1.5, 1.5)
  278.     castBar.IconOverlay:SetPoint("BOTTOMRIGHT", spellIconRegion, 1.5, -1.5)
  279.     castBar.IconOverlay:SetTexture(iconTexture)
  280.  
  281.     highlightRegion:SetTexture(barTexture)
  282.     highlightRegion:SetVertexColor(0.25, 0.25, 0.25)
  283.     frame.highlight = highlightRegion
  284.  
  285.     raidIconRegion:ClearAllPoints()
  286.     raidIconRegion:SetPoint("RIGHT", healthBar, 25, 2)
  287.     raidIconRegion:SetSize(20, 20)
  288.     raidIconRegion:SetTexture(raidIcons)   
  289.  
  290.     frame.oldglow = glowRegion
  291.     frame.elite = stateIconRegion
  292.     frame.boss = bossIconRegion
  293.  
  294.     glowRegion:SetTexture(nil)
  295.     overlayRegion:SetTexture(nil)
  296.     shieldedRegion:SetTexture(nil)
  297.     castbarOverlay:SetTexture(nil)
  298.     stateIconRegion:SetAlpha(0)
  299.     bossIconRegion:SetTexture(nil)
  300.  
  301.     UpdatePlate(frame)
  302.     frame:SetScript("OnShow", UpdatePlate)
  303.     frame:SetScript("OnHide", OnHide)
  304.  
  305.     frame.elapsed = 0
  306.     frame:SetScript("OnUpdate", ThreatUpdate)
  307. end
  308. hooksecurefunc(NamePlateDriverFrame, "OnNamePlateCreated", function(_, frame)
  309.     CreatePlate(frame.UnitFrame)
  310. end)
  311.  
  312. hooksecurefunc(NamePlateDriverFrame, "ApplyFrameOptions", function(_, frame, unit)
  313.     UpdatePlate(frame.UnitFrame)
  314. end)
what I have currently...I'm kind of struggling
  Reply With Quote
08-19-16, 07:10 PM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I'd really strongly suggest starting over from scratch. Don't try to do everything at once. Start with something really basic like detecting when a nameplate is created and printing a message to the chat frame. Then figure out how to add a texture -- just use "Interface\\Icons\\Icon_Misc_QuestionMark" for now as a demo -- to each nameplate. Then detect when a nameplate's unit changes and print a message. Then show/hide the texture based on some simple condition, like whether the unit is a player or an NPC. Then try something like finding the existing font string that shows the unit's name and changing its font, or moving it. Once you've got these basics down, then start building back up toward what you had with caelNameplates before.

Right now you've just got a bunch of someone else's code that you don't understand that doesn't even work, where huge portions of it need to be removed or rewritten from scratch anyway. You're not doing yourself any favors by starting so far in the hole. Even I'd just throw away the existing code and write some new code if I was trying to update a nameplate addon for 7.0. You're going to end up with almost all new code anyway, so just skip ahead to the part where you start writing that new code, instead of wasting a bunch of time now trying to figure out code that's not functional and not relevant.
__________________
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
08-20-16, 05:15 PM   #11
badness
A Cliff Giant
 
badness's Avatar
Join Date: May 2010
Posts: 74
I guess I'm gonna have to do just that..sigh
  Reply With Quote
08-21-16, 10:31 AM   #12
Joker119
A Flamescale Wyrmkin
 
Joker119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 113
Having recently gone through this process, I agree with Phanx, you'll be much better off, and likely take less time, to simply rewrite it from scratch.

If all you're looking for is reskinning the nameplates to use different bar textures, you can take a look at mine (http://www.wowinterface.com/download...ameplates.html) for some code ideas, really all you need to do is change the statusbar file with the one you want to use.

The default blizzard frames take care of things like raid icons, elite/boss icons, debuffs, etc that cael and many others use to do, and thus they really aren't needed.
  Reply With Quote
08-21-16, 03:44 PM   #13
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You could also write your own skin for TidyPlates.
__________________
"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

  Reply With Quote
08-23-16, 05:18 PM   #14
Joker119
A Flamescale Wyrmkin
 
Joker119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 113
Basically just used my current nameplate addon and changed the skin and a few other small things, incase anyone else wanted it:
http://www.wowinterface.com/download...ameplates.html
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » caelNameplates

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