WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   WoD Beta archived threads (https://www.wowinterface.com/forums/forumdisplay.php?f=151)
-   -   GetSpellInfo changes in WOD beta (https://www.wowinterface.com/forums/showthread.php?t=49493)

LeoChen1216 07-19-14 11:35 AM

GetSpellInfo changes in WOD beta
 
It seems Blizzard changed the return values for GetSpellInfo.
It used to be:
Code:

name, rank, icon, powerCost, isFunnel, powerType, castingTime, minRange, maxRange = GetSpellInfo(...)
Now, the "powerCost, isFunnel, powerType" values are removed. Does anyone know if there is any other API I can call to get these values?

Code:

name, rank, icon, castingTime, minRange, maxRange = GetSpellInfo(...)

Phanx 07-19-14 10:02 PM

You can use tooltip scanning. Set the spell to a tooltip, and then look at the text in the tooltip. Do a forum search if you need examples; I know there are tons, but I'm too lazy to find them for you right now.

Strange, though, that they'd remove information that's actually relevant, but leave the rank return, when spells haven't had ranks in years...

MuffinManKen 07-20-14 11:17 PM

I noticed another oddity with GetSpellInfo. When you call it in WoD with an invalid Spell ID it returns a table of 3 empty strings, while the current live (5.4) returns nil.

p3lim 07-21-14 12:37 AM

Quote:

Originally Posted by Phanx (Post 294076)
Strange, though, that they'd remove information that's actually relevant, but leave the rank return, when spells haven't had ranks in years...

arg2 is no longer rank, it's "spellSubName":
https://github.com/tekkub/wow-ui-sou...rnal.lua#L2291

Oddly enough, the old return values are still present in some code in the latest build, although not used (shaman totem bar):
https://github.com/tekkub/wow-ui-sou...Frame.lua#L963

Phanx 07-21-14 01:29 AM

Quote:

Originally Posted by p3lim (Post 294138)
Oddly enough, the old return values are still present in some code in the latest build, although not used (shaman totem bar):
https://github.com/tekkub/wow-ui-sou...Frame.lua#L963

It's not odd at all that they didn't bother updating that code, since the shaman totem bar was removed from the game with the launch of Cataclysm. :p

p3lim 07-21-14 05:30 AM

Quote:

Originally Posted by Phanx (Post 294142)
It's not odd at all that they didn't bother updating that code, since the shaman totem bar was removed from the game with the launch of Cataclysm. :p

They did update it to the new 1/nil true/false changes to :SetChecked(), but they might have automated that with a script or something.

LeoChen1216 07-21-14 06:49 PM

Quote:

Originally Posted by Phanx (Post 294076)
You can use tooltip scanning. Set the spell to a tooltip, and then look at the text in the tooltip. Do a forum search if you need examples; I know there are tons, but I'm too lazy to find them for you right now.

Strange, though, that they'd remove information that's actually relevant, but leave the rank return, when spells haven't had ranks in years...

great, thank you!

Phanx 07-22-14 12:16 AM

That's a lot of unnecessary overhead...

Code:

local name, some, other, vars, here = GetSpellInfo(12345)
if name and name ~= "" then
    -- carry on
end

Adding a simple equality check is a much better solution than adding two function calls.

jlam 10-11-14 11:17 AM

Quote:

Originally Posted by Phanx (Post 294076)
You can use tooltip scanning. Set the spell to a tooltip, and then look at the text in the tooltip. Do a forum search if you need examples; I know there are tons, but I'm too lazy to find them for you right now.

Strange, though, that they'd remove information that's actually relevant, but leave the rank return, when spells haven't had ranks in years...

I'm searching for a way to do this that's locale-independent. The tooltip has the information in a consistent place, but the format of that line differs between locales and also has to deal with singular/plural variations. I'm mostly struggling with the singular/plural part of it. Are there existing examples of getting this spell cost information from the tooltip?

Phanx 10-12-14 01:05 AM

The common texts in tooltips (X mana, Y rage, Z energy, etc.) all use strings from GlobalStrings.lua, so you can just pick out the strings (Blizzard uses them with string.format) and convert them for use with string.match.

For example, the "X mana" string is contained in the global variable MANA_COST, and I use the following code to make spell tooltips show the mana costs of spells as a percent of my total mana pool instead of as a raw number; the lines I highlighted in green will be the most relevant for you.

Code:

        local MANA_COST_PATTERN = gsub(MANA_COST, "%%d", "([%%d%.,]+)")
        local MANA_COST_TEXT = gsub(MANA_COST, "%%d", "%%d%%%%")

        GameTooltip:HookScript("OnTooltipSetSpell", function()
                for i = 2, 4 do
                        local line = _G["GameTooltipTextLeft"..i]
                        local text = line:GetText()
                        if text then
                                local cost = strmatch(text, MANA_COST_PATTERN)
                                cost = cost and tonumber((gsub(cost, "%D", "")))
                                if cost then
                                        local pool = UnitPowerMax(UnitInVehicle("player") and "vehicle" or "player")
                                        if cost > 0 and cost <= pool then
                                                return line:SetFormattedText(MANA_COST_TEXT, cost / pool * 100 + 0.5)
                                        end
                                        return
                                end
                        end
                end
        end)

Edit: You will need to do a little more work to "patternize" strings with singular/plural variations, but you should be able to figure it out pretty easily by looking at the global strings for each locale (link above).

jlam 10-12-14 01:56 AM

Ah, having GlobalStrings.lua for all locales will make this easier. Thanks for the link.


All times are GMT -6. The time now is 08:08 PM.

vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI