Balance Power Tracker

BalancePowerTracker is an addon designed to provide a highly configurable bar to track Lunar/Solar energy, Eclipse direction and Peak buff.
It also can fire wanrnings when you gain Eclipse and provides energy prediction.
It's focused on using the CPU strictly necessary and no more.

PREDICTED ENERGY:
Predicted energy analizes your current cast/GCD and adds its cast time to your current energy, so BPT predicts where your energy is going to be, and if you are going to proc any Peak or not.
Unlike former versions, calculating predicted energy is now more difficult (due to fast switch when near 0 and lag), so it's done by approximation. This means that prediction accuracy is no longer 100% (near 100 and -100 is pretty much completely accurate and near 0 you can get +2/-2, usually +1/-1 averaged)
You can configure the indicators (bar,text,icons,arrow) of the mod to either display predicted or real info.
Also, you can configure the alerts to fire when you are going to get a Peak.
(Author's note: I feel Predicted Energy is the heart of BPT, I think without this option I wouldn't have made this addon, also it has taken up most of the time invested in the addon, however, I understand people value the choice to turn this off. At least, give it a try!)
WARNING: Euphoria is untested and Astral Communion error margin is higher

Provides LibSharedMedia, Masque & MikSBT support:

LibSharedMedia: Bar textures, alert sounds, fonts

Masque: Eclipse icons skin

MikSBT: Fire alerts through MikSBT

FAQ:

Can I disable it out of combat?
You can't disable it out of combat, but you can turn the Alpha Out Of Combar to 0, so it won't bother you (CPU load out of combat is pretty much 0).

The energy seems a little erratic...?
Predicted energy & peak are enabled by default, with this enabled, the mod will add the energy of you current cast to the bar, if you only want to change the size & position of the energy bar, I suggest you to uncheck this option.

Is there any way to have the awesome Blizzard art?
Enable default art module, you'll get a bar like Blizzard's with some options (not nearly as many as with the Eclipse bar module).

Green bar:
BPT is unable to access the bar/border texture, check if you have uninstalled it.

How do I configure it?
Type /bpt, in the tab "addons" you will find all the options for BPT.

Castbar mode ...? When casting a spell, the Eclipse bar will turn in a sort of castbar, still showing the arrow and the energy text. Just have this in mind: this isn't a castbar mod, so it shouldn't replace it, but this option reduces the places you need to have your eyes on (you need to have the spark enabled).

ADDON AUTHORS:

LibBalancePowerTracker
In v1.1.0 the energy track and predict features were moved into a library called LibBalancePowerTracker. This library is standalone and will avoid loading itself more than once. The API is commented in the first lines of LibBalancePowerTracker-2.0.lua.

v 2.0.1 Updated LibBalancePowerTracker to v2.0.1:
Improved death recognition
Fixed Euphoria detection
Improved Euphoria prediction
Removed unused public var warnedVEclipse in EclipseBar
Added timer to peak buff, can be shown either as CD (works with OmniCC), text or both

v 1.2.0 FIX: Now working in 4.2 patch.
FIX: Updated libraries.
FEATURE: BalancePowerTracker_Pipe: now you can use BPT's values in PowerAuras when this module is loaded.
FEATURE: BalancePowerTracker_Log: Found a bug? Please, log it with this tool.
CHANGE: BalancePowerTracker_Options: BPT's options were moved into a new AddOn in order to free a little memory.

v 1.1.8 FIX: Now working in 4.1 patch.
LibBalancePowerTracker:
Future log compatibility functions
The mark shouldn´t 'dance' at 0,100 and -100 energy anymore.
Extra functions to avoid letting a spell remain in the queue when it must be erased.

v 1.0.8 FIX: Showing addon when visible was not enabled
FEATURE: BalancePowerTracker_SharedInfo.hidden added
FEATURE: BalancePowerTracker_SharedInfo.enabled added
FEATURE: MSBT support
FEATURE: Text color and size can be changed
FEATURE: Icon offset can be changed
FIX: Position sliders gap reduced
CHANGE: Some functions moved from ADDON_LOADED to PLAYER_LOGIN, shouldn't be any problem
FIX: Removed LibButtonFacade, but ButtonFacade is still supported
CHANGE: Hiding behaviour improved
FIX: Arrow not working like it should after teleporting

v 1.0.7 FIX: Showing default blizz frame when getting out of vehicle
FIX: Not showing the foresee energy bar when reaching end
FIX: Bar not updating when teleporting & changing form at the same time
FIX: Enlarging both icons when there was no eclipse direction
FEATURE: Arrow can be scaled
FEATURE: Eclipse icons can be hidden
FEATURE: Show addon when not in Caster/Moonkin Form option
FEATURE: Border color can be changed
FEATURE: Added option to color the entire bar based on direction (You can select the info used to color the bar)
FEATURE: /bpt & /balancepowertracker show the config window
CHANGE: You can now select the info displayed on the icons (before, it used arrow's info)
CHANGE: Icons can be scaled
FEATURE: Original Icons can be selected (Need some tweaks)
FEATURE: ButtonFacade support
FEATURE: Bar can be set to vertical or horizontal
FEATURE: Added public functions to enable/disable/show/hide the addon and to start/stop foreseeing energy

v 1.0.5 Created & using SpellQueue ADT, easier to maintain code
In text you can configure which energy should be displayed
In arrow you can configure which info should be displayed
You can hide the former "addEnergy" bar without losing the benefits of Foresee energy
Add energy renamed to "Foresee energy"
Options clarified

v 1.0.3 Uptaded "add energy" to the last ptr build (13082)
You can choose between arrow instead and spark (if you choose arrow, the text will move so you can see the arrow)
You can hide the energy text
New function added: Warnings
Bunch of minor bugs fixes

v 1.0.2 Uptaded "add energy" to the last ptr build (13033):
-SS fixed energy
-fixed WR sometimes 14 energy
-smoothly!
-unregister its events when not using it, to free CPU
Fixed checking form when not having all forms trained
Info box in style tab
Strata and alpha can be changed!
v 1.0.1 Fixed Blizz Frame showing when not Balance and some bugs also with Blizz Frame & Power tracker
Fixed missing lib
v 1.0.0 Release

I would to know if it would be possible to build the option in to change the arrow to either the Starfire or Wrath icon depending on which side your building towards. Or perhaps add the Starfire / wrath icon middle top of the bar itself, basicly a visual indication of which spell you should be casting ?

I know this might sound silly, but for a non to experienced balance druid this might be a very nice aid. (toggleable ofcourse for those that think its not needed)

I'll check as soon as I can, I'm really busy with exams now.
I don't think the two are related because to include BPT in the Options UI I use the functions Blizzard provides, but you've given me an idea, BPT includes a library to make the options dialog broader, maybe I should test it without the library.

Originally posted by Shadowlycaon Beautiful, works a charm. Learned a whole lot, thanks for the tutorial. Keep up the fantastic work. Would you prefer Kurohoshi (EU-Minahonda) or Copialinex for credit?

I'm glad it worked, I advise you to wait till I update LibBalancePowerTracker with the PvP bonus (maybe till Saturday or Sunday GMT) so you include the last version.
Copialinex vs Kurohoshi: Use the one you like more, I will answer at both
Thanks for using LibBalancePowerTracker, and giving me credit!

Originally posted by Shadowlycaon
[b]Thank you very much, got it all set up and looking good. Having an issue with Virtual Energy though. I can't seem to be able to detect virtual energy. I get a value for it, but only after a spell has been cast, making it pretty much useless. I have the calculation under the following events:
UNIT_SPELLCAST_SUCCEEDED
UNIT_SPELLCAST_FAILED
UNIT_SPELLCAST_INTERRUPTED
UNIT_SPELLCAST_SENT
COMBAT_LOG_UNFILTERED -->

SPELL_ENERGIZE
SPELL_MISS
SPELL_DAMAGE

Am I missing one? Or perhaps just missing something all together?

LBPT uses the same events to recalculate energy, so if your client fires first your addon's events, when checking the LBPT vars will find nothing has changed.

You only need 1 of those functions:
If you want to retrieve the energy vars, it should be like this:
function EclipseInfo()
energy, direction, virtual_energy, virtual_direction, reach_end = LibBalancePowerTracker:GetEclipseEnergyInfo()
end
The callback only needs to be registered once, you are registering one different callback each time you call EclipseInfo().

What I'd do:
Get ridden of the above events (unless you use them for something else)
Creating a function that updates the addon using the info
LibBalancePowerTracker:RegisterFullCallback(function(...) UpdateMyAddon(...) end) on, for example PLAYER_LOGIN

Thank you very much, got it all set up and looking good. Having an issue with Virtual Energy though. I can't seem to be able to detect virtual energy. I get a value for it, but only after a spell has been cast, making it pretty much useless. I have the calculation under the following events:
UNIT_SPELLCAST_SUCCEEDED
UNIT_SPELLCAST_FAILED
UNIT_SPELLCAST_INTERRUPTED
UNIT_SPELLCAST_SENT
COMBAT_LOG_UNFILTERED -->

I'd use the library, I've left the table because maybe some other addons use it.
The table is fairly simple, it has 13 fields, 3 (beginning with capital letters) are functions to manage the addon, the other are read-only fields that store the values of the variables used by BPT.

The library is easier, you just need to include it in your addon (the library will avoid loading twice, and it will leave the more updated version)
First, the variables used by LibBalancePowerTracker:

energy: The energy you have at the moment. Int = [-100,100]
direction: The direction of the arrow. String = {"none","sun","moon"}
virtual_energy: The energy you will have when the spell you're casting and all the flying spells land. Int = [-100,100]
virtual_direction: The direction of the arrow when the spell you're casting and all the flying spells land. String = {"none","sun","moon"}
reach_end: If you reach 100 or -100 virtual energy when calculating the virtual_energy, the value is stored here, false otherwise.

Once it's loaded, you register a callback. The callback will be fired whenever one of the values related to the callback changes. There are two types of callback, I've named them "Full" and "Reduced", the Full Callback will be fired when one of the five variables changes (Usually twice per SF/WR/SS), the Reduced Callback only is fired when energy or direction change (Usually once per SF/WR/SS).
You can always check the state of the variables using the LibBalancePowerTracker:GetEclipseEnergyInfo() function (Don't worry about CPU usage of the library, it maintains a buffer with the variables, it only recalculates them when they change)

The API is the following:

id = LibBalancePowerTracker:RegisterFullCallback(function)
The callback will be fired with the following arguments: callback(energy, direction, virtual_energy, virtual_direction, reach_end)
NOTE: When registering a callback, that callback will be fired once.

id = LibBalancePowerTracker:RegisterReducedCallback(function)
The callback will be fired with the following arguments: callback(energy, direction)
NOTE: When registering a callback, that callback will be fired once.

failed = LibBalancePowerTracker:UnregisterCallback(id)
Tries to unregister the callback with identifier id (id is returned only when you register the callback).

energy, direction, virtual_energy, virtual_direction, reach_end = LibBalancePowerTracker:GetEclipseEnergyInfo()
Gets the current state of the variables.

version,subversion,revision = LibBalancePowerTracker:GetVersion()
Gets the current working version of the library.

For example, BPT does this in PLAYER_LOGIN
LibBalancePowerTracker:RegisterFullCallback(function(...) BalancePowerTracker:RecalcEnergy(...) end);

You only need to register one type of callback, the Reduced one is included in case you don't want to use the foresee feature.
To load the library, you can have BPT, since this addon loads it, or you can include it in your addon structure and reference it in your .toc

Also, you can use the following command if you want to understand better when callbacks are fired and the values. (You are registering a callback that prints the values in chat)
/script LibBalancePowerTracker:RegisterFullCallback(function(...) print(...) end);

Originally posted by Shadowlycaon Firstly, brilliant addon. Your addons are always just what moonkins need.

I have a rather out-of-date addon I'm updating atm(Shadow's Eclipse Monitor) and thought I'd try to incorporate your libary/public table. I however, have not much of an idea of how. Would you be kind enough to give me a quick couple of pointers on integrating your libary into an addon? Functions to register it etc...Credit will of course be given at all possible points. I understand how to use the variables in the table, just having my addon recognise those variables is giving me trouble.

P.S. I know my addon is horribly disjointed script wise. Was my first attempt at an addon having no scripting background.

I have a rather out-of-date addon I'm updating atm(Shadow's Eclipse Monitor) and thought I'd try to incorporate your libary/public table. I however, have not much of an idea of how. Would you be kind enough to give me a quick couple of pointers on integrating your libary into an addon? Functions to register it etc...Credit will of course be given at all possible points. I understand how to use the variables in the table, just having my addon recognise those variables is giving me trouble.

P.S. I know my addon is horribly disjointed script wise. Was my first attempt at an addon having no scripting background.

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.