I'm a bit stuck at the moment. My goal was to create a chi tracker in Weakauras that also had "shadows" representing the future income of chi. This took into account that you would get 2 chi with Power Strikes active. By default this actually worked marvelously, but I was a little annoyed with the bars always appearing, even outside of combat, but I also wanted to know how much chi I had the moment ANYBODY in my group entered combat. What I have should work (based on my new understanding of Lua and WoW API) but it doesn't, in fact NONE of the chi bars are appearing now, no matter what amount of chi that I have. I'm also unsure as how to check if I currently have "power strikes" on my character. The best way that I have found so far is comparing UnitBuff name output to the name of the buff provided in my chiCheck function.
I'm currently running code to functions in my own addon script to check if anybody is in combat and if there is enough chi. I did this mostly to save space and to make it easier to change the bulk of the code easily in the future.
Note: chiReq changes for each weakaura, but I leave it as 2 by default.
Anyways here are bits of my code:
Code:
AK = {};
function AK.groupCombatCheck()
local groupNum = GetNumGroupMembers();
local inCombat = UnitAffectingCombat("player");
if inCombat == 1 then
return true;
else
for i = 1, groupNum, 1 do
inCombat = UnitAffectingCombat(("party"..i) or ("raid"..i));
if inCombat == 1 then
return true;
end
end
end
return false;
end
function AK.chiCheck(chi, buff, chiReq, sChi)
local pBuff = "Power Strikes";
local pass = false;
if sChi then
if chi == chiReq - 1 then
return true;
elseif chi == chiReq - 2 then
if buff == pBuff then
return true;
end
end
else
if chi == chiReq then
return true;
end
end
return false;
end
This is my own custom script. The first function (groupCombatCheck) seems right, but I'm a little worried about the whole "party"..i and "raid"..i bit.
Code:
function()
local sChi = false;
local chi = UnitPower("player",12) or 0;
local pBuff = UnitBuff("player","power strikes");
local chiReq = 2;
if AK.groupCombatCheck() then
if AK.chiCheck(chi, pBuff, chiReq, sChi) then
return true;
end
end
return false;
end
This is my custom trigger in Weakauras for the solid (not "shadow") bars. sChi represents this fact and lets it evaluate the proper code in chiCheck in the previous code segment.
Code:
function()
local sChi = false;
local chi = UnitPower("player",12) or 0;
local pBuff = UnitBuff("player","power strikes");
local chiReq = 2;
if not AK.groupCombatCheck() then
return true;
elseif not AK.chiCheck(chi, pBuff, chiReq, sChi) then
return true;
end
return false;
end
This is the untrigger for the above code.
The only difference between those two code segments and my shadow trigger and untrigger is that sChi is set equal to true at the beginning.
I hope this was formatted well enough and that anybody on Earth can understand what I did haha.