Thread Tools Display Modes
10-21-12, 08:21 AM   #1
[email protected]
A Kobold Labourer
AddOn Author - Click to view addons
Join Date: Oct 2012
Posts: 1
Need some help to change the way to show enermy's HP

As I said, I'm looking for a lua to change the form of number display from 123,456 to 123k. How to do that?
  Reply With Quote
10-21-12, 07:56 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Code:
local function Abbreviate(value)
	if type(value) == "string" then
		value = tonumber(gsub(value, "%D", ""))
	end

	local absvalue = abs(value)

	if absvalue >= 10000000 then
		return format("%.1fm", value / 1000000)
	elseif absvalue >= 1000000 then
		return format("%.2fm", value / 1000000)
	elseif absvalue >= 100000 then
		return format("%.0fk", value / 1000)
	elseif absvalue >= 1000 then
		return format("%.1fk", value / 1000)
	end

	return value
end
Without more information from you -- such as where in the UI you are trying to replace text -- I can't be more specific, or even tell you whether the above code is relevant to your problem. Please be more specific.
__________________
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

WoWInterface » Developer Discussions » Lua/XML Help » Need some help to change the way to show enermy's HP


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