I'm learning lua, and it's not obvious for me. I sursh on plurality forums but I don't understand why y code doesn't work. Actualy I have this :
Lua Code:
--Player Frame
local fp = CreateFrame("Button", "FarmootPlayerPortrait", UIParent, "SecureUnitButtonTemplate")
fp:SetSize(70, 70)
fp:SetPoint("CENTER", -80, -350)
fp:SetAttribute("unit", "player")
RegisterUnitWatch(fp)
fp:SetAttribute("toggleForVehicle", true)
fp:RegisterForClicks("AnyUp")
fp:SetAttribute("*type1", "target")
fp:SetAttribute("*type2", "togglemenu")
fp:SetAttribute("*type3", "assist")
fp.Texture = fp:CreateTexture("$parent_Texture", "BACKGROUND")
fp.Texture:SetAllPoints()
SetPortraitTexture(fp.Texture, "player")
fp.Border = fp:CreateTexture("$parent_Border", "BORDER")
fp.Border:SetPoint("TOPLEFT", -6, 4)
fp.Border:SetPoint("BOTTOMRIGHT", 6, -10)
fp.Border:SetTexture("Interface/PLAYERFRAME/UI-PlayerFrame-Deathknight-Ring")
fp.Border:SetVertexColor(1, 1, 0, 1)
fp:RegisterUnitEvent("UNIT_PORTRAIT_UPDATE", "player")
fp:SetScript("OnEvent", function(self) SetPortraitTexture(self.Texture, "player") end)
--Target Frame
local ft = CreateFrame("Button", "FarmootTargetPortrait", UIParent, "SecureUnitButtonTemplate")
fp.Target = ft -- based on suggestion of Fizzlemizz
ft:SetSize(70, 70)
ft:SetPoint("CENTER", 110, -350)
ft:SetAttribute("unit", "target")
RegisterUnitWatch(ft)
ft:SetAttribute("toggleForVehicle", true)
ft:RegisterForClicks("AnyUp")
ft:SetAttribute("*type1", "target")
ft:SetAttribute("*type2", "togglemenu")
ft:SetAttribute("*type3", "assist")
ft.Texture = ft:CreateTexture("$parent_Texture", "BACKGROUND")
ft.Texture:SetAllPoints()
ft.Border = ft:CreateTexture("$parent_Border", "BORDER")
ft.Border:SetPoint("TOPLEFT", -6, 4)
ft.Border:SetPoint("BOTTOMRIGHT", 6, -10)
ft.Border:SetTexture("Interface/PLAYERFRAME/UI-PlayerFrame-Deathknight-Ring")
ft.Border:SetVertexColor(1, 1, 0, 1)
ft:RegisterUnitEvent("UNIT_PORTRAIT_UPDATE", "target")
ft:RegisterEvent("PLAYER_TARGET_CHANGED") -- based on suggestion of Fizzlemizz
ft:SetScript("OnEvent", function(self) SetPortraitTexture(self.Texture, "target") end)
--Target Classification
local default = "Interface/AddOns/ClassicPortrait/media/default"
local uClassTextures = {
worldboss = "Interface/AddOns/ClassicPortrait/media/worldboss",
boss = "Interface/AddOns/ClassicPortrait/media/boss",
elite = "Interface/AddOns/ClassicPortrait/media/elite",
rare = "Interface/AddOns/ClassicPortrait/media/rare",
rareelite = "Interface/AddOns/ClassicPortrait/media/rareelite",
}
local uClass = UnitClassification("target")
local function OnEvent(self, event, ...)
if event == "PLAYER_TARGET_CHANGED" and UnitExists("target") then
self:SetTexture( unitClassTextures[UnitClassification("target")] or default )
end
self:RegisterEvent("PLAYER_TARGET_CHANGED")
end
This display portraits but not classification textutes. I deleted settings and keep those in --Target Frame. i try to follow your advice, but it not easy to write the code.