1. Trying to add a "check for character name" or "check for class" statement in the target.lua of oUF_Diablo unit frames so it will be able to load different background art when logging on to certain characters/classes (duh ;> )

    the original lua code regarding the background is

    • --actionbar background
    • local createArtwork = function(self)
    • local t = self:CreateTexture(nil,"BACKGROUND",nil,-8)
    • t:SetAllPoints(self)
    • t:SetTexture("Interface\AddOns\rTextures\target")
    • end

    It was explained to me that all I had to pretty much do is add

    • if UnitName("player") == "myplayername" then
    • --do stuff
    • else
    • --do other stuff
    • end

    So I dropped a 2nd TGA file in the same dir named "target2.tga" and then changed the code to

    • if UnitName("player") == "Remsaa" then
    • --actionbar background
    • local createArtwork = function(self)
    • local t = self:CreateTexture(nil,"BACKGROUND",nil,-8)
    • t:SetAllPoints(self)
    • t:SetTexture("Interface\AddOns\rTextures\target2")
    • else
    • --actionbar background
    • local createArtwork = function(self)
    • local t = self:CreateTexture(nil,"BACKGROUND",nil,-8)
    • t:SetAllPoints(self)
    • t:SetTexture("Interface\AddOns\rTextures\target")
    • end

    That didnt work so I tried

    • --actionbar background
    • local createArtwork = function(self)
    • local t = self:CreateTexture(nil,"BACKGROUND",nil,-8)
    • t:SetAllPoints(self)
    • if UnitName("player") == "Kraftman" then
    • t:SetTexture("Interface\AddOns\rTextures\target2")
    • else
    • t:SetTexture("Interface\AddOns\rTextures\target")
    • end

    and now I will try when I get home

    • --actionbar background
    • local createArtwork = function(self)
    • local t = self:CreateTexture(nil,"BACKGROUND",nil,-8)
    • t:SetAllPoints(self)
    • t:SetTexture("Interface\AddOns\rTextures\target2")
    • if UnitName("player") == "Kraftman" then
    • t:SetTexture("Interface\AddOns\rTextures\target")
    • end

    But as you can tell my knowledge for coding is horrible so I have little faith. I was hoping to get this resolved so I can finally give my wife that pretty Priest UI she has been wanting for so long.

    Can anyone tell me where I am going wrong or can give me a push in the right direction?

    Thanks for your time guys

    edit*ugh sorry about the code formatting coming out gross ;)

    By "doesn't work" do you mean "produces an error message" (make sure you have your game client set to tell you when there is an error) or "doesn't change the texture"?

    I don't work with textures so I don't know if there are any potential snags there (nothing looks wrong to me) but something else to check is whether the addon is changing the texture again after you set it; do a search for SetTexture to see if there's anywhere else you need to add your if-structure.

    It sounds like you're trying to modify an addon that doesn't have preference-settings for textures to use an other-than-default texture but only for one character? You could also just modify a renamed copy of addon and disable the regular version on the one character, and disable the modified copy on the others. Or add preferences with per-character saved data, but it sounds like you're not that ambitious.

    To get code to look nice on the forum: Click the last icon on the top bar

    Well I was missing a few items but I think I might have got it now...

    I added

     local player_name, _ = UnitName("player")
     local _, player_class = UnitClass("player")
    

    at the top of the lua

    and then modified the actionbar code to read;

     --actionbar background
     if player_class == "PALADIN" then  
     local createArtwork = function(self)
         local t = self:CreateTexture(nil,"BACKGROUND",nil,-8)
         t:SetAllPoints(self)
         t:SetTexture("Interface\\AddOns\\rTextures\\targethui")
     else
     local createArtwork = function(self)
         local t = self:CreateTexture(nil,"BACKGROUND",nil,-8)
         t:SetAllPoints(self)
         t:SetTexture("Interface\\AddOns\\rTextures\\target")
       end
    

    I think this should do it, will try it later.