From 29cd686eec79bb1a015261b910b0370548bfcfab Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 4 Jan 2025 19:05:55 +0100 Subject: [PATCH] Implement exporting sets --- Actions.lua | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Actions.lua b/Actions.lua index cb77a70..a6c5fbc 100644 --- a/Actions.lua +++ b/Actions.lua @@ -228,7 +228,7 @@ function AliasSpell(args) end table.insert(ActionBarSaverReloaded.spellAliases[spellID], aliasID) -print(string.format("Added %d as an alias for %d", aliasID, spellID)) + print(string.format("Added %d as an alias for %d", aliasID, spellID)) end function DeleteSpellAliases(spellID) @@ -262,6 +262,26 @@ function ListAliases() end) end + +function ExportSet(setName) + local set = ActionBarSaverReloaded.sets[setName] + if not set then + print(string.format("No set with the name '%s' exists", setName)) + return + end + local stringified = {} + for slot, action in pairs(set) do + local typeChar = typeMap[action.type] + if not typeChar then + print(string.format("Unknown action type '%s' in set '%s'", action.type, setName)) + return + end + stringified[#stringified + 1] = string.format("%s\\%s\\%s", tostring(slot), tostring(action.id), + tostring(typeChar)) + end + local str = table.concat(stringified, "|") + print(str) +end function PrintUsage() print("ABS Slash commands") print("/abs save - Saves your current action bar setup under the given ") @@ -271,6 +291,8 @@ function PrintUsage() print("/abs alias - Adds an alias with to ") print("/abs unalias - Removes all aliases associated with ") print("/abs aliases - List all spell aliases") + print("/abs export - Export set") + print("/abs import - Import set from exported string") end SlashCmdList["ABS"] = function(argv) @@ -298,6 +320,13 @@ SlashCmdList["ABS"] = function(argv) if cmd == "aliases" then ListAliases() end + if cmd == "export" then + ExportSet(args[2]) + end + if cmd == "import" then + ImportSet(args[2], args[3]) + end + if cmd == "" or not cmd then PrintUsage() end