Thread Tools Display Modes
09-10-09, 12:27 PM   #1161
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
self.Experience.Rested:SetParent(self.Experience)

voilą that should do the trick.
 
09-10-09, 12:40 PM   #1162
Icerat
A Fallenroot Satyr
Join Date: Sep 2006
Posts: 28
wow thanks for the fast reply where would i put that?

Sorry I'm a nub but learning i hope lol


EDIT: Figured it out many thanks Rostok, been a long day at work

Last edited by Icerat : 09-10-09 at 12:45 PM. Reason: Solved it
 
09-10-09, 12:52 PM   #1163
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Rostok View Post
self.Experience.Rested:SetParent(self.Experience)

voilą that should do the trick.
Rather use self.Experience as the 3rd argument in CreateFrame
 
09-13-09, 03:23 PM   #1164
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
So here I am, writing yet another oUF layout based on p3lim's great work. And also, here I am, finding yet another problem writing tags for myself to use.

I'm trying to get my power text for players/pets powertype-colored and shortened to "11.2k" for example. But this just won't work the way I want it to.

(Warning for long paste, could make a pastey if wanted)
Code:
local format = string.format
local gsub = string.gsub

local colors = setmetatable({
	power = setmetatable({
		['MANA'] = {0, 144/255, 1}
	}, {__index = oUF.colors.power}),
	reaction = setmetatable({
		[2] = {1, 0, 0},
		[4] = {1, 1, 0},
		[5] = {0, 1, 0}
	}, {__index = oUF.colors.reaction}),
}, {__index = oUF.colors})

local function shortVal(value)
	if(value >= 1e6) then
		return ('%.2fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1')
	elseif(value >= 1e4) then
		return ('%.1fk'):format(value / 1e3):gsub('%.?0+([km])$', '%1')
	else
		return value
	end
end

local function hex(r, g, b)
	if(type(r) == 'table') then
		if(r.r) then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end
	end
	return ('|cff%02x%02x%02x'):format(r * 255, g * 255, b * 255)
end

oUF.Tags['[ppower]'] = function(unit)
	local _, str = UnitPowerType(unit)
	local mini = UnitPower(unit)
	return ('%s%d|r'):format(hex(colors.power[str] or {1, 1, 1}), shortVal(mini))
end
The error I get (oh and this is a lot...) is this.
Code:
Message: Interface\AddOns\oUF_Hariyama\tags.lua:40: bad argument #1 to 'format' (number expected, got string)
Time: 09/13/09 23:22:45
Count: 44660
Stack: [string "Interface\FrameXML\BasicControls.xml:<Scrip..."]:18: in function <[string "Interface\FrameXML\BasicControls.xml:<Scrip..."]:4>
[C]: ?
[C]: in function `format'
Interface\AddOns\oUF_Hariyama\tags.lua:40: in function `func'
Interface\AddOns\oUF\elements\tags.lua:402: in function `UpdateTag'
Interface\AddOns\oUF\elements\tags.lua:259: in function <Interface\AddOns\oUF\elements\tags.lua:255>

Locals: (*temporary) = "%d"
(*temporary) = ""
(*temporary) = "18.6k"
(*temporary) = 0
(*temporary) = "number expected, got string"
I just don't see what the problem is, can anyone shed some light upon this please?

- Wimpzter.
__________________
All I see is strobe lights blinding me in my hindsight.
 
09-13-09, 04:26 PM   #1165
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Wimpface View Post
So here I am, writing yet another oUF layout based on p3lim's great work. And also, here I am, finding yet another problem writing tags for myself to use.

I'm trying to get my power text for players/pets powertype-colored and shortened to "11.2k" for example. But this just won't work the way I want it to.
Code:
oUF.Tags['[ppower]'] = function(unit)
	local _, str = UnitPowerType(unit)
	local mini = UnitPower(unit)
	return ('%s%s|r'):format(hex(colors.power[str] or {1, 1, 1}), shortVal(mini))
end
%d needs a digit, while 'k' is a letter, you would need %s so it accept strings.
 
09-13-09, 04:27 PM   #1166
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
This will do what you want:

Code:
function round(num, idp)
  if idp and idp>0 then
    local mult = 10^idp
    return math.floor(num * mult + 0.5) / mult
  end
  return math.floor(num + 0.5)
end

function CoolNumber(num)
    if num>999 then
        return round(num/1e3,0).."K"
    else
        return num
    end
end
The red number can be 0,1, ... while 0 means 18400 becomes 18k ... 1 means 18400 becomes 18.4k, etc.
 
09-13-09, 04:29 PM   #1167
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
Thanks Dawn! I'm going to try it out.

EDIT: Thanks p3lim aswell, I'm trying both things out but p3lim's solutions seems simpler.

EDIT2: p3lim's solution worked a charm! I never actually tested Dawn's one.
__________________
All I see is strobe lights blinding me in my hindsight.

Last edited by Wimpface : 09-13-09 at 04:32 PM.
 
09-14-09, 04:29 AM   #1168
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
The code works. I'm using it. Just wanted to point that out if others are interested, too.
 
09-14-09, 01:56 PM   #1169
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Dawn View Post
This will do what you want:

Code:
function round(num, idp)
  if idp and idp>0 then
    local mult = 10^idp
    return math.floor(num * mult + 0.5) / mult
  end
  return math.floor(num + 0.5)
end

function CoolNumber(num)
    if num>999 then
        return round(num/1e3,0).."K"
    else
        return num
    end
end
The red number can be 0,1, ... while 0 means 18400 becomes 18k ... 1 means 18400 becomes 18.4k, etc.
using the formatting I use (supports millions aswell)
Code:
local function shortVal(value)
	if(value >= 1e6) then
		return ('%.2fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1')
	elseif(value >= 1e4) then
		return ('%.1fk'):format(value / 1e3):gsub('%.?0+([km])$', '%1')
	else
		return value
	end
end
green numbers represent the amount of decimals shown.
 
09-14-09, 06:16 PM   #1170
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
I have been trying to add oUF_Reputation support but to no avail, I've added the code needed (atleast I think so, copied from the oUF_Experience code I had from p3lim's layout and modified a bit ) and added oUF_Reputation to my TOC's metadata.

This is the code I have, gives no error. It just won't show the actual bar.
Code:
		if IsAddOnLoaded('oUF_Reputation') and UnitLevel("Player") == 80 then
			self.Reputation = CreateFrame('StatusBar', nil, self)
			--self.Reputation:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -20)
			--self.Reputation:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', 0, -20)
			self.Reputation:SetPoint('CENTER', self, 'CENTER', 0, -116)
			self.Reputation:SetHeight(11)
			self.Reputation:SetWidth(416)
			self.Reputation:SetStatusBarTexture(barTex)
			self.Reputation:SetStatusBarColor(0.15, 0.7, 0.1)
			self.Reputation.Tooltip = true
			
			self.Reputation.Text = self.Reputation:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall')
			self.Reputation.Text:SetPoint('CENTER', self.Reputation)
			
			self.Reputation.bg = self.Reputation:CreateTexture(nil, 'BORDER')
			self.Reputation.bg:SetAllPoints(self.Reputation)
			self.Reputation.bg:SetTexture(0.3, 0.3, 0.3)
		end
__________________
All I see is strobe lights blinding me in my hindsight.
 
09-14-09, 09:02 PM   #1171
wurmfood
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 122
I assume you're only loading this if the unit == player. Otherwise, you'll load it for any unit so long as the player level is 80.

However, you also need to have "player" all in lowercase.
 
09-15-09, 01:46 AM   #1172
leyrhao
A Defias Bandit
AddOn Compiler - Click to view compilations
Join Date: Apr 2009
Posts: 2
Hi.

I want to change the player's bars growth from right to left instead of left to right but as much as I search I can't find a way to make it. Any little help on how could I make it?

Thanks
 
09-15-09, 02:43 AM   #1173
Wimpface
A Molten Giant
 
Wimpface's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 648
Originally Posted by wurmfood View Post
I assume you're only loading this if the unit == player. Otherwise, you'll load it for any unit so long as the player level is 80.

However, you also need to have "player" all in lowercase.
Yes, I am only loading it for unit == 'player', and thanks. I'm going to try it in about 20 minutes when the servers go up.

EDIT2: Fixed it.
__________________
All I see is strobe lights blinding me in my hindsight.

Last edited by Wimpface : 09-15-09 at 03:02 AM.
 
09-15-09, 08:41 AM   #1174
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by leyrhao View Post
Hi.

I want to change the player's bars growth from right to left instead of left to right but as much as I search I can't find a way to make it. Any little help on how could I make it?

Thanks
PostUpdateHealth function, use :SetValue(max - min)
Also use :SetMinMaxValues(max, 0)
 
09-15-09, 10:27 AM   #1175
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
I was wondering, would it be possible to have the following:

Health bar:
- tapped, disconnected: grey
- or just blackish, solid color

Name text:
- classcolored always, with outline

Health bar background:
- classcolored always

Power bar:
- normal color.

Is this possible to achieve without PostUpdateHealth?
 
09-15-09, 10:33 AM   #1176
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by mrruben5 View Post
I was wondering, would it be possible to have the following:

Health bar:
- tapped, disconnected: grey
- or just blackish, solid color

Name text:
- classcolored always, with outline

Health bar background:
- classcolored always

Power bar:
- normal color.

Is this possible to achieve without PostUpdateHealth?
All of them are possible, but why without using PostUpdateHealth?
You'd have to register new events a function else.
 
09-15-09, 08:11 PM   #1177
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
You'd only need to use PostUpdateHealth for the health bar background. For everything else you don't need (and shouldn't use) PostUpdateHealth.

Code:
self.Health.colorTapping
self.Power.colorPower
For class colored names just use a tag function, and use :SetFont on your fontstring to take care of the outline.

Code:
-- drycode
oUF.TagEvents['[mylayoutname]'] = oUF.TagEvents['[name]']
oUF.Tags['[mylayoutname]'] = function(unit)
	local c = RAID_CLASS_COLORS[select(2, UnitClass(unit))]
	return format('|cff%02x%02x%02x%s', c.r * 255, c.g * 255, c.b * 255, UnitName(unit))
end

edit: PostUpdateHealth would probably be overkill for the class colored background as well, since you don't need it to be called extraneously after health updates. It's a much cleaner solution to register your own event, imo... Not that it's significant either way.

Last edited by Waverian : 09-15-09 at 08:13 PM.
 
09-16-09, 03:09 AM   #1178
NeverD1e
A Murloc Raider
Join Date: Aug 2008
Posts: 5
Smile

Hello everyone, I'm bad know Lua.
Help bring the code with this:

local function truncate(value)
if(value >= 1e6) then
return gsub(format('%.2fm', value / 1e6), '%.?0+([km])$', '%1')
elseif(value >= 1e5) then
return gsub(format('%.1fk', value / 1e3), '%.?0+([km])$', '%1')
else
return value
end
end

Such:

1603022>1,603k
725622>725,6k
11813>11,8k
9156>9,1k
937>937


And with this:

oUF.TagEvents['[customstatus]'] = 'UNIT_HEALTH'
oUF.Tags['[customstatus]'] = function(unit)
return not UnitIsConnected(unit) and PLAYER_OFFLINE or UnitIsGhost(unit) and 'Ghost' or UnitIsDead(unit) and DEAD
end

oUF.TagEvents['[customhp]'] = 'UNIT_HEALTH UNIT_MAXHEALTH'
oUF.Tags['[customhp]'] = function(unit)
local status = oUF.Tags['[customstatus]'](unit)
local min, max = UnitHealth(unit), UnitHealthMax(unit)

local r,g,b = ColourGradient(min/max)

return status and status or
(unit ~= 'player' and unit ~= 'target' and min-max ~= 0) and format('|cff%02x%02x%02x%s|r', r, g, b, truncate(min-max)) or
(unit == 'target' and min - max == 0) and format('|cff%02x%02x%02x%s|r', r, g, b, truncate(max)) or
(min - max == 0) and format('%s', '') or
(unit == 'target' or unit == 'player') and format('|cff00FF00%s|r . |cff%02x%02x%02x%s|r %d%%', truncate(max), r, g, b, truncate(min), floor(min/max*100)) or
(min~=max) and format('%s |cff0090ff/|r %s', truncate(min), truncate(max)) or max
end


Such:

If player or target then
If min~=max then
show max
If max<100% then
show min | max

If targettarget or pet or focus then

If min~=max then
show max
If max<100% then
show min

If party or raid then

If min~=max then
show max
If max<100% then
show -(min-max)

I suffer for a long time, help me please.
 
09-16-09, 05:31 AM   #1179
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by Waverian View Post
You'd only need to use PostUpdateHealth for the health bar background. For everything else you don't need (and shouldn't use) PostUpdateHealth.

Code:
self.Health.colorTapping
self.Power.colorPower
For class colored names just use a tag function, and use :SetFont on your fontstring to take care of the outline.

Code:
-- drycode
oUF.TagEvents['[mylayoutname]'] = oUF.TagEvents['[name]']
oUF.Tags['[mylayoutname]'] = function(unit)
	local c = RAID_CLASS_COLORS[select(2, UnitClass(unit))]
	return format('|cff%02x%02x%02x%s', c.r * 255, c.g * 255, c.b * 255, UnitName(unit))
end

edit: PostUpdateHealth would probably be overkill for the class colored background as well, since you don't need it to be called extraneously after health updates. It's a much cleaner solution to register your own event, imo... Not that it's significant either way.
Thanks, that's exactly the info I was hoping for
 
09-16-09, 06:34 AM   #1180
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Mhm, why not simply put the [raidcolor] tag in before the [name] tag?
 

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF - Layout discussion


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