Thread Tools Display Modes
05-17-13, 10:21 AM   #1
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Need help with addon!

Hi I am not great with lua and have had a big break from it and now cannot even remember some of the basics.

I want to create an addon that skins the Compact Raid Frame to match my UI better:



I am using the below code to control the addon however it does not show anything when I enter a raid. I am sure there are probably a lot of things wrong with it. Can anyone good at lua show me what I need to change?
Thank you for taking a look at it in advance!

Code:
local MayronUI = ...
local MEDIAPATH = "Interface\\AddOns\\" .. MayronUI .. "\\"
local CLICK = "Interface\\AddOns\\MayronSetup\\Media\\SounD\\click.mp3"
local FONT = "Fonts\\FRIZQT__.ttf"
local classcolor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[(select(2, UnitClass("player")))]

------------------------------------------------------------------------
-- Core Objects and Functions
------------------------------------------------------------------------

local CompactFrame = CreateFrame("Frame", "CompactFrame", UIParent)
CompactFrame:Hide()

local Open = CreateFrame("Button", "Open", UIParent)
Open:Hide()

local Close = CreateFrame("Button", "Close", UIParent)
Close:Hide()

local function OpenFrame()
Open:Hide()
CompactFrame:Show()
end

local function CloseFrame()
Open:Show()
CompactFrame:Hide()
end

local EventFrame = CreateFrame("Frame")
EventFrame:RegisterEvent("PLAYER_ENTER_WORLD")
EventFrame:SetScript("OnEvent", function(self, event, ...)
inInstance, instanceType = IsInInstance()
if IsInInstance() then
	if CompactRaidFrameManagerDisplayFrame:IsVisible() then
		OpenFrame()
	else
		CloseFrame()
	end
end
end)

------------------------------------------------------------------------
-- OnShow Events
------------------------------------------------------------------------
CompactFrame:SetScript("OnShow", function(self)
	self:SetScript("OnShow", nil)
	self:SetPoint("TOPLEFT", "CompactRaidFrameManagerDisplayFrame", "TOPLEFT", 0, 0)
	self:SetPoint("BOTTOMRIGHT", "CompactRaidFrameManagerDisplayFrame", "BOTTOMRIGHT", 0, 0)

	local CompactDisplay = self:CreateTexture(nil, "BORDER")
	CompactDisplay:SetPoint("TOPLEFT", "CompactRaidFrameManagerDisplayFrame", "TOPLEFT", 0, 0)
	CompactDisplay:SetPoint("BOTTOMRIGHT", "CompactRaidFrameManagerDisplayFrame", "BOTTOMRIGHT", 0, 0)
	CompactDisplay:SetBackdropColor(0.2,0.2,0.2,0.8)
	
	CloseFrame:SetPoint("LEFT", "CompactFrame", "RIGHT", 0, 0)
	CloseFrame:SetText("<")
	CloseFrame:CreateTexture(nil, "BORDER")
	CloseFrame:SetBackdropColor(0.2,0.2,0.2,0.8)
	CloseFrame:SetTextColor(classcolor.r, classcolor.g, classcolor.b)
	CloseFrame:SetTexture(MEDIAPATH .. "RightBarButton")
	
	CloseFrame:SetScript("OnClick", function()
	PlaySoundFile(CLICK)
	CloseFrame()
	end)
	
	CloseFrame:SetScript("OnEnter", function()
	local _, class = UnitClass("player");
		if class == "PRIEST" then
			CloseFrame:SetTextColor(1,0,0)
		else
			CloseFrame:SetTextColor(1,1,1)
		end
	end)
	
	CloseFrame:SetScript("OnLeave", function()
	CloseFrame:SetTextColor(classcolor.r, classcolor.g, classcolor.b)
end)



Open:SetScript("OnShow", function(self)
	self:SetScript("OnShow", nil)
	self:SetPoint("CENTER", "UIParent", "CENTER", 0, 0)
	self:CreateTexture(nil, "HIGH")
	self:SetBackdropColor(0.2,0.2,0.2,0.8)
	
	local OpenText = self:CreateFontString(nil, "HIGH")
	OpenText:SetFont(FONT, 14)
	OpenText:SetTextColor(classcolor.r, classcolor.g, classcolor.b)
	OpenText:SetText(">")
	self:SetNormalTexture(MEDIAPATH .. "RightBarButton")
	
	self:SetScript("OnClick", function()
	PlaySoundFile(CLICK)
	OpenFrame()
	end)
	
	self:SetScript("OnEnter", function()
	local _, class = UnitClass("player");
		if class == "PRIEST" then
			self:SetTextColor(1,0,0)
		else
			self:SetTextColor(1,1,1)
		end
	end)
	
	self:SetScript("OnLeave", function()
	self:SetTextColor(classcolor.r, classcolor.g, classcolor.b)
	end)
end)
  Reply With Quote
05-17-13, 12:16 PM   #2
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
One obvious thing I see is that you misspelled the event. The event for entering an instance is "PLAYER_ENTERING_WORLD", however, this triggers after the instance/login loading bar completes but not when the player actually joins a raid.

The event to check if you are in a party or raid is GROUP_ROSTER_UPDATE.

I believe this triggers when you join a party, leave a party, join a raid, leave a raid, when the raid roster is sorted, or when another player joins or leaves a raid. not sure about the arguments however

The function to check if you are in a raid is IsInRaid()

Last edited by ravagernl : 05-17-13 at 12:19 PM.
  Reply With Quote
05-17-13, 01:51 PM   #3
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
You seem to be doing alot of 'things' unrelated to skinning.

Unless I misunderstood your original post.
If you just want to change the appearance of the raid manager you don't need any of that code.

You just need to identify the art resources used in the default and override them (textures, borders, fonts, colors etc)
  Reply With Quote
05-17-13, 04:06 PM   #4
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by ravagernl View Post
One obvious thing I see is that you misspelled the event. The event for entering an instance is "PLAYER_ENTERING_WORLD", however, this triggers after the instance/login loading bar completes but not when the player actually joins a raid.

The event to check if you are in a party or raid is GROUP_ROSTER_UPDATE.

I believe this triggers when you join a party, leave a party, join a raid, leave a raid, when the raid roster is sorted, or when another player joins or leaves a raid. not sure about the arguments however

The function to check if you are in a raid is IsInRaid()
Thank you I knew something there was wrong but not sure what to use. I tried a few different types but not that one so I will try!

Originally Posted by Dridzt View Post
You seem to be doing alot of 'things' unrelated to skinning.

Unless I misunderstood your original post.
If you just want to change the appearance of the raid manager you don't need any of that code.

You just need to identify the art resources used in the default and override them (textures, borders, fonts, colors etc)
Sounds interesting and a lot more simple but not sure how to do any of that lol
Will definitely look into it though thanks

Last edited by Mayron : 05-17-13 at 04:08 PM.
  Reply With Quote
05-17-13, 10:04 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Also, creating global names like "Open" and "Close" is a bad idea. Don't do it.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
05-18-13, 10:49 AM   #6
Sharparam
A Flamescale Wyrmkin
 
Sharparam's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 102
Unless I'm missing something, the "Open", "Close" vars et.c are all declared as local.
  Reply With Quote
05-18-13, 11:08 AM   #7
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by F16Gaming View Post
Unless I'm missing something, the "Open", "Close" vars et.c are all declared as local.
Global names, 2nd argument in CreateFrame is "Open" and "Close".
  Reply With Quote
05-18-13, 11:37 AM   #8
Sharparam
A Flamescale Wyrmkin
 
Sharparam's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 102
Oh derp, missed those :P
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help with addon!


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