Implement exporting macros
This commit is contained in:
		
							
								
								
									
										24
									
								
								Actions.lua
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								Actions.lua
									
									
									
									
									
								
							@@ -5,14 +5,16 @@ local typeMap = {
 | 
				
			|||||||
    item = "I",
 | 
					    item = "I",
 | 
				
			||||||
    macro = "M",
 | 
					    macro = "M",
 | 
				
			||||||
    companion = "C",
 | 
					    companion = "C",
 | 
				
			||||||
    equipmentset = "E"
 | 
					    equipmentset = "E",
 | 
				
			||||||
 | 
					    summonmount = "U"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
local inverseTypeMap = {
 | 
					local inverseTypeMap = {
 | 
				
			||||||
    S = "spell",
 | 
					    S = "spell",
 | 
				
			||||||
    I = "item",
 | 
					    I = "item",
 | 
				
			||||||
    M = "macro",
 | 
					    M = "macro",
 | 
				
			||||||
    C = "companion",
 | 
					    C = "companion",
 | 
				
			||||||
    E = "equipmentset"
 | 
					    E = "equipmentset",
 | 
				
			||||||
 | 
					    U = "summonmount"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function PickupEquipmentSet(setName)
 | 
					local function PickupEquipmentSet(setName)
 | 
				
			||||||
@@ -299,6 +301,7 @@ function ExportSet(setName)
 | 
				
			|||||||
        print(string.format("No set with the name '%s' exists", setName))
 | 
					        print(string.format("No set with the name '%s' exists", setName))
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					    local macros = {}
 | 
				
			||||||
    local stringified = {}
 | 
					    local stringified = {}
 | 
				
			||||||
    for slot, action in pairs(set) do
 | 
					    for slot, action in pairs(set) do
 | 
				
			||||||
        local typeChar = typeMap[action.type]
 | 
					        local typeChar = typeMap[action.type]
 | 
				
			||||||
@@ -308,11 +311,24 @@ function ExportSet(setName)
 | 
				
			|||||||
        end
 | 
					        end
 | 
				
			||||||
        stringified[#stringified + 1] = string.format("%s\\%s\\%s", tostring(slot), tostring(action.id),
 | 
					        stringified[#stringified + 1] = string.format("%s\\%s\\%s", tostring(slot), tostring(action.id),
 | 
				
			||||||
            tostring(typeChar))
 | 
					            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
 | 
					    end
 | 
				
			||||||
    local str = table.concat(stringified, "|")
 | 
					    local str = table.concat(stringified, "|")
 | 
				
			||||||
    local partitions = Partition(str, 160, "|")
 | 
					    local partitions = Partition(str, 200, "|")
 | 
				
			||||||
    for _, partition in ipairs(partitions) do
 | 
					    for _, partition in ipairs(partitions) do
 | 
				
			||||||
        print("/abs import " .. setName .. " " .. partition)
 | 
					        print(partition)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user