Thread Tools Display Modes
12-24-15, 01:55 PM   #1
Mirrikh
A Flamescale Wyrmkin
 
Mirrikh's Avatar
AddOn Compiler - Click to view compilations
Join Date: Sep 2011
Posts: 111
Custom Lua text StUF

As the title says, I need some help making a custom Lua tag for StUF. What I want is to have my current hp/mana shown, but as a whole number (without decimals). I know with other UF you can usually add a [short] tag to it and it'll work, but that doesn't seem to work with StUF. Any help is greatly appreciated.

Last edited by Mirrikh : 12-24-15 at 10:47 PM.
  Reply With Quote
12-27-15, 02:56 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
If you want to show the whole number, just pass the return value from UnitHealth (or whatever tagging-language-specific function gives you a unit's health) without any shortening or digit grouping decorators.

If you do that and you still see decimals (or commas; due to international differences, I'm not actually sure whether you're referring to the characters used for grouping digits in large integers, or for separating the non-integer portions of numbers) then you'll probably need to look for and disable whatever option in STUF is applying that formatting after the fact.
__________________
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
12-27-15, 06:03 PM   #3
Mirrikh
A Flamescale Wyrmkin
 
Mirrikh's Avatar
AddOn Compiler - Click to view compilations
Join Date: Sep 2011
Posts: 111
I've tried that and it just gives me the full number, I want it to show it shortened. Ex: 160.0k --> 160k, just want it without the decimal.
  Reply With Quote
01-01-16, 01:52 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Show your code.
__________________
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
01-01-16, 02:19 AM   #5
Mirrikh
A Flamescale Wyrmkin
 
Mirrikh's Avatar
AddOn Compiler - Click to view compilations
Join Date: Sep 2011
Posts: 111
I ended up getting some help on it. I'll post the code I got that works for anyone who needs it.

Player HP
Code:
function(unit, cache, textframe) 
 health=tonumber(UnitHealth("Player"))
   if health>=1000000 then
  return tostring(floor(health/1000000)) .. "M"
 elseif health>=1000 then
  return tostring(floor(health/1000)) .. "K"
 else
  return health
 end
end
Player Power
Code:
function(unit, cache, textframe) 
 power=tonumber(UnitPower("Player"))
   if power>=1000000 then
  return tostring(floor(power/1000000)) .. "M"
   elseif power>=1000 then
  return tostring(floor(power/1000)) .. "K"
 else
  return power
 end
end
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Custom Lua text StUF

Thread Tools
Display Modes

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