From 49d7f95e62c84eb8da0de16a393c8369fc40e26b Mon Sep 17 00:00:00 2001 From: Buds Date: Sat, 19 Aug 2023 15:44:17 +0200 Subject: [PATCH] Trigger filters can be grouped with "or" same as with load options This is use with Cast trigger to be able to filter spells by name and by id at the same time --- WeakAuras/GenericTrigger.lua | 13 ++++++++++++- WeakAuras/Prototypes.lua | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index 16e027fa2d..12f3cb2174 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -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 @@ -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])); @@ -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 ""); diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 86bbdb9039..4b7d98a47a 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -8209,7 +8209,8 @@ Private.event_prototypes = { multiEntry = { operator = "or", }, - noValidation = true + noValidation = true, + orConjunctionGroup = "spellCastFilter" }, { name = "spellIds", @@ -8220,6 +8221,7 @@ Private.event_prototypes = { multiEntry = { operator = "or", }, + orConjunctionGroup = "spellCastFilter" }, { name = "spellId",