Quantcast WoWInterface - View Single Post - Stuf LUA help
Thread: Stuf LUA help
View Single Post
10-03-15, 07:15 PM   #4
hikokun
A Murloc Raider
 
hikokun's Avatar
Join Date: Oct 2015
Posts: 4
Originally Posted by Nikita S. Doroshenko View Post
Lua Code:
  1. function(unit, cache, textframe)
  2.     local curhp, maxhp
  3.     if UnitExists(unit) then
  4.         curhp = UnitHealth(unit)
  5.         maxhp = UnitHealthMax(unit)
  6.     else
  7.         curhp = UnitHealth("player")
  8.         maxhp = UnitHealthMax("player")
  9.     end
  10.     local perchp = 100 * curhp/maxhp
  11.     local stamp = curhp.." / "..maxhp.." | ".."%.2f%%"
  12.     return stamp,perchp
  13. end
This one works perfect, thank you! I attempted (with no knowledge of lua) to also make it into the format of

60.00% | 300000/500000

but the text would disappear each time. How would I go about switching it around?

Edit:
Lua Code:
  1. function(unit, cache, textframe)
  2.         local curhp, maxhp
  3.         if UnitExists(unit) then
  4.             curhp = UnitHealth(unit)
  5.             maxhp = UnitHealthMax(unit)
  6.         else
  7.             curhp = UnitHealth("player")
  8.             maxhp = UnitHealthMax("player")
  9.         end
  10.         local perchp = 100 * curhp/maxhp
  11.         local stamp = "%.2f%%".." | "..curhp.." / "..maxhp
  12.         return stamp,perchp
  13.     end

Figured it out after messing around a bit! However, I've now noticed that the numbers are not being shortened (I have my STUF options to shorten starting at 1 million).

Instead of showing 1M, its showing 1000000. Any way to fix this?

Ideally I'd like it to show like this -

60.00% | 3.0M / 5.0M
5.00% | 250000 / 5.0M

Last edited by hikokun : 10-03-15 at 07:43 PM.
  Reply With Quote