Some suggestions.
a) either allow more exludes (make it a table) to make things like this work (because Lua's regular expressions are so weak they can't accomplish this in one go):
Lua Code:
{ mapping = "Stats", pattern = "^STAT_", exclude = {"^STAT_BONUS_OPTION_", "^STAT_SOFT_CAP_OPTION", "^STAT_VALUE_COLOR"} }
b) or replace excludes with a non-mapping...
Lua Code:
{ mapping = false, pattern = "^CHAT_CATEGORY_HEADER_" }, -- non-mapping
{ mapping = "ChatCategories", pattern = "^CHAT_CATEGORY_" },
{ mapping = "StatBonusOptions", pattern = "^STAT_BONUS_OPTION_" },
{ mapping = "StatSoftCapOptions", pattern = "^STAT_SOFT_CAP_OPTION_" },
{ mapping = false, pattern = "^STAT_VALUE_COLOR" }, -- non-mapping
{ mapping = "Stats", pattern = "^STAT_" },
...and stop after the first match
Lua Code:
--For every entry in the Global table
for key, value in zo_insecurePairs(_G) do
--Compare it to every mapping
local foundMap = nil
for _, currentMap in ipairs(Mappings) do
if key:find(currentMap.pattern) then
foundMap = currentMap
break -- stop at the first match
end
end
if foundMap and foundMap.mapping then
--found a Value for this mapping, so store it in the table
local newentry = { key = key, value = value}
table.insert(data[foundMap.mapping], newentry)
end
end
Also it would be nice to have direct [value] => "key" mapping in addition to the table of pairs (I'm aware there might be collisions and the library would have to deal somehow, that's why wrote in addition to
)