Spells with Charges

90 Undead Warlock
3975
Is there currently any way to track the number of charges spells like conflag have?

I've been unsuccessfully playing with power auras (the MoP beta version) and searching various forums without luck. I haven't even really found anyone discussing the issue.

If this doesn't exist, can anyone tell me if it's because spells having charges is new and it hasn't been handled, or if the in-game information won't allow an addon to track this data at this point in time?

Thanks
Reply Quote
90 Gnome Warrior
12355
Does Power Auras have a place to script conditions?

GetSpellCharges("Conflagrate") will return the number of charges. It's a new function in 5.0 so Power Auras will probably need updated to support it if it doesn't already.
Reply Quote
83 Gnome Mage
5070
09/23/2012 06:53 AMPosted by Caman
If this doesn't exist, can anyone tell me if it's because spells having charges is new and it hasn't been handled, or if the in-game information won't allow an addon to track this data at this point in time?

New MoP API function GetSpellCharges. Seems implemented for spells only (at least GetItemCharges was unavailable when I was trying to call it, like mana gem's charges)
Reply Quote
90 Gnome Warrior
12355
GetItemCount("item name",nil,1) will return number of charges an item like a HS has.

GetActionCharges will work for action buttons.
Reply Quote
83 Gnome Mage
5070
09/23/2012 10:14 AMPosted by Ro
GetActionCharges will work for action buttons

Except I need it for my "FlyoutButton Custom" and new one "TinyExtraBars", buttons not action based.
Reply Quote
90 Gnome Warrior
12355
Yeah you would use GetItemCount or GetSpellCharges if it's not one of the canonical 120 action bar buttons. I thought that was axiomatic. :p

btw if you're the author of FlyoutButton Custom and it's the addon I'm thinking of, you can change the button in combat to cast the last picked item/spell. Set a frame reference to the action button and a pre/post-click wrapper set the action button's attributes to the button clicked. You can grab the code from Select (on wowinterface) if interested.
Reply Quote
83 Gnome Mage
5070
09/23/2012 10:44 AMPosted by Ro
Yeah you would use GetItemCount or GetSpellCharges if it's not one of the canonical 120 action bar buttons

In case of items like "Mana gem" GetItemCount returns 1 while gem can have up to 3 charges.

btw if you're the author of FlyoutButton Custom and it's the addon I'm thinking of, you can change the button in combat to cast the last picked item/spell. Set a frame reference to the action button and a pre/post-click wrapper set the action button's attributes to the button clicked. You can grab the code from Select (on wowinterface) if interested.

But how to assign it to action button in combat? For Blizzard action buttons (and for Bartender and Dominos it seems) I'm using 4 params to cursor and PlaceAction call. Hard part is to put info into protected buttons. If it possible would be nice (old style totem buttons back again). Ok, it seems I'm understanding ... Will try.
Reply Quote
90 Undead Warlock
3975
Does Power Auras have a place to script conditions?

GetSpellCharges("Conflagrate") will return the number of charges. It's a new function in 5.0 so Power Auras will probably need updated to support it if it doesn't already.


Thanks for the responses both of you.

Power Auras has a box that you can input text that a tooltip should contain. I'm assuming that it's a condition; I'll play around with it later.

If that doesn't do anything, at the least the new function gives me hope something will turn up eventually.
Reply Quote
83 Gnome Mage
5070
you can change the button in combat to cast the last picked item/spell. Set a frame reference to the action button and a pre/post-click wrapper set the action button's attributes to the button clicked. You can grab the code from Select (on wowinterface) if interested.

I can find according action button through SetFrameRef/GetFrameRef, but can't figure how to change action in combat (changing attributes "type" to "spell" etc have no effect). If there some obvious way to do it - I can't see it. Is there thread on Wowinterface with example?
Reply Quote
90 Gnome Warrior
12355
Give me a few hours to get some free time I'll see what I can mock up.

btw on the GetItemCount, use GetItemCount("Mana Gem",nil,1) (or true or whatever for third argument).
Reply Quote
83 Gnome Mage
5070
09/23/2012 03:32 PMPosted by Ro
btw on the GetItemCount, use GetItemCount("Mana Gem",nil,1) (or true or whatever for third argument)

Thanks, that works :)

09/23/2012 03:32 PMPosted by Ro
Give me a few hours to get some free time I'll see what I can mock up

Of course I can wait, thanks for help.
Reply Quote
90 Gnome Warrior
12355
Apparently since you have frames all parented to the action buttons you don't even need frame references.

I added 3 lines to FlyoutListButtonOnClickWrapScript:
local FlyoutListButtonOnClickWrapScript = [=[
local listFrame = self:GetParent()
if listFrame then
local arrowBtn = listFrame:GetParent()
if arrowBtn then
arrowBtn:SetAttribute("expanded", false)
listFrame:Hide()
end
local actionButton = arrowBtn:GetParent()
actionButton:SetAttribute("type",self:GetAttribute("type"))
actionButton:SetAttribute(self:GetAttribute("type"),self:GetAttribute(self:GetAttribute("type")))

end
]=]

which doesn't appear to set the attributes, but it does. That action button now, when clicked, will perform the action clicked in the above snippet.

The issue is now getting the button to reflect the attributes it now contains. You don't want to taint the action buttons so it has to be done carefully, but everything (SetTextures, SetVertexColors, SetTexts) is now unsecure work you can do in combat too.

I chose MultiBarBottomRightButton8 as a test button and did a hooksecurefunc on its icon's SetTexture. I don't recommend doing a hooksecurefunc for all 120 buttons on something that can be called a lot. If I were to do this myself I'd create a 1-frame OnUpdate that shows on registered events to reassert its texture/vertex/text (and then hides after running its code until the next event); then when leaving combat actually pick up the chosen item or spell and put it in its place on the action button (this would make the button remember its state on reload/logins too). So you have hook-free updates to changes in combat, and out of combat (or in combat when the button isn't changed) the action button's own code can handle all the updates.

-- self:SetTexture post-hooked just to MultiBarBottomRightButton8Icon
-- self is the icon in icon:SetTexture(stuffToIgnore)
local function ourOwnSetTexture(self)
if self.settingOurOwnSetTexture then
return -- we triggered this SetTexture, ignore
else
local attribType = self:GetParent():GetAttribute("type")
local attribValue = self:GetParent():GetAttribute(attribType)
local texture
-- get a texture from the action button's attributes
if attribType == "item" then
texture = select(10,GetItemInfo(attribValue))
elseif attribType == "spell" then
texture = GetSpellTexture(attribValue)
end
if texture and self:GetTexture() ~= texture then
-- remember this whole function is called by SetTexture
-- we don't want to call ourselves in reaction to one
self.settingOurOwnSetTexture = 1
self:SetTexture(texture)
self.settingOurOwnSetTexture = nil
end
end
end

-- didn't look into it deeply, but your buttons weren't defined for
-- a few seconds after login. This 1-frame OnUpdate waits 5 seconds
-- after login to set up MultiBarBottomRightButton8
local f=CreateFrame("Frame")
f:SetScript("OnUpdate",function(self,elapsed)
self.timer = self.timer + elapsed
if self.timer > 5 then -- waiting 5 seconds after login to run this
self:Hide() -- only running below code once

-- this is a post-hook on any SetTexture done to our test button
hooksecurefunc(MultiBarBottomRightButton8Icon,"SetTexture",ourOwnSetTexture)

-- all this just adds a PostClick to each ListFrameButton1..n (didn't dig
-- through code to find a better place to insert ourOwnSetTexture)
MultiBarBottomRightButton8CustomFlyoutListFrame:HookScript("OnShow",function(self)
local i=1
local button
repeat
button = _G[self:GetName().."ListButton"..i]
if button and not button.postClickAdded then
button:SetScript("PostClick",function()
-- force a SetTexture to the action's icon
ourOwnSetTexture(self:GetParent():GetParent().icon)
end)
button.postClickAdded = 1
end
i=i+1
until not button
end)

end
end)
f.timer = 0


edit: sorry OP for hijacking your thread!
Edited by Ro on 9/24/2012 3:11 AM PDT
Reply Quote
83 Gnome Mage
5070
-- didn't look into it deeply, but your buttons weren't defined for
-- a few seconds after login. This 1-frame OnUpdate waits 5 seconds
-- after login to set up MultiBarBottomRightButton8

The problem is: I'm waiting for macro info retrieved by client to properly initialize macro buttons (2 types separated: global and per character, waiting for 2 events). And now with battlepets I should wait even more for its API ready (else I can't even retrieve textures - API returns nils). More than that battlepet API initialization too slow and in recent version (on my PC) I should also check am I in combat already since battlepet API can be initialized later than I have InCombat state (/reload while in combat - cant create buttons or frames).

Thanks for code, going to implement right now.
Reply Quote
83 Gnome Mage
5070
Works (well, changed some stuff) except tooltips. Is there any workarounds to change tooltips in combat for action buttons? Right now I'm using "override_pending" attribute and making full parent button update on PostClick with "override_pending" enabled.

Thanks, much better than before :)

Edit: uploaded fresh v2.40 on WoWInterface (always feel guilty uploading on curse - people there spending near 6 hours to approve).
Edited by Dussy on 9/24/2012 7:16 AM PDT
Reply Quote
90 Gnome Warrior
12355
Nice! I'll check it out tonight if MoP preparations don't get me.

You can do a hooksecurefunc(GameTooltip,"SetAction",etc) to insert your own tooltips. That function isn't called a lot.

I hadn't uploaded an addon to curse in years. Tried the other day and it's just as awful as I remember when they switched to the curseforge thing. No regrets ignoring it for a few more years here.
Reply Quote
83 Gnome Mage
5070
You can do a hooksecurefunc(GameTooltip,"SetAction",etc) to insert your own tooltips. That function isn't called a lot.

Thanks, did as local actionButton = GameTooltip:GetOwner()
if actionButton then
local flyoutButtonName = actionButton:GetAttribute("tooltip_source")
if flyoutButtonName then
local flyoutButton = _G[flyoutButtonName]
if flyoutButton then
flyoutButton:UpdateTooltip()
end
end
end

Actually it called a lot since tooltip update stuff assigned to many action button events in WoW UI ActionButton.lua
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Reason
Explain (256 characters max)
Submit Cancel

Reported!

[Close]