[Suggestion] CastSpellByName hook and ranks
Voidmenull opened this issue ยท 4 comments
your CastSpellByName hook does not support ranks - therefor macros with ranks will not work,
i fixed it like that:
edit: damn github xD
http://i.imgur.com/GunMZjl.png
well, ppl have to use case sensitive macros :)
my version does work without (rank x) since gfind function will be skipped
"[1-9]" is not a good idea, since they are spells like frostbolt with more ranks :)
cheers, you can close the topic
edit: speaking of frostbolt, your database is missing R11: http://db.vanillagaming.org/?item=21214
In the version you posted there was no name=text (i think xD). Also, it's not just "[1-9]", it's "[1-9]%d*" so that the number cannot be 0.
Thanks. Think it would work anyway because I default to the highest rank if the index is too large, but added it for consistency :)
Hm, there is another issue which I couldn't be bothered to fix which is why I'd left it like this: The argument to this function doesn't have to match the case of the tooltip spell name. To fix it one would have to convert the whole spell database to lower/uppercase and also add that everywhere an effect is retrieved from the API.
As for your pattern, I've made some modifications. Yours doesn't work if there is no rank and also rank should be case insensitive. Here's my current version:
do
local orig = CastSpellByName
function _G.CastSpellByName(text, onself)
if not onself then
local _, _, name, rank = strfind(text, '(.*)%([Rr][Aa][Nn][Kk] ([1-9]%d*)%)')
name = name or text
casting[name] = {unit=TARGET_ID, rank=tonumber(rank)}
end
return orig(text, onself)
end
end