Thread Tools Display Modes
06-01-10, 07:42 AM   #1
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Post Race & class

Hi there all.

I just wanted to ask. if there is a Layout already made. or where i could start.

what it is. i was thinknig alot of the layouts i find use

UnitClass & UnitRace

but end up with the full race and class name. i wanted to make a plugin that shortens this.

ie.

Like
Draenei - Death Knight

Class - Death Knight TO 'DK'
Race - Draenei to 'D'

this i guess moght have a floor. but i think you see like shorted down vers of partys and so on. race and class.


thanks for you time.
  Reply With Quote
06-01-10, 07:59 AM   #2
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
What about
"a class colored name or bar or whatever"?

and
"a DK is a DK is a DK"

so forget about the freaking race?

Just some thoughts on information that you shouldn't care about.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
06-01-10, 08:13 AM   #3
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Originally Posted by Dawn View Post
What about
"a class colored name or bar or whatever"?

and
"a DK is a DK is a DK"

so forget about the freaking race?

Just some thoughts on information that you shouldn't care about.
lol. well thanks for your reply. already have the class colored name in the setup.


so say your a mage. you mana bar looks like this

Code:
80 Human Mage 100%
now from what you said. i might remove the Race.
and try to add Class icons. i think i remember cogumel0 doing somthing like this.

but then do i add them into the mana bar.

but i still would like to add a text format. im not big into icons. other then lfd leader ect. lol
  Reply With Quote
06-01-10, 08:53 AM   #4
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
If class colors are insufficient for you, try something like this:

Code:
local classabbrev = {
      Mage = "Mg",
      Warlock = "Wl",

}
create a fontstring ... like self.Class or whatever you want
Code:
	self.Class:SetText(classabbrev[UnitClass(unit)])
Note this is theory, untested, but it's something to start with.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
06-01-10, 09:43 AM   #5
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Originally Posted by Dawn View Post
If class colors are insufficient for you, try something like this:

Code:
local classabbrev = {
      Mage = "Mg",
      Warlock = "Wl",

}
create a fontstring ... like self.Class or whatever you want
Code:
	self.Class:SetText(classabbrev[UnitClass(unit)])
Note this is theory, untested, but it's something to start with.
nice i think that might do it. i will work on it. and let you know

thanks again
  Reply With Quote
06-01-10, 10:53 AM   #6
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
well this is what i did

Code:
local classabbrev = {
      Druid = "Dd",
      Hunter = "Hr",
      Mage = "Mg",
      Paladin = "Pd",
      Priest = "Pt",
      Rogue = "Rg",
      Shaman = "Sm",
      Warlock = "Wl",
      Warrior = "Wr",
      Deathknight = "Dk",

}
and i added that into the local part of the code.

the in the self part. i put

Code:
self.Class:SetText(classabbrev[UnitClass(unit)])
but i got this error

Code:
Interface\AddOns\oUF_Test\oUF_Test.lua:634: attempt to index field 'Class' (a nil value)
Count: 1

Call Stack:
[C]: ?
Interface\AddOns\oUF_Test\oUF_Test.lua:634: in function `styleFunc'
Interface\AddOns\oUF\ouf.lua:421: in function <Interface\AddOns\oUF\ouf.lua:413>
Interface\AddOns\oUF\ouf.lua:492: in function <Interface\AddOns\oUF\ouf.lua:488>
Interface\AddOns\oUF\ouf.lua:543: in function `Spawn'
Interface\AddOns\oUF_Test\oUF_Test.lua:743: in main chunk
  Reply With Quote
06-01-10, 12:45 PM   #7
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
check if self.Class exists first
  Reply With Quote
06-01-10, 04:47 PM   #8
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Quick walkthrough

Code:
-- this needs to be defined before the function you use to update the font string (see below)
local classabbrev = {
      Druid = "DR",
      Hunter = "HT",
      Mage = "MG",
      Paladin = "PD",
      Priest = "PT",
      Rogue = "RG",
      Shaman = "SH",
      Warlock = "WL",
      Warrior = "WR",
      Deathknight = "DK",
}
I did put this in my updateHealth function, you can use another function to update it, though.
Code:
local updateHealth = function(self, event, unit, bar, min, max)
	self.Class:SetText((classabbrev[UnitClass(unit)]) or (UnitCreatureType(unit)))  -- set abbreviated class text if unit is a player AND set creature type for NPCs
end

Code:
-- create the font string
	self.Class = self.Health:CreateFontString(nil, "ARTWORK")
	self.Class:SetFont(FontName, FontSize, FontFlag)
	self.Class:SetTextColor(1,1,1) -- white or whatever ...

Code:
    if (unit == "target") or (unit == "focus") then -- define the frames on which the font string should be shown
		self.Class:SetPoint("TOP", self.Health, "BOTTOM", 0, 4) -- define position
	end
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
06-01-10, 07:17 PM   #9
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
thank you for your time Dawn., i will look into this tomorrow. thanks.
  Reply With Quote
06-01-10, 09:42 PM   #10
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
You should change the table keys to match the second return from UnitClass so that it's locale independent. The format is the English name is all capital letters with spacing removed. MAGE, HUNTER, DEATHKNIGHT etc.
  Reply With Quote
06-02-10, 08:24 AM   #11
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Originally Posted by Waverian View Post
You should change the table keys to match the second return from UnitClass so that it's locale independent. The format is the English name is all capital letters with spacing removed. MAGE, HUNTER, DEATHKNIGHT etc.
Yeah, good point, at least if you are going to publish.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
06-02-10, 11:58 AM   #12
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
thanks again so much for the iput. i need to 1st remove the comment that my code has that show the race and class.

as im testing out on oUF Classic.
as i found on the fourm that is the best place to learn. so ive been adding LFG and other things i like in a ui. there are lots out there that tick alot of boxs.
  Reply With Quote
06-02-10, 05:10 PM   #13
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
ok well it all seems to be ok. by one bit.

Code:
local PostUpdatePower = function(self, event, unit, bar, min, max)
	self.Class:SetText((classabbrev[UnitClass(unit)]) or (UnitCreatureType(unit)))
end --i did try adding if and else and also elseif
	if(min == 0) then
		bar.value:SetText()
	elseif(UnitIsDead(unit) or UnitIsGhost(unit)) then
		bar:SetValue(0)
	elseif(not UnitIsConnected(unit)) then
		bar.value:SetText()
	else
		bar.value:SetFormattedText('%s/%s', siValue(min), siValue(max))
	end
end

now looking over it. the template im usen. i see this

Code:
		-- Info string
		local info = pp:CreateFontString(nil, "OVERLAY", "GameFontNormal")
		info:SetPoint("LEFT", 2, -1)
		info:SetPoint("RIGHT", -2, 0)
		info:SetJustifyH"LEFT"
		info:SetFont(GameFontNormal:GetFont(), 11)
		info:SetTextColor(1, 1, 1)

		self:Tag(info, 'L[level][shortclassification] [raidcolor][smartclass]')
		self.Info = info
	end
now when removed smartclass it dont show DRUID this is where i wanted to add DR.

and with the help from you guys. i think maybe what we have can be added into this. as that self tag is set up for level then class. i was thinking to add all the code ive had help make and just add classabbrev from the local updateHealth part. but it didnt work. i guess i dont know that code. at this point i did have the local classabbrev = { and the font string added./ so that way i was thinking not like

'L[level][shortclassification] [raidcolor][classabbrev]'

but

'L[level][shortclassification] [raidcolor][classabbrev[UnitClass(unit)]'


well again guys thanks for your time and help.
  Reply With Quote
06-03-10, 08:36 AM   #14
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
you need to create a new tag
Code:
oUF.Tags['shortclass'] = function(unit)
     local _, class = UnitClass(unit)
     return classabbrev[class]
end
oUF.TagEvents['shortclass'] = 'UNIT_NAME_CHANGED'
This is just an example though, the event might be wrong.
  Reply With Quote
06-03-10, 11:41 AM   #15
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Originally Posted by p3lim View Post
you need to create a new tag
Code:
oUF.Tags['shortclass'] = function(unit)
     local _, class = UnitClass(unit)
     return classabbrev[class]
end
oUF.TagEvents['shortclass'] = 'UNIT_NAME_CHANGED'
This is just an example though, the event might be wrong.
well i added this part you suggested and there was no error. but the levels didnt show on the bar. so i added

'L[level][shortclassification] [raidcolor][classabbrev[UnitClass(unit)]'
that didnt work. and this did not work also.

self.Class:SetText((classabbrev[UnitClass(unit)]) or (UnitCreatureType(unit)))
under the PostUpdatePower

i just get
Test.lua:103: '<eof>' expected near 'end'
Count: 1

Call Stack:
[C]: ?


thanks

Last edited by weasoug : 06-03-10 at 12:47 PM.
  Reply With Quote
06-03-10, 12:59 PM   #16
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
There's at least one "end" to much or to less. Leaving a function open or closing it to early.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
06-03-10, 02:07 PM   #17
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Originally Posted by Dawn View Post
There's at least one "end" to much or to less. Leaving a function open or closing it to early.
this is how i have it,


Code:
local PostUpdatePower = function(self, event, unit, bar, min, max)
	self.Class:SetText((classabbrev[UnitClass(unit)]) or (UnitCreatureType(unit)))
	end
	if(min == 0) then
		bar.value:SetText()
	elseif(UnitIsDead(unit) or UnitIsGhost(unit)) then
		bar:SetValue(0)
	elseif(not UnitIsConnected(unit)) then
		bar.value:SetText()
	else
		bar.value:SetFormattedText('%s/%s', siValue(min), siValue(max))
	end
end
and when i have it like

self.Class:SetText((classabbrev[UnitClass(unit)]) or (UnitCreatureType(unit)))

if(min == 0) then

i get the error


attempt to index field 'class' (a nil value)

Last edited by weasoug : 06-03-10 at 02:27 PM.
  Reply With Quote
06-03-10, 02:32 PM   #18
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
You are still trying to use the "self.Class" FontString from my example, without having it defined. Thus the error. You are using "info", replace self.Class with "self.info".
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
06-03-10, 03:04 PM   #19
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Originally Posted by Dawn View Post
You are still trying to use the "self.Class" FontString from my example, without having it defined. Thus the error. You are using "info", replace self.Class with "self.info".
well i did this you see the other day,

local class = pp:CreateFontString(nil, "OVERLAY", "GameFontNormal")
class = self.Health:CreateFontString(nil, "ARTWORK")
class:SetPoint("LEFT", 2, -1)
class:SetPoint("RIGHT", -2, 0)
class:SetJustifyH"LEFT"
class:SetFont(GameFontNormal:GetFont(), 11)
class:SetTextColor(1, 1, 1)

i made a fontstring. for the call to be handled.

well that is what i was thinking
  Reply With Quote
06-04-10, 12:28 AM   #20
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
add at the end of your fontstring declaration :
self.Class = class

That should do it (but remember self.Class and class are different till you say they're not).
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Race & class


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