From 3b04d7aedfc93f71f8e3683ed34c3e14caa48613 Mon Sep 17 00:00:00 2001 From: Buds Date: Sat, 29 Jun 2024 01:35:15 +0200 Subject: [PATCH] Allows TSU function to not have to return true when a state was changed This require usage of allstates' Update/Remove/RemoveAll --- WeakAuras/GenericTrigger.lua | 3 ++- WeakAuras/TSUHelpers.lua | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index d861471b6d..c99b2c4b34 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -639,9 +639,10 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 else ok, returnValue = xpcall(data.triggerFunc, errorHandler, allStates, event, arg1, arg2, ...); end - if (ok and returnValue) then + if (ok and (returnValue or (returnValue ~= false and allStates.__changed))) then updateTriggerState = true; end + allStates.__changed = nil for key, state in pairs(allStates) do if (type(state) ~= "table") then errorHandler(string.format(L["All States table contains a non table at key: '%s'."], key)) diff --git a/WeakAuras/TSUHelpers.lua b/WeakAuras/TSUHelpers.lua index 0776d0e7bc..974f809cf6 100644 --- a/WeakAuras/TSUHelpers.lua +++ b/WeakAuras/TSUHelpers.lua @@ -23,6 +23,7 @@ local remove = function(states, key) if state then state.show = false state.changed = true + states.__changed = true changed = true end return changed @@ -36,6 +37,9 @@ local removeAll = function(states) state.changed = true changed = true end + if changed then + states.__changed = true + end return changed end @@ -65,6 +69,7 @@ local update = function(states, key, newState) changed = recurseUpdate(state, newState) if changed then state.changed = true + states.__changed = true end end return changed @@ -74,6 +79,7 @@ end local create = function(states, key, newState) states[key] = newState states[key].changed = true + states.__changed = true fixMissingFields(states[key]) return true end