Implement exporting sets

This commit is contained in:
2025-01-04 19:05:55 +01:00
parent 94408916e0
commit 29cd686eec

View File

@@ -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 <set> - Saves your current action bar setup under the given <set>")
@@ -271,6 +291,8 @@ function PrintUsage()
print("/abs alias <spellID> <aliasID> - Adds an alias with <aliasID> to <spellID>")
print("/abs unalias <spellID> - Removes all aliases associated with <spellID>")
print("/abs aliases - List all spell aliases")
print("/abs export <set> - Export set")
print("/abs import <set> <str> - 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