Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- allows making a macro such as:
- -- /run EquipSameItemEnchant:New("MacroLabel", itemID, enchantID)
- -- /click EquipSameItemEnchantMacroLabel
- -- (untested code)
- local frame = CreateFrame("Frame", "EquipSameItemEnchant")
- frame.New = function(self, label, itemID, enchantID)
- if not frame[label] then
- frame[label] = CreateFrame("Button", "EquipSameItemEnchant"..label)
- frame[label].itemID = itemID
- frame[label].enchantID = enchantID
- frame[label]:SetScript("OnClick", function()
- local itemCount = 0
- for bag = 0,4 do
- for slot = 1, C_Container.GetContainerNumSlots(bag) do
- local itemLink = C_Container.GetContainerItemLink(bag, slot)
- local dataCount = 0
- local currentItemID = nil
- local currentEnchantID = nil
- for data in itemLink:gmatch("([^:]*)") do
- dataCount = dataCount + 1
- if dataCount == 2 then
- currentItemID = data
- elseif dataCount == 3 then
- currentEnchantID = data
- else
- break
- end
- end
- if frame[label].itemID == currentItemID and frame[label].enchantID == currentEnchantID then
- itemCount = itemCount + 1
- C_Container.PickupContainerItem(bag, slot)
- local equipSlot = (itemCount == 1) and "MainHandSlot" or "SecondaryHandSlot"
- EquipCursorItem(GetInventorySlotInfo(equipSlot))
- if itemCount == 2 then
- return true
- end
- end
- end
- end
- end)
- end
- frame[label].itemID = (frame[label].itemID == itemID) and frame[label].itemID or itemID
- frame[label].enchantID = (frame[label].enchantID == enchantID) and frame[label].enchantID or enchantID
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement