Thread Tools Display Modes
04-06-16, 02:03 PM   #1
Psylock
A Murloc Raider
Join Date: May 2007
Posts: 4
OUF_text health help

In the code he is calling abreviatelargenumbers(hp). This fine but how can we change this to show one or two decimal places?

Thank you
  Reply With Quote
04-07-16, 06:12 AM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
I use this one in my unitframes:

Lua Code:
  1. local function Short(value)
  2.     if(value >= 1e6) then
  3.         return gsub(format('%.2fm', value / 1e6), '%.?0+([km])$', '%1')
  4.     elseif(value >= 1e4) then
  5.         return gsub(format('%.1fk', value / 1e3), '%.?0+([km])$', '%1')
  6.     else
  7.         return value
  8.     end
  9. end

If the value is a million or above it shows two decimal points, if it's above 10000 it shows one decimal, and anything below that shows the full value.
  Reply With Quote
04-07-16, 06:56 PM   #3
Psylock
A Murloc Raider
Join Date: May 2007
Posts: 4
That's fine and I've seen that code before but how to work it into the following is my issue...
Code:
--Short HP Tag
oUF.Tags.Events["shorthp"] = "UNIT_HEALTH"
oUF.Tags.Methods["shorthp"] = function(unit)
	if not UnitIsDeadOrGhost(unit) then
		local hp = UnitHealth(unit)
		return AbbreviateLargeNumbers(string.format("%.0f",hp))
	end
end
  Reply With Quote
04-07-16, 07:51 PM   #4
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 309
Place his function somewhere near the top of the tags file. Then change your code to:
Code:
--Short HP Tag
oUF.Tags.Events["shorthp"] = "UNIT_HEALTH"
oUF.Tags.Methods["shorthp"] = function(unit)
	if not UnitIsDeadOrGhost(unit) then
		local hp = UnitHealth(unit)
		return Short(hp)
	end
end
__________________
AddOns: Tim @ WoWInterface
Battle Tag: Mysterio#11164
Current PC Setup: PCPartPicker List
  Reply With Quote
04-07-16, 08:22 PM   #5
Psylock
A Murloc Raider
Join Date: May 2007
Posts: 4
thank you very much
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » OUF_text health help


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