Thread Tools Display Modes
08-05-17, 12:04 AM   #1
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
Question How put icon on nameplate with X name [SOLVED]

Good morning to all,

Somebody have idea how put an icon over nameplate with X name? For example, i want put an icon to all mobs with name "Eredar Summoner".

My testing code atm:
Lua Code:
  1. local moblist = { "Eredar Summoner", "Wrathguard Dreadblade", }
  2.  
  3. for k in pairs(moblist) do
  4.     moblist[#moblist + 1] = k
  5. end
  6. table.sort(moblist)
  7. for i = 1, #moblist do
  8.  name = moblist[i]
  9.  moblist[name] = name
  10.  print(moblist[name])
  11. end
  12.  
  13. local nkids = WorldFrame:GetNumChildren()
  14.     for i = 1, nkids do
  15.         local frame = select(i, WorldFrame:GetChildren())
  16.             if frame.moblist[name] then
  17.                 frame.moblist[name]:SetTexCoord(.22, .22, .22, .22)
  18.                 frame.moblist[name]:SetHeight(35)
  19.                 frame.moblist[name]:SetWidth(35)
  20.                 frame.moblist[name]:SetTexture("Interface\Icons\Ability_hunter_beastcall02")
  21.             end
  22.     end

Last edited by Mortimerlol : 08-05-17 at 11:18 PM. Reason: [SOLVED]
  Reply With Quote
08-05-17, 09:02 AM   #2
pas06
A Theradrim Guardian
Join Date: Apr 2009
Posts: 62
use event NAME_PLATE_UNIT_ADDED, argument is a unitID, check the mobs's name with UnitName(unitID) then you can get the nameplate with C_NamePlate.GetNamePlateForUnit(unitID). i guess you will also need NAME_PLATE_UNIT_REMOVED to remove the changes you made.
  Reply With Quote
08-05-17, 09:15 AM   #3
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
Originally Posted by pas06 View Post
use event NAME_PLATE_UNIT_ADDED, argument is a unitID, check the mobs's name with UnitName(unitID) then you can get the nameplate with C_NamePlate.GetNamePlateForUnit(unitID). i guess you will also need NAME_PLATE_UNIT_REMOVED to remove the changes you made.
Thanks for answering !!

Yes, Im trying with NAME_PLATE_UNIT_ADDED, and yes, put unitID as COMBAT_LOG_EVENT_UNFILTERED... i can compare but i cant link with nameplateXunitframe, etc....
  Reply With Quote
08-05-17, 09:43 AM   #4
pas06
A Theradrim Guardian
Join Date: Apr 2009
Posts: 62
Sorry, but i don't understand what you wanted to do with COMBAT_LOG_EVENT_UNFILTERED.
I also don't understand what you are tying todo with your table moblist. If you want the desired mobnames in a table its better to just make the table like
Lua Code:
  1. local mobs = {
  2. ["Eredar Summoner"] = true,
  3. ["Wrathguard Dreadblade"] = true,
  4. }
This way you can easily check if the new added nameplate belongs to a unit whose name is in your table.

Exmaple Code:
Lua Code:
  1. local moblist = {
  2.     ["Eredar Summoner"] = true,
  3.     ["Wrathguard Dreadblade"] = true,
  4. }
  5.  
  6.  
  7.  
  8.  
  9. local frame = CreateFrame("frame")
  10. frame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  11. frame:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
  12. frame:SetScript("OnEvent", function(self, event, ...)
  13. if event == "NAME_PLATE_UNIT_ADDED" then
  14.     local unitID = ...
  15.     if moblist[UnitName(unitID)] then-- modify his nameplates
  16.         local nameplate = C_NamePlate.GetNamePlateForUnit(unitID)
  17.         if not nameplate.myIndicator then
  18.             nameplate.myIndicator = nameplate:CreateTexture(nil, "OVERLAY")
  19.             nameplate.myIndicator:SetTexture("whatEverTextureYouLike")
  20.         end
  21.         nameplate.myIndicator:Show()
  22.     end
  23.  
  24. elseif event == "NAME_PLATE_UNIT_REMOVED" then
  25.         local unitID = ...
  26.     local nameplate = C_NamePlate.GetNamePlateForUnit(unitID)
  27.     if nameplate.myIndicator then
  28.         nameplate.myIndicator:Hide()
  29.     end
  30. end
  31.  
  32.  
  33. end)
  Reply With Quote
08-05-17, 09:57 AM   #5
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
Lua Code:
  1. nameplate.myIndicator = nameplate:CreateTexture(nil, "OVERLAY")
  2. nameplate.myIndicator:SetTexture("Interface\\Icons\\Ability_hunter_beastcall02")
  3. nameplate.myIndicator:SetSize(25,25)
  4. nameplate.myIndicator:SetPoint("TOP", 40, 15) -- horizontal, vertical
12312312312 of thanks!!!!!
  Reply With Quote
08-05-17, 02:01 PM   #6
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
is all perfect with mobs and players but with name-something dont work :/
  Reply With Quote
08-05-17, 02:47 PM   #7
pas06
A Theradrim Guardian
Join Date: Apr 2009
Posts: 62
Thats probably because UnitName() has two return values https://wow.gamepedia.com/API_UnitName
  Reply With Quote
08-05-17, 03:15 PM   #8
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
yes, then must be works with it:

Lua Code:
  1. local unitID = ...
  2. UNTI = GetUnitName(unitID, true);
  3. if moblist[UNTI] then
  Reply With Quote
08-05-17, 03:36 PM   #9
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
yeah works fine now with name-Realm. Now need only check if realm enemy player is in same realm that me then split -sameRealm

Lua Code:
  1. local realmName = GetRealmName()
But i have only tthe guids

Last edited by Mortimerlol : 08-05-17 at 03:38 PM.
  Reply With Quote
08-05-17, 04:00 PM   #10
pas06
A Theradrim Guardian
Join Date: Apr 2009
Posts: 62
Just use the following.
Lua Code:
  1. local name, realm = UnitName(unitID)
  2. if realm then name = name.."-"..realm end
  Reply With Quote
08-05-17, 04:12 PM   #11
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
i save always name-realm in my savedvariable...
Lua Code:
  1. local unitID = ...
  2.     local realmName = GetRealmName()
  3.     --local name, realm = UnitName(unitID)
  4.     UNTI = GetUnitName(unitID, true); -- sin esto duvuelve solo el nombre sin realm
  5.     --if string.find(UNTI, '%-'..realmName) then UNTI = strsplit("-", UNTI) end
I need split realm if is same with me
  Reply With Quote
08-05-17, 11:17 PM   #12
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
[solved]

Lua Code:
  1. unitID = ...
  2.     realmName = GetRealmName()
  3.     UNTI = GetUnitName(unitID, true); -- return name-realm
  4.     if not string.find(UNTI, '%-') then -- no realm
  5.         CUNTI = UNTI.."-"..realmName;
  6.     elseif string.find(UNTI, '% ') then -- for respect mobs
  7.         UNTI = UNTI;
  8.     end
  9.    if BangHateds[UNTI] or BangHateds[CUNTI] then
Thanks for help!
  Reply With Quote
08-06-17, 07:29 AM   #13
Kakjens
A Cliff Giant
Join Date: Apr 2017
Posts: 75
I don't quite understand what are you trying to accomplish with
Lua Code:
  1. elseif string.find(UNTI, '% ') then -- for respect mobs
  2.      UNTI = UNTI;
Depending on answer, line 5 might get changed into
Code:
UNTI = UNTI.."-"..realmName;
, and consequent check simplified into
Code:
if BangHateds[UNTI]  then
.
Is it me, or there really are several global variables?

Last edited by Kakjens : 08-06-17 at 07:32 AM.
  Reply With Quote
08-06-17, 07:36 AM   #14
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
Yes, i read from save variables ^^ Thanks for your correction in line 5
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How put icon on nameplate with X name [SOLVED]

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