WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Race & class (https://www.wowinterface.com/forums/showthread.php?t=32874)

weasoug 06-01-10 07:42 AM

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.

Dawn 06-01-10 07:59 AM

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? :rolleyes:

Just some thoughts on information that you shouldn't care about.

weasoug 06-01-10 08:13 AM

Quote:

Originally Posted by Dawn (Post 190419)
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? :rolleyes:

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

Dawn 06-01-10 08:53 AM

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.

weasoug 06-01-10 09:43 AM

Quote:

Originally Posted by Dawn (Post 190428)
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

weasoug 06-01-10 10:53 AM

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


p3lim 06-01-10 12:45 PM

check if self.Class exists first

Dawn 06-01-10 04:47 PM

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


weasoug 06-01-10 07:17 PM

thank you for your time Dawn., i will look into this tomorrow. thanks.

Waverian 06-01-10 09:42 PM

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.

Dawn 06-02-10 08:24 AM

Quote:

Originally Posted by Waverian (Post 190587)
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. :)

weasoug 06-02-10 11:58 AM

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.

weasoug 06-02-10 05:10 PM

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.

p3lim 06-03-10 08:36 AM

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.

weasoug 06-03-10 11:41 AM

Quote:

Originally Posted by p3lim (Post 190815)
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

Dawn 06-03-10 12:59 PM

There's at least one "end" to much or to less. Leaving a function open or closing it to early.

weasoug 06-03-10 02:07 PM

Quote:

Originally Posted by Dawn (Post 190857)
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)

Dawn 06-03-10 02:32 PM

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". :)

weasoug 06-03-10 03:04 PM

Quote:

Originally Posted by Dawn (Post 190865)
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

Rostok 06-04-10 12:28 AM

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).


All times are GMT -6. The time now is 06:42 PM.

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