Implement exporting macros

This commit is contained in:
2025-01-04 23:18:50 +01:00
parent 9520269857
commit 8b310197fc

View File

@@ -5,14 +5,16 @@ local typeMap = {
item = "I",
macro = "M",
companion = "C",
equipmentset = "E"
equipmentset = "E",
summonmount = "U"
}
local inverseTypeMap = {
S = "spell",
I = "item",
M = "macro",
C = "companion",
E = "equipmentset"
E = "equipmentset",
U = "summonmount"
}
local function PickupEquipmentSet(setName)
@@ -299,6 +301,7 @@ function ExportSet(setName)
print(string.format("No set with the name '%s' exists", setName))
return
end
local macros = {}
local stringified = {}
for slot, action in pairs(set) do
local typeChar = typeMap[action.type]
@@ -308,11 +311,24 @@ function ExportSet(setName)
end
stringified[#stringified + 1] = string.format("%s\\%s\\%s", tostring(slot), tostring(action.id),
tostring(typeChar))
if typeChar == "M" then
local _, _, macro = GetMacroInfo(action.id)
if macro then
macros[action.id] = macro
end
end
end
for name, macro in pairs(macros) do
local content = B64.Encode(macro)
local cpartitions = Partition(content, 160, "|")
for partitionIndex, partition in ipairs(cpartitions) do
print(string.format("M|%s|%d|%s", name, partitionIndex, partition))
end
end
local str = table.concat(stringified, "|")
local partitions = Partition(str, 160, "|")
local partitions = Partition(str, 200, "|")
for _, partition in ipairs(partitions) do
print("/abs import " .. setName .. " " .. partition)
print(partition)
end
end
@@ -357,10 +373,10 @@ function ImportSet(setName, str)
return
end
local set = ActionBarSaverReloaded.sets[setName] or {}
-- if set then
-- print(string.format("Set '%s' already exists", setName))
-- return
-- end
-- if set then
-- print(string.format("Set '%s' already exists", setName))
-- return
-- end
str = strtrim(str)
local data = {strsplit("|", str)}