View Single Post
04-17-19, 04:18 AM   #14
SilverDragony
A Murloc Raider
Join Date: Apr 2019
Posts: 6
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:
  1. --Player Frame
  2.     local fp = CreateFrame("Button", "FarmootPlayerPortrait", UIParent, "SecureUnitButtonTemplate")
  3.     fp:SetSize(70, 70)
  4.     fp:SetPoint("CENTER", -80, -350)
  5.     fp:SetAttribute("unit", "player")
  6.     RegisterUnitWatch(fp)
  7.     fp:SetAttribute("toggleForVehicle", true)
  8.     fp:RegisterForClicks("AnyUp")
  9.     fp:SetAttribute("*type1", "target")
  10.     fp:SetAttribute("*type2", "togglemenu")
  11.     fp:SetAttribute("*type3", "assist")
  12.     fp.Texture = fp:CreateTexture("$parent_Texture", "BACKGROUND")
  13.     fp.Texture:SetAllPoints()
  14.     SetPortraitTexture(fp.Texture, "player")
  15.     fp.Border = fp:CreateTexture("$parent_Border", "BORDER")
  16.     fp.Border:SetPoint("TOPLEFT", -6, 4)
  17.     fp.Border:SetPoint("BOTTOMRIGHT", 6, -10)
  18.     fp.Border:SetTexture("Interface/PLAYERFRAME/UI-PlayerFrame-Deathknight-Ring")
  19.     fp.Border:SetVertexColor(1, 1, 0, 1)
  20.     fp:RegisterUnitEvent("UNIT_PORTRAIT_UPDATE", "player")
  21.     fp:SetScript("OnEvent", function(self) SetPortraitTexture(self.Texture, "player") end)
  22.      
  23.     --Target Frame
  24.     local ft = CreateFrame("Button", "FarmootTargetPortrait", UIParent, "SecureUnitButtonTemplate")
  25.     fp.Target = ft -- based on suggestion of Fizzlemizz
  26.     ft:SetSize(70, 70)
  27.     ft:SetPoint("CENTER", 110, -350)
  28.     ft:SetAttribute("unit", "target")
  29.     RegisterUnitWatch(ft)
  30.     ft:SetAttribute("toggleForVehicle", true)
  31.     ft:RegisterForClicks("AnyUp")
  32.     ft:SetAttribute("*type1", "target")
  33.     ft:SetAttribute("*type2", "togglemenu")
  34.     ft:SetAttribute("*type3", "assist")
  35.     ft.Texture = ft:CreateTexture("$parent_Texture", "BACKGROUND")
  36.     ft.Texture:SetAllPoints()
  37.     ft.Border = ft:CreateTexture("$parent_Border", "BORDER")
  38.     ft.Border:SetPoint("TOPLEFT", -6, 4)
  39.     ft.Border:SetPoint("BOTTOMRIGHT", 6, -10)
  40.     ft.Border:SetTexture("Interface/PLAYERFRAME/UI-PlayerFrame-Deathknight-Ring")
  41.     ft.Border:SetVertexColor(1, 1, 0, 1)
  42.     ft:RegisterUnitEvent("UNIT_PORTRAIT_UPDATE", "target")
  43.     ft:RegisterEvent("PLAYER_TARGET_CHANGED") -- based on suggestion of Fizzlemizz
  44.     ft:SetScript("OnEvent", function(self) SetPortraitTexture(self.Texture, "target")  end)
  45.    
  46.     --Target Classification
  47.     local default = "Interface/AddOns/ClassicPortrait/media/default"
  48.     local uClassTextures = {
  49.         worldboss = "Interface/AddOns/ClassicPortrait/media/worldboss",
  50.         boss = "Interface/AddOns/ClassicPortrait/media/boss",
  51.         elite = "Interface/AddOns/ClassicPortrait/media/elite",
  52.         rare = "Interface/AddOns/ClassicPortrait/media/rare",
  53.         rareelite = "Interface/AddOns/ClassicPortrait/media/rareelite",
  54.     }
  55.     local uClass = UnitClassification("target")
  56.     local function OnEvent(self, event, ...)
  57.         if event == "PLAYER_TARGET_CHANGED" and UnitExists("target") then
  58.             self:SetTexture( unitClassTextures[UnitClassification("target")] or default )
  59.         end
  60.         self:RegisterEvent("PLAYER_TARGET_CHANGED")
  61.     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.
  Reply With Quote