Quantcast Would like to be able to scan all set attributes for a SecureActionButton - WoWInterface
Thread Tools Display Modes
04-24-19, 10:20 PM   #1
Nightness
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 30
Would like to be able to scan all set attributes for a SecureActionButton

I'm trying to make a (pseudo) GetAllSetAttributes function for use on SecureActionButtonTemplate. I'm looking to generate a table of all potential attributes that could be set using the attribute naming scheme for SecureActionButtonTemplate.
So here is an excerpt from a wiki on SecureActionButtonTemplate, as an example.

"type" Any clicks.
"*type1" Any left click.
"type1" Unmodified left click.
"shift-type2" Shift+right click. (But not Alt+Shift+right click)
"shift-type*" Shift+any button click.
"alt-ctrl-shift-type*" Alt+Control+Shift+any button click.

Rules
  • General order {modifiers-attribute-suffix}
  • Order of 'alt-ctrl-shift' is strict for modifiers. Also, for at least the 'spell' attribute, the format "modifiers-attribute-{nuke | heal}", is valid.
  • The 'attribute' part is required, other parts are not.
  • Asterisks can only be at the end (any button), beginning (any prior modifiers), or omitted. Note: I believe ctrl and shift can be straight up omitted, so "alt-attribute" should be valid. Not sure if "alt-*-attribute" is legal (matching both alt-shift and alt-ctrl).

Primary Attributes
Code:
local primaryAttributes = {
	"type", "spell", "item", "action", "macro", "macrotext",
 	"checkselfcast", "checkfocuscast", "toy", "flyoutDirection",
	"clickbutton", "unit", "marker", "harmbutton", "helpbutton",
	"attribute-name", "attribute-value", "actionpage",
	"downbutton", "unit-suffix", "toggleForVehicle", "allowVehicleTarget"
}
String parsing isn't my strong suit (I can do it), but if anyone has any ideas or suggestions, or wants a little fun challenge; the help would be appreciated. This is for my addon MagnetButtons, trying to add insertion of custom (not yet supported in the addon) attributes. I will give credit to anyone with viable code to use.

Reference: Format details

Last edited by Nightness : 04-25-19 at 04:31 AM.
  Reply With Quote
04-26-19, 08:36 PM   #2
Nightness
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 30
I need to learn regex

Code:
local primaryAttributes = {
	"type", "spell", "item", "action", "macro", "macrotext", "checkselfcast", "checkfocuscast",
	"toy", "flyoutDirection", "clickbutton", "unit", "marker", "harmbutton", "helpbutton", "attribute-name",
	"attribute-value", "actionpage", "downbutton", "unit-suffix", "toggleForVehicle", "allowVehicleTarget"
}

local function potentialProperties(startingTable, attr, prefix, suffix)
	if (type(attr) ~= "string") then return startingTable end
	if (prefix) then prefix = "*" else prefix = "" end
	if (suffix) then suffix = "*" else suffix = "" end
	table.insert(startingTable, prefix..attr..suffix)
	table.insert(startingTable, prefix.."alt-"..attr..suffix);
	table.insert(startingTable, prefix.."alt-ctrl-"..attr..suffix);
	table.insert(startingTable, prefix.."alt-shift-"..attr..suffix);
	if (prefix ~= "*") then
		table.insert(startingTable, prefix.."alt-ctrl-shift-"..attr..suffix);
	end
	table.insert(startingTable, prefix.."ctrl-"..attr..suffix);
	table.insert(startingTable, prefix.."ctrl-shift-"..attr..suffix);
	table.insert(startingTable, prefix.."shift-"..attr..suffix);
	return startingTable;
end

local function generateAllPossibleAttributes()
	local results = { };
	for attribIndex,attrib in ipairs(primaryAttributes) do
		results = potentialProperties(results, attrib, false, false)
		results = potentialProperties(results, attrib, false, true)
		results = potentialProperties(results, attrib, true, false)
		results = potentialProperties(results, attrib, true, true)
		for idx = 1, 5 do
			results = potentialProperties(results, attrib..tostring(idx), false, false)
			results = potentialProperties(results, attrib..tostring(idx), true, false)
		end
	end
	return results;
end

Last edited by Nightness : 04-26-19 at 10:28 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Would like to be able to scan all set attributes for a SecureActionButton

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off