View Single Post
04-26-19, 08:36 PM   #2
Nightness
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 32
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