Thread Tools Display Modes
07-22-18, 09:47 AM   #1
Kenjub
A Deviate Faerie Dragon
Join Date: Jul 2018
Posts: 15
Need help with WA2 script for mana percentage

Hi! This worked fine pre 8.0, but as of 8.0 it just doesn't display anything:

Code:
function()
    local percent = (UnitMana("player")/UnitManaMax("player"))*100
    return floor(percent+0.5).."%"
end
what's wrong? Thanks!
  Reply With Quote
07-22-18, 10:58 AM   #2
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
https://www.townlong-yak.com/framexm..._7_2_0.lua#172
  Reply With Quote
07-22-18, 04:30 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
What Ammako is saying is that those functions have been deprecated for some time and were finally removed. Now you have to use their replacements.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-16-18, 05:58 AM   #4
Kenjub
A Deviate Faerie Dragon
Join Date: Jul 2018
Posts: 15
Undestood it from his reply but thanks (forgot to reply originally)

However what I need is alternate power percentage (in this case, Shadowpriest mana bar that shows below insanity bar). Any suggestions?
  Reply With Quote
09-16-18, 09:39 AM   #5
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
The Enum.PowerType.Mana shown in the linked code is a number. Here’s the full table:

Lua Code:
  1. Enum = {
  2.     PowerType = {
  3.         Alternate = 10,
  4.         ArcaneCharges = 16,
  5.         Chi = 12,
  6.         ComboPoints = 4,
  7.         Energy = 3,
  8.         Focus = 2,
  9.         Fury = 17,
  10.         HealthCost = -2,
  11.         HolyPower = 9,
  12.         Insanity = 13,
  13.         LunarPower = 8,
  14.         Maelstrom = 11,
  15.         Mana = 0,
  16.         None = -1,
  17.         NumPowerTypes = 19,
  18.         Obsolete = 14,
  19.         Obsolete2 = 15,
  20.         Pain = 18,
  21.         Rage = 1,
  22.         Runes = 5,
  23.         RunicPower = 6,
  24.         SoulShards = 7,
  25.     },
  26. }

Last edited by Kanegasi : 09-16-18 at 10:31 AM. Reason: tabs > spaces; sorted; removed brackets and quotes
  Reply With Quote
10-02-18, 06:27 PM   #6
Kenjub
A Deviate Faerie Dragon
Join Date: Jul 2018
Posts: 15
Originally Posted by Kanegasi View Post
The Enum.PowerType.Mana shown in the linked code is a number. Here’s the full table:

Lua Code:
  1. Enum = {
  2.     PowerType = {
  3.         Alternate = 10,
  4.         ArcaneCharges = 16,
  5.         Chi = 12,
  6.         ComboPoints = 4,
  7.         Energy = 3,
  8.         Focus = 2,
  9.         Fury = 17,
  10.         HealthCost = -2,
  11.         HolyPower = 9,
  12.         Insanity = 13,
  13.         LunarPower = 8,
  14.         Maelstrom = 11,
  15.         Mana = 0,
  16.         None = -1,
  17.         NumPowerTypes = 19,
  18.         Obsolete = 14,
  19.         Obsolete2 = 15,
  20.         Pain = 18,
  21.         Rage = 1,
  22.         Runes = 5,
  23.         RunicPower = 6,
  24.         SoulShards = 7,
  25.     },
  26. }
Thanks for the list but I'm a bit lost on how to incorporate it into my current code snippet.

The following shows the current main power amount, I need it to show alternate power percentage (in my case, mana) :
Code:
function()
    local percent = (UnitPower("player")/UnitPowerMax("player"))*100
    return floor(percent+0.5)..""
end
  Reply With Quote
10-02-18, 08:10 PM   #7
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
As the linked code above shows, UnitPower has two arguments: unit and type. Type is a number and is one of the numbers I posted above.

Usage: UnitPower(unit,type)

This returns player mana: UnitPower("player",0)

This returns player insanity: UnitPower("player",13)

This returns max player mana: UnitPowerMax("player",0)

This returns max player insanity: UnitPowerMax("player",13)
  Reply With Quote
10-02-18, 09:11 PM   #8
Kenjub
A Deviate Faerie Dragon
Join Date: Jul 2018
Posts: 15
I get it now, holy hell am I dense :|

Thanks for the help!
  Reply With Quote
10-02-18, 09:55 PM   #9
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
And if you don't want to remember what number is what power you can instead use:

Code:
Enum.PowerType.Mana
Enum.PowerType.Rage
Enum.PowerType.Focus
Enum.PowerType.Energy
Enum.PowerType.ComboPoints
Enum.PowerType.Runes
Enum.PowerType.RunicPower
Enum.PowerType.SoulShards
Enum.PowerType.LunarPower
Enum.PowerType.HolyPower
Enum.PowerType.Maelstrom
Enum.PowerType.Chi
Enum.PowerType.Insanity
Enum.PowerType.ArcaneCharges
Enum.PowerType.Fury
Enum.PowerType.Pain
Insanity = UnitPower("player", Enum.PowerType.Insanity)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help with WA2 script for mana percentage

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