Quantcast
PlayerHitIndicator and class color. Help - WoWInterface
Thread Tools Display Modes
11-26-17, 05:02 AM   #1
RammounZ
A Defias Bandit
Join Date: Nov 2017
Posts: 3
PlayerHitIndicator and class color. Help

Hi!

It's possible to change the size of PlayerHitIndicator(incoming healing and damage on player frame) and a little move to the left?
Click image for larger version

Name:	WoWScrnShot_112617_131348.jpg
Views:	336
Size:	438.8 KB
ID:	9022

And second question, i have code that change color my nickname on my player frame(you can see that my nickname is blue, like color of the class)

Code:
local function getPlayerColors()
    local c = RAID_CLASS_COLORS[select(2,UnitClass("player"))]
    return c.r, c.g, c.b
end

PlayerName:SetTextColor(getPlayerColors())
so, i want change class color of the nickname on target and focus. Something like that
Code:
TargetFrameTextureFrameName:SetTextColor(getPlayerColors())
FocusFrameTextureFrameName:SetTextColor(getPlayerColors())
But, I dont know how to make the getPlayerColors() function return the color of the class, not just the color of the player. How to do it ?
  Reply With Quote
11-26-17, 08:22 AM   #2
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,352
I'm not an expert in Lua coding (by any means), but, the answer (basically) is in the second line of your example. RAID_CLASS_COLORS should give you your clue.

Sorry if that's wrong, but it seemed obvious to me.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!

Last edited by jeffy162 : 11-26-17 at 08:32 AM. Reason: more blah blah blah
  Reply With Quote
11-26-17, 08:53 AM   #3
RammounZ
A Defias Bandit
Join Date: Nov 2017
Posts: 3
Thanks for reply. Yes, one dude suggest me this code, but he doesnt work

Code:
local function getPlayerColors(unit)
    local c = RAID_CLASS_COLORS[select(2,UnitClass(unit))]
    return c.r, c.g, c.b
end

PlayerName:SetTextColor(getPlayerColors("player"))
TargetFrameTextureFrameName:SetTextColor(getPlayerColors("target"))
FocusFrameTextureFrameName:SetTextColor(getPlayerColors("focus"))
  Reply With Quote
11-26-17, 10:40 AM   #4
Kakjens
A Cliff Giant
Join Date: Apr 2017
Posts: 75
Originally Posted by RammounZ View Post
he doesnt work
Was it meant as "it doesn't work"?
I believe you might want to call
Code:
TargetFrameTextureFrameName:SetTextColor(getPlayerColors("target"))
FocusFrameTextureFrameName:SetTextColor(getPlayerColors("focus"))
accordingly when target or focus changed instead of during login.

Last edited by Kakjens : 11-26-17 at 10:42 AM.
  Reply With Quote
11-26-17, 11:23 AM   #5
Tim
A Frostmaul Preserver
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 285
Pretty sure the PlayerHitIndicator text is drawn on sort of like Blizzard's combat text so, the only ways to change it are by changing fonts or disabling it completely.

As for the name color stuff....

Code:
local function getPlayerColors(unit)

   if not UnitExists(unit) then return end

   local color
   local class = select(2, UnitClass(unit))

   if UnitIsPlayer(unit) then
      color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
   else
      color = FACTION_BAR_COLORS[UnitReaction(unit, "player")]
   end

   return color.r, color.g, color.b

end

local UpdateColor = CreateFrame("Frame")
UpdateColor:RegisterEvent("PLAYER_ENTERING_WORLD")
UpdateColor:RegisterEvent("PLAYER_TARGET_CHANGED")
UpdateColor:RegisterEvent("PLAYER_FOCUS_CHANGED")
UpdateColor:RegisterEvent("UNIT_FACTION")
UpdateColor:SetScript("OnEvent", function(_, event)

   _G["PlayerName"]:SetTextColor(getPlayerColors("player"))
   _G["TargetFrameTextureFrameName"]:SetTextColor(getPlayerColors("target"))
   _G["FocusFrameTextureFrameName"]:SetTextColor(getPlayerColors("focus"))

end)
  Reply With Quote
11-26-17, 12:05 PM   #6
RammounZ
A Defias Bandit
Join Date: Nov 2017
Posts: 3
Originally Posted by Tim View Post
Code:
local function getPlayerColors(unit)

   if not UnitExists(unit) then return end

   local color
   local class = select(2, UnitClass(unit))

   if UnitIsPlayer(unit) then
      color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
   else
      color = FACTION_BAR_COLORS[UnitReaction(unit, "player")]
   end

   return color.r, color.g, color.b

end

local UpdateColor = CreateFrame("Frame")
UpdateColor:RegisterEvent("PLAYER_ENTERING_WORLD")
UpdateColor:RegisterEvent("PLAYER_TARGET_CHANGED")
UpdateColor:RegisterEvent("PLAYER_FOCUS_CHANGED")
UpdateColor:RegisterEvent("UNIT_FACTION")
UpdateColor:SetScript("OnEvent", function(_, event)

   _G["PlayerName"]:SetTextColor(getPlayerColors("player"))
   _G["TargetFrameTextureFrameName"]:SetTextColor(getPlayerColors("target"))
   _G["FocusFrameTextureFrameName"]:SetTextColor(getPlayerColors("focus"))

end)
This code working very well, ty Tim very much for help!!!

And about PlayerHitIndicator, you are right. I use other fonts, that's why PlayerHitIndicator is so big. And since they can not be reduced, I decided to hide them. If someone need a code:

Code:
PlayerHitIndicator:SetText(nil)
PlayerHitIndicator.SetText = function() end
  Reply With Quote
11-26-17, 05:09 PM   #7
Kakjens
A Cliff Giant
Join Date: Apr 2017
Posts: 75
With a use of variable "event" is possible to avoid unnecessary getPlayerColors(unit) calls.
What's the reason for UpdateColor:RegisterEvent("UNIT_FACTION")?
For me it feels that
Lua Code:
  1. PlayerHitIndicator:SetText(nil)
  2. PlayerHitIndicator.SetText = function() end
is a wrong way to hide text due to tainting.
  Reply With Quote
11-26-17, 09:23 PM   #8
Kanegasi
A Firelord
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 499
Originally Posted by Kakjens View Post
For me it feels that
Lua Code:
  1. PlayerHitIndicator:SetText(nil)
  2. PlayerHitIndicator.SetText = function() end
is a wrong way to hide text due to tainting.
Correct. Altering any of Blizzard's functions is a good way to taint. Not all UI code is secure, but taints happen in weird ways.

A better way to hide the PlayerHitIndicator text:

Lua Code:
  1. PlayerFrame:UnregisterEvent('UNIT_COMBAT')

My addon NoCombatText can also hide the text, but it also allows you to configure what you want to show, for both Player and Pet. An addon of the same name here, No Combat Text, just hides the text by clearing the anchor points of the HitIndicator frames. The names are coincidental, as explained in my comment on that addon's page.
  Reply With Quote
11-27-17, 04:42 AM   #9
Tim
A Frostmaul Preserver
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 285
Originally Posted by Kakjens View Post
What's the reason for UpdateColor:RegisterEvent("UNIT_FACTION")?
It's just for the npc's where they're not always friendly/neutral/hostile towards you.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » PlayerHitIndicator and class color. 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