WeakAuras

WeakAuras

208M Downloads

Add "Clean/Optimize" Button to Remove Unused Configuration Data in WeakAuras

masterkain opened this issue · 1 comments

commented

WeakAuras currently retains configuration data—including triggers, actions, and load conditions—even when they are no longer in use. For example, if I create a WeakAura with a custom trigger and associated Lua functions, then later convert it to a built-in Health trigger, the custom code remains embedded in the final WeakAuras.lua file. This residual code ensures that if I revert to the custom trigger, the original functions are still intact.

Issues:

  • Code Clutter: I often create WeakAuras by duplicating existing ones. Over time, this results in unnecessary and unrelated code accumulating within each WeakAura, leading to cluttered configurations.
  • Sharing Complications: When sharing WeakAuras, custom elements such as sound file names are directly embedded in the exported code, making it less portable or leading to privacy issues.
  • Manual Editing Challenges: To compile large lists of buffs/debuffs, I sometimes need to edit WeakAuras.lua directly. The excessive and unused code makes this process difficult, especially when using Lua extensions that attempt to reformat the file upon saving.

Proposed Solution: Introduce a "Clean" or "Optimize" button within the WeakAuras interface. This feature would:

  • Capture the current active configuration of a WeakAura, including only the enabled triggers, actions, and load conditions.
  • Eliminate any disabled or unused code segments, such as custom triggers or Lua functions that are no longer active.
  • Ensure that the exported WeakAuras are free from unnecessary code, making them cleaner and easier to share or edit manually.

Consider the following WeakAura configuration:

{
    ["trigger"] = {
        ["type"] = "unit",
        ["use_absorbHealMode"] = true,
        ["custom_type"] = "status",
        ["custom_hide"] = "timed",
        ["percenthealth"] = {
            "75",
            "0",
        },
        ["event"] = "Health",
        ["unit"] = "player",
        ["use_absorbMode"] = true,
        ["events"] = "UNIT_HEALTH:player",
        ["custom"] = 'function()\n    local maxHealth blabla',
        ["use_unit"] = true,
        ["check"] = "event",
        ["use_percenthealth"] = true,
        ["percenthealth_operator"] = {
            "<=",
            ">",
        },
        ["debuffType"] = "HELPFUL",
    },
    ["untrigger"] = {
        ["custom"] = 'function()\n    local maxHealth blabla',
    },
}

In this example, a custom trigger was initially used but later converted to a standard Health trigger. However, the custom trigger and untrigger code remain in the configuration.
A "Clean" button would remove these unused custom functions, resulting in a streamlined WeakAura that reflects only the current active settings.

Since WeakAuras does not immediately writes the file upon editing maybe there can be a checkbox in the info panel that when enabled it will save that weakaura as "cleaned/optimized", warning the user there will be no undos.

commented

Duplicate of #803