WoWInterface - View Single Post - caelNameplates
Thread: caelNameplates
View Single Post
08-18-16, 05:35 PM   #7
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()
  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:

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
  7.     if lastUpdate > 0.1 then
  8.         lastUpdate = 0
  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()
  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)
  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