Skip to content

Commit

Permalink
GetSpellBookItemName now used to iterate over spellbook instead of Ge…
Browse files Browse the repository at this point in the history
…tNumSpellTabs, since the latter does not reliably return all known spells.

fixes:Softrix#9
credit: Mokay https://discord.com/channels/697774223833170000/864095814950977557/1066432962582806548

Signed-off-by: speedwaystar <[email protected]>
  • Loading branch information
speedwaystar committed Feb 3, 2023
1 parent e4811f2 commit d7dd6ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
29 changes: 6 additions & 23 deletions SmartBuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
-- Cast the most important buffs on you, tanks or party/raid members/pets.
-------------------------------------------------------------------------------

SMARTBUFF_DATE = "240123";
SMARTBUFF_DATE = "030223";

SMARTBUFF_VERSION = "r18."..SMARTBUFF_DATE;
SMARTBUFF_VERSIONNR = 100002;
SMARTBUFF_VERSIONNR = 100003;
SMARTBUFF_TITLE = "SmartBuff";
SMARTBUFF_SUBTITLE = "Supports you in casting buffs";
SMARTBUFF_DESC = "Cast the most important buffs on you, your tanks, party/raid members/pets";
Expand Down Expand Up @@ -924,32 +924,17 @@ end

-- Get Spell ID from spellbook
function SMARTBUFF_GetSpellID(spellname)
local i, id = 1, nil;
local spellN, spellId, skillType;
if (spellname) then
spellname = string.lower(spellname);
else
return nil;
end

local i = 0;
local nSpells = 0;
local id = nil;
local spellN, spellId, skillType;

-- Get number of spells
--for i = 1, GetNumSpellTabs() do
-- Common and specialization
for i = 1, GetNumSpellTabs() do
local _, _, _, n = GetSpellTabInfo(i);
nSpells = nSpells + n;
end

i = 0;
while (i < nSpells) do
i = i + 1;
while GetSpellBookItemName(i, BOOKTYPE_SPELL) do
spellN = GetSpellBookItemName(i, BOOKTYPE_SPELL);
skillType, spellId = GetSpellBookItemInfo(i, BOOKTYPE_SPELL);
--print(spellN.." "..spellId);

if (skillType == "FLYOUT") then
for j = 1, GetNumFlyouts() do
local fid = GetFlyoutID(j);
Expand All @@ -965,20 +950,18 @@ function SMARTBUFF_GetSpellID(spellname)
end
end
end

if (spellN ~= nil and string.lower(spellN) == spellname) then
id = spellId;
break;
end
i = i + 1;
end

if (id) then
if (IsPassiveSpell(id) or skillType == "FUTURESPELL" or not IsSpellKnown(id)) then
id = nil;
i = nil;
end
end

return id, i;
end
-- END SMARTBUFF_GetSpellID
Expand Down
4 changes: 2 additions & 2 deletions SmartBuff.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 100002
## Interface: 100005
## Title: SmartBuff |cffffffff(Retail)|r by |cff00ff00Codermik & Aeldra|r
## Version: 18.100002
## Version: 18.100003
## Author: |cff20d2ffCodermik & Aeldra|r (EU-Proudmoore)
## Contributing Author: |cff20d2ffSpeedwaystar
## Notes: Cast the most important buffs on you or party/raid members/pets. Use /sbm for options menu.
Expand Down

0 comments on commit d7dd6ba

Please sign in to comment.