diff --git a/Actions.lua b/Actions.lua index cf4bb52..9c7a87d 100644 --- a/Actions.lua +++ b/Actions.lua @@ -3,7 +3,7 @@ local ADDON_LOADED, shared = ... local function PickupEquipmentSet(setName) local setIndex = 0 - for i=1,C_EquipmentSet.GetNumEquipmentSets() do + for i = 1, C_EquipmentSet.GetNumEquipmentSets() do local sn = C_EquipmentSet.GetEquipmentSetInfo(i) if sn == setName then @@ -19,7 +19,7 @@ local pickupActionButton = { spell = PickupSpell, macro = PickupMacro, companion = PickupSpell, - equipmentset = PickupEquipmentSet, + equipmentset = PickupEquipmentSet } local function RestoreActionButton(self, index, actionButton) @@ -29,7 +29,9 @@ local function RestoreActionButton(self, index, actionButton) ClearCursor() end - if not actionButton then return true, nil end + if not actionButton then + return true, nil + end local aliases = ActionBarSaverReloaded.spellAliases[actionButton.id] or {} local ids = Array.insert(aliases, actionButton.id, 1) @@ -48,7 +50,9 @@ local function RestoreActionButton(self, index, actionButton) return false end -local function IsMacro(actionButton) return actionButton and actionButton.type == "macro" end +local function IsMacro(actionButton) + return actionButton and actionButton.type == "macro" +end local function GetMacroDuplicates() local t = {} @@ -71,15 +75,12 @@ local function GetMacroDuplicates() end local function AddWarning(warnings, macroName, usages) - table.insert( - warnings, - string.format( - "Warning: Found %d macros named '%s'. Consider renaming them to avoid issues", - usages, - macroName)) + table.insert(warnings, string.format("Warning: Found %d macros named '%s'. Consider renaming them to avoid issues", + usages, macroName)) end function SaveSet(setName) + print("ABS SaveSet") if not setName or setName == "" then print("Set name cannot be empty") return @@ -95,7 +96,9 @@ function SaveSet(setName) if type == "macro" then -- use macro name as the ID id = GetMacroInfo(id) - if duplicates[id] then AddWarning(warnings, id, duplicates[id]) end + if duplicates[id] then + AddWarning(warnings, id, duplicates[id]) + end end if type and id then @@ -108,7 +111,9 @@ function SaveSet(setName) ActionBarSaverReloaded.sets[setName] = set print(string.format("Saved set '%s'!", setName)) - Array.iter(warnings, function(warning) print(warning) end) + Array.iter(warnings, function(warning) + print(warning) + end) end function RestoreSet(setName) @@ -137,18 +142,25 @@ function RestoreSet(setName) for i = 1, MAX_ACTION_BUTTONS do local actionButton = set[i] - if IsMacro(actionButton) and duplicates[actionButton.id] then AddWarning(messages, actionButton.id, duplicates[actionButton.id]) end + if IsMacro(actionButton) and duplicates[actionButton.id] then + AddWarning(messages, actionButton.id, duplicates[actionButton.id]) + end local succeeded, restoredID = RestoreActionButton(self, i, actionButton) if not succeeded then - table.insert(messages, string.format("Error: Unable to restore %s with id [%s] to slot %d", actionButton.type, actionButton.id or "", i)) + table.insert(messages, string.format("Error: Unable to restore %s with id [%s] to slot %d", + actionButton.type, actionButton.id or "", i)) elseif actionButton and restoredID ~= actionButton.id then - table.insert(messages, string.format("Info: Restored spell %d (%s) in place of spell %d", restoredID, GetSpellInfo(restoredID), actionButton.id)) + table.insert(messages, + string.format("Info: Restored spell %d (%s) in place of spell %d", restoredID, GetSpellInfo(restoredID), + actionButton.id)) end end print(string.format("Restored set '%s'", setName)) - Array.iter(messages, function(warning) print(warning) end) + Array.iter(messages, function(warning) + print(warning) + end) end function DeleteSet(setName) @@ -246,8 +258,10 @@ function PrintUsage() end SlashCmdList["ABS"] = function(argv) + print("ABS slash", tostring(argv)) local args = strsplit(" ", argv) local cmd = args[1] + print("ABS slash", tostring(cmd)) if cmd == "save" then SaveSet(args[2]) @@ -270,7 +284,7 @@ SlashCmdList["ABS"] = function(argv) if cmd == "aliases" then ListAliases() end - if cmd == "" then + if cmd == "" or not cmd then PrintUsage() end end diff --git a/Main.lua b/Main.lua index d2a6be1..121474d 100644 --- a/Main.lua +++ b/Main.lua @@ -3,14 +3,16 @@ local ADDON_NAME, shared = ... local frame = CreateFrame("Frame") frame:RegisterEvent("ADDON_LOADED") frame:SetScript("OnEvent", function(self, event, addon) - if addon ~= ADDON_NAME then return end + if addon ~= ADDON_NAME then + return + end ActionBarSaverReloaded = ActionBarSaverReloaded or {} ActionBarSaverReloaded.spellAliases = ActionBarSaverReloaded.spellAliases or {} ActionBarSaverReloaded.sets = ActionBarSaverReloaded.sets or {} end) ---function ABS:OnInitialize() +-- function ABS:OnInitialize() -- self.commands = { -- save = self.actions.SaveSet, -- restore = self.actions.RestoreSet, @@ -20,11 +22,11 @@ end) -- unalias = self.actions.DeleteSpellAliases, -- aliases = self.actions.ListAliases, -- } ---end +-- end -- ---function ABS:HandleCommands(input) +-- function ABS:HandleCommands(input) -- local cmd, args = Str.split(input, " ", 2) -- local fn = self.commands[Str.toLower(cmd)] -- -- if fn then fn(self, args) else self.actions.PrintUsage(self) end ---end \ No newline at end of file +-- end diff --git a/constants.lua b/constants.lua index 05f80e4..fb06873 100644 --- a/constants.lua +++ b/constants.lua @@ -1,2 +1,2 @@ MAX_MACROS = 138 -MAX_ACTION_BUTTONS = 132 \ No newline at end of file +MAX_ACTION_BUTTONS = 132