Thread Tools Display Modes
08-18-11, 08:15 PM   #1
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
Question 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.
  Reply With Quote
08-18-11, 10:10 PM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
You'd do something like:

Code:
    if UnitFactionGroup("player") == "Alliance" then
        DoStuff()
    else
        DoOtherStuff()
    end
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
08-18-11, 10:27 PM   #3
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
Originally Posted by Torhal View Post
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

Last edited by dreamcatcher : 08-18-11 at 10:59 PM.
  Reply With Quote
08-19-11, 02:30 AM   #4
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
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
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
08-19-11, 07:24 PM   #5
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
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.
  Reply With Quote
08-19-11, 11:43 PM   #6
Ekaterina
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 65
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
  Reply With Quote
08-19-11, 11:59 PM   #7
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
(face palm) You were right. lol the simplest thing messed me up.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Switching art work betwen faction?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off