View Single Post
02-16-15, 04:31 PM   #20
Malsomnus
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Apr 2013
Posts: 203
Thanks for all the help and explanations

After a lot of experimentation around semlar's code, I technically have a button that switches one talent for me every time I press it. I haven't gotten around to trying to make it work for several talents yet, but here's the code I have so far, in case somebody finds it useful:

Lua Code:
  1. function pickTalent(row,col)
  2.   local s = [[
  3.     /stopmacro [combat]
  4.     /click PlayerTalentFrameTalentsTalentRow%sTalent%s
  5.     /click StaticPopup1Button1
  6.   ]]
  7.   return s:format(row,col)
  8. end
  9.  
  10. f.btn = CreateFrame ("Button", nil, f, 'SecureActionButtonTemplate, SecureHandlerBaseTemplate')
  11. f.btn:RegisterForClicks ("AnyDown")
  12. f.btn:SetAttribute ("type","macro")
  13. f.btn:SetAttribute ('macrotext', pickTalent(1,2))
  14.  
  15. f.btn:SetScript ('PostClick', function()
  16.   C_Timer.After(1, function ()
  17.     PlayerTalentFrameTalentsLearnButton:GetScript("OnClick")(PlayerTalentFrameTalentsLearnButton)
  18.   end)  
  19. end)
__________________
SanityCheck - If you've ever said the words "Sorry, I forgot" then you need this add-on.

Remember, every time you post a comment on an add-on, a kitten gets its wings!
  Reply With Quote