Can the API check against a resource, such as insanity?

I have an old weakaura string I would like to update to get working again after SL mechanic changes to Shadowpriest. The old string was checking for stackcount while in voidform. I would like to change it so that it it instead checks my insanity resource. If interested, the full string can be found below the dashed line.

Reading the string, i can see that it is rolling through the combat log to find successful spell casts and then checking for the stackcount, but I just cant figure out how to switch it over to check the insanity resource instead.


function(self, targ, …)
local type = select(1, …)
local source = select(4, …)
local name = UnitName(“player”)
if(source == name) then
if(type == “SPELL_CAST_SUCCESS” or type == “SPELL_ENERGIZE”) then
local stackCount = -1
for i = 1, 40 do
local name, _, count = UnitAura(“player”, i, “HELPFUL”)
if(name == “voidform”) then
stackCount = count
break
end
end
local chance = 1;
local max = 80;
if(stackCount > 0) then
local x = stackCount / 100;
x = (x^3) * max;
chance = 3 + x;
end
local ids = {14372, 14373, 14374, 14375, 15780, 15779, 15759, 15760, 15757, 15758, 15756, 15764, 15766, 8580, 8581, 8582, 8583, 8584, 8585, 8586, 8587, 37142, 37145, 37146, 37147, 37148, 37149, 38763, 38764, 38765, 38766, 38767, 38768, 38769, 38771, 38772, 38773, 38774, 38775, 38776, 38777, 38780, 38781, 38783, 38785, 58912, 58913, 58914, 58915,58916, 58917, 58918, 58926, 58933 }
local max = table.getn(ids)
local index = math.random(1, max)
local rand = math.random(0, 100)
if(rand < chance) then
PlaySound(ids[index], “Master”)
end
end
end
end

local name, _, count = UnitAura("player", i, "HELPFUL")
Needs to be replaced with a UnitPower check.
local count = UnitPower("player",13)

https://wow.gamepedia.com/API_UnitPower

Ah, did not realize that player resources were tagged as power. Ill drop this into the string when i get a chance tonight. Thx!

Appreciate the link as well. I should be able to copy this over to my Paladin and play around with it too now.

There’s also built-in triggers for it.
Type: Status
Status: Power
Power Type: Insanity