Files
coa-weakauras/WeakAuras
NoM0Re 7c7869494e 5.19.3
Add methods to the states/allstates table that helps with creating,
updating or remove states in an optimized way

## Advantage of using this function instead of doing a states[key] = {
... }

- If already created, update existing state, and return true if any
value was changed, this can help reduce amount of resources an aura use

- Automatically `return true` when using these functions and any change
was made

## Examples

```Lua
function(states, event, ...)
    if event == "PLAYER_TARGET_CHANGED" then
        if UnitExists("target") then
            -- if state exists it's updated, not replaced
            -- show & changed fields can be skipped
            states:Update("", {
                    name = UnitName("target"),
                    duration = 5,
                    expirationTime = GetTime() + 5,
                    progressType = "timed",
                    autoHide = true
            })
        else
            -- wipe
            states:RemoveAll()
        end
    end
    -- no need to return true
end
```

with clones

```Lua
function(states, event, ...)
    local currentEssence = UnitPower("player", Enum.PowerType.Essence)
    local maxEssence = UnitPowerMax("player", Enum.PowerType.Essence)
    for i = 1, 6 do
        if i > maxEssence then
            states:Remove(i) -- wipe allstates[6]
        else
            local value = currentEssence >= i and 1 or 0
            local newState = {
                progressType = "static",
                value = value,
                total = 1
            }
            states:Update(i, newState)
        end
    end
    -- no need to return true
end
```
2025-02-24 22:10:45 +01:00
..
2020-09-16 23:03:25 +03:00
2025-01-27 03:28:33 +01:00
2025-02-24 22:10:45 +01:00
2020-06-02 23:40:06 +03:00
2025-02-24 22:10:45 +01:00
2025-02-15 14:40:24 +01:00
2025-01-19 16:02:00 +01:00
2025-02-14 18:46:41 +01:00
2025-02-18 17:13:03 +01:00
2025-02-16 20:50:05 +01:00
2025-01-27 03:28:33 +01:00
2025-02-14 18:46:41 +01:00
2025-02-14 18:46:41 +01:00
2020-07-01 17:42:02 +03:00
2025-02-24 22:10:45 +01:00
2025-02-24 22:10:45 +01:00
2025-01-06 19:47:37 +01:00
2025-02-24 22:10:45 +01:00
2020-06-02 23:40:06 +03:00
2020-06-02 23:40:06 +03:00
2021-08-26 17:57:54 +03:00
2025-02-04 17:27:16 +01:00
2025-02-18 19:30:43 +01:00
2025-02-14 18:46:41 +01:00
2025-02-24 22:10:45 +01:00
2025-02-24 22:10:45 +01:00
2025-02-24 22:10:45 +01:00