WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Switching art work betwen faction? (https://www.wowinterface.com/forums/showthread.php?t=41207)

dreamcatcher 08-18-11 08:15 PM

Switching art work betwen faction?
 
I would like to set my back ground frames to switch there art work depending on if you are horde or alliance. I have no idea how to do this or were to look for info on this type of coding. I'm using just all Lua want to stay away from XML since I know nothing a bought XML. Any ideas would be grateful thank you.

Torhal 08-18-11 10:10 PM

You'd do something like:

Code:

    if UnitFactionGroup("player") == "Alliance" then
        DoStuff()
    else
        DoOtherStuff()
    end


dreamcatcher 08-18-11 10:27 PM

Quote:

Originally Posted by Torhal (Post 243394)
You'd do something like:

Code:

    if UnitFactionGroup("player") == "Alliance" then
        DoStuff()
    else
        DoOtherStuff()
    end


Ok how would i put that in the config file for the backdrop?

Config.lua
Code:

Backdrop = {
        bgFile = [=[Interface\AddOns\DreamTweaks\Media\Breaking Glass]=],
        edgeFile = [=[Interface\DialogFrame\UI-DialogBox-Border]=],
        tile = false, tileSize = 0, edgeSize = 16,
        insets = {left = 4, right = 4, top = 4, bottom = 4},
},

Styler.lua
Code:

local function Backdrop()
        if UnitFactionGroup("player") == "Horde" then
        Backdrop ={
        bgFile = [=[Interface\AddOns\DreamTweaks\Media\Breaking Glass]=],
        edgeFile = [=[Interface\DialogFrame\UI-DialogBox-Border]=],
        tile = false, tileSize = 0, edgeSize = 16,
        insets = {left = 4, right = 4, top = 4, bottom = 4},
};
        end
        if UnitFactionGroup("player") == "Alliance" then
        Backdrop ={
        bgFile = [=[Interface\AddOns\DreamTweaks\Media\Fire]=],
        edgeFile = [=[Interface\DialogFrame\UI-DialogBox-Border]=],
        tile = false, tileSize = 0, edgeSize = 16,
        insets = {left = 4, right = 4, top = 4, bottom = 4},
};
        end
end

local function CreateFrames()

local f = CreateFrame("Frame", nil, UIParent)
        f:SetWidth(128)
        f:SetHeight(64)
        f:SetFrameStrata("BACKGROUND")
        f:SetBackdrop(Backdrop)
        f:SetBackdropBorderColor(0,0,0)
        f:SetPoint("CENTER",0,0)
        f:Show()
end


Torhal 08-19-11 02:30 AM

Like this:

Code:

local HORDE_BACKDROP = {
        bgFile = [[Interface\AddOns\DreamTweaks\Media\Breaking Glass]],
        edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
        tile = false, tileSize = 0, edgeSize = 16,
        insets = {left = 4, right = 4, top = 4, bottom = 4},
}

local ALLIANCE_BACKDROP = {
        bgFile = [[Interface\AddOns\DreamTweaks\Media\Fire]],
        edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
        tile = false, tileSize = 0, edgeSize = 16,
        insets = {left = 4, right = 4, top = 4, bottom = 4},
}

local function CreateFrames()
        local f = CreateFrame("Frame", nil, UIParent)
        f:SetWidth(128)
        f:SetHeight(64)
        f:SetFrameStrata("BACKGROUND")

        if UnitFactionGroup("player") == "Horde" then
                f:SetBackdrop(HORDE_BACKDROP)
        else
                f:SetBackdrop(ALLIANCE_BACKDROP)
        end
        f:SetBackdropBorderColor(0,0,0)
        f:SetPoint("CENTER",0,0)
        f:Show()
end


dreamcatcher 08-19-11 07:24 PM

It works for all but my Omen and Recount. Why?

Code:

if Recount then
        local f = CreateFrame("Frame", "Recount", UIParent)
        f:SetParent(Recount_MainWindow)
        f:SetPoint("BOTTOMLEFT", Recount_MainWindow, -5, -5)
        f:SetPoint("TOPRIGHT", Recount_MainWindow, 5 , -5)
        f:SetFrameStrata("BACKGROUND")
        if UnitFactionGroup("player") == "HORDE" then
                f:SetBackdrop(cfg.Media.HORDE)
        else
                f:SetBackdrop(cfg.Media.ALLIANCE)
        end
        f:SetBackdropBorderColor(cfg.Media.BorderColor)
end
       
if Omen then
        local f = CreateFrame("Frame", "Omen", UIParent)
        f:SetParent(OmenAnchor)
        f:SetPoint("BOTTOMLEFT", OmenAnchor, -5, -5)
        f:SetPoint("TOPRIGHT", OmenAnchor, 5 , 5)
        f:SetFrameStrata("BACKGROUND")
        if UnitFactionGroup("player") == "HORDE" then
                f:SetBackdrop(cfg.Media.HORDE)
        else
                f:SetBackdrop(cfg.Media.ALLIANCE)
        end
        f:SetBackdropBorderColor(cfg.Media.BorderColor)
end

It sets there background but only to the alliance background.
:confused:

Ekaterina 08-19-11 11:43 PM

Hi,
Looking at your code, I think it's a capitalisation issue.

This:
if UnitFactionGroup("player") == "HORDE" then

Should be this:
if UnitFactionGroup("player") == "Horde" then

dreamcatcher 08-19-11 11:59 PM

(face palm) :eek: You were right. lol the simplest thing messed me up.


All times are GMT -6. The time now is 04:44 PM.

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