View Single Post
10-16-22, 08:29 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
You're addon is probably running the code before Bartender has initialised the bars. This usually happens at a specific event that fires during the game loading sequence.

It's also why it works when you're already in the game tesing in WowLua.

Try something like:

Lua Code:
  1. function ParseSpellName(spellId)
  2.    local spellName, spellSubName, _ = GetSpellInfo(spellId);
  3.    if spellSubName then
  4.       return string.format("%s(%s)", spellName, spellSubName)
  5.    else
  6.       return spellName
  7.    end
  8. end
  9.  
  10.  
  11. local f = CreateFrame("Frame")
  12. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  13. f:SetScript("OnEvent", function(self, event, ...)
  14.     self:UnregisterAllEvents() -- PLAYER_ENTERING_WORLD will fire every time you see a loading screen so, stop that happening
  15.     local button = BT4Button73
  16.     local slot = button:GetAttribute('action');
  17.     local actionType, actionId, _ = GetActionInfo(slot);
  18.     if (actionType == 'spell') then
  19.        local command = string.format("/use [@mouseover]%s", ParseSpellName(actionId))
  20.        print(command);
  21.     end
  22. end)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote