Skip to content

Commit

Permalink
Trigger filters can be grouped with "or" same as with load options
Browse files Browse the repository at this point in the history
This is use with Cast trigger to be able to filter spells by name and by id at the same time
  • Loading branch information
mrbuds committed Aug 19, 2023
1 parent 5570bef commit 49d7f95
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion WeakAuras/GenericTrigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ function ConstructFunction(prototype, trigger)
local store = {};
local init;
local preambles = "\n"
local orConjunctionGroups = {}
if(prototype.init) then
init = prototype.init(trigger);
else
Expand Down Expand Up @@ -332,7 +333,12 @@ function ConstructFunction(prototype, trigger)
if(arg.required) then
tinsert(required, test);
else
tinsert(tests, test);
if arg.orConjunctionGroup then
orConjunctionGroups[arg.orConjunctionGroup] = orConjunctionGroups[arg.orConjunctionGroup] or {}
tinsert(orConjunctionGroups[arg.orConjunctionGroup], "("..test..")")
else
tinsert(tests, test);
end
end
if(arg.debug) then
tinsert(debug, arg.debug:format(trigger[name]));
Expand All @@ -344,6 +350,11 @@ function ConstructFunction(prototype, trigger)
end
end
end

for _, orConjunctionGroup in pairs(orConjunctionGroups) do
tinsert(tests, "("..table.concat(orConjunctionGroup, " or ")..")")
end

local ret = preambles .. "return function("..tconcat(input, ", ")..")\n";
ret = ret..(init or "");

Expand Down
4 changes: 3 additions & 1 deletion WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8209,7 +8209,8 @@ Private.event_prototypes = {
multiEntry = {
operator = "or",
},
noValidation = true
noValidation = true,
orConjunctionGroup = "spellCastFilter"
},
{
name = "spellIds",
Expand All @@ -8220,6 +8221,7 @@ Private.event_prototypes = {
multiEntry = {
operator = "or",
},
orConjunctionGroup = "spellCastFilter"
},
{
name = "spellId",
Expand Down

0 comments on commit 49d7f95

Please sign in to comment.