WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   How put icon on nameplate with X name [SOLVED] (https://www.wowinterface.com/forums/showthread.php?t=55622)

Mortimerlol 08-05-17 12:04 AM

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

pas06 08-05-17 09:02 AM

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.

Mortimerlol 08-05-17 09:15 AM

Quote:

Originally Posted by pas06 (Post 324504)
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....

pas06 08-05-17 09:43 AM

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)

Mortimerlol 08-05-17 09:57 AM

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!!!!!

Mortimerlol 08-05-17 02:01 PM

is all perfect with mobs and players but with name-something dont work :/

pas06 08-05-17 02:47 PM

Thats probably because UnitName() has two return values https://wow.gamepedia.com/API_UnitName

Mortimerlol 08-05-17 03:15 PM

yes, then must be works with it:

Lua Code:
  1. local unitID = ...
  2. UNTI = GetUnitName(unitID, true);
  3. if moblist[UNTI] then

Mortimerlol 08-05-17 03:36 PM

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 :o

pas06 08-05-17 04:00 PM

Just use the following.
Lua Code:
  1. local name, realm = UnitName(unitID)
  2. if realm then name = name.."-"..realm end

Mortimerlol 08-05-17 04:12 PM

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

Mortimerlol 08-05-17 11:17 PM

[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! :banana: :banana: :banana:

Kakjens 08-06-17 07:29 AM

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?

Mortimerlol 08-06-17 07:36 AM

Yes, i read from save variables ^^ Thanks for your correction in line 5 :)


All times are GMT -6. The time now is 11:18 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI