View Single Post
10-05-15, 04:49 PM   #2
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
Untested but this should be close. I used macro attribute instead of spell so it is more generic this way
Lua Code:
  1. local button_table = {}
  2. local name_mod = {"","_CTRL","_SHIFT","_CTRL_SHIFT"}
  3. local bind_mod = {"","CTRL-","SHIFT-","CTRL-SHIFT-"}
  4. for i=1,24 do
  5.     button_table[i] = {}
  6.     for j=1,4 do
  7.         local button_name = "weirdbutton"..name_mod[j].."_F"..i --for example: weirdbutton_F1 or weirdbutton_CTRL_SHIFT_F24
  8.         local keybind = bind_mod[j].."F"..i                     --for example: F1 or CTRL-SHIFT-F24
  9.         button_table[i][j] = CreateFrame("Button",button_name,nil,"SecureActionButtonTemplate")
  10.         button_table[i][j]:SetAttribute("type","macro")
  11.         SetBindingClick(keybind,button_name)
  12.     end
  13. end
  14.  
  15.  --use this function when you want to refer to a button by its sequential number: 1 to 96
  16. local function get_button(number)
  17.     local i,j = floor((button_number+3)/4),(button_number+3)%4+1 --for example: 62 -> (16,2) -> CTRL-F16
  18.     return button_table[i][j]
  19. end
  20.  
  21. --setting a particular button to a macro that cast a spell
  22. local button_number = 62
  23. get_button(button_number):SetAttribute("macrotext","/use Cold Blood") --if button_number==62 then it is the same thing as button_table[16][2]:SetAttribute("macrotext","/use Cold Blood")
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill

Last edited by Banknorris : 10-05-15 at 09:25 PM.
  Reply With Quote