Untested but this should be close. I used macro attribute instead of spell so it is more generic this way
Lua Code:
local button_table = {}
local name_mod = {"","_CTRL","_SHIFT","_CTRL_SHIFT"}
local bind_mod = {"","CTRL-","SHIFT-","CTRL-SHIFT-"}
for i=1,24 do
button_table[i] = {}
for j=1,4 do
local button_name = "weirdbutton"..name_mod[j].."_F"..i --for example: weirdbutton_F1 or weirdbutton_CTRL_SHIFT_F24
local keybind = bind_mod[j].."F"..i --for example: F1 or CTRL-SHIFT-F24
button_table[i][j] = CreateFrame("Button",button_name,nil,"SecureActionButtonTemplate")
button_table[i][j]:SetAttribute("type","macro")
SetBindingClick(keybind,button_name)
end
end
--use this function when you want to refer to a button by its sequential number: 1 to 96
local function get_button(number)
local i,j = floor((button_number+3)/4),(button_number+3)%4+1 --for example: 62 -> (16,2) -> CTRL-F16
return button_table[i][j]
end
--setting a particular button to a macro that cast a spell
local button_number = 62
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")