WoW:USERAPI EquipItemByLink

Revision as of 10:37, 13 February 2007 by WoWWiki>Tekkub
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page documents a <i>user-defined function</i> that you can copy and paste into your addon. Replace PREFIX with your addon or lib prefix to avoid conflicts between different versions of these functions.

User defined functions


Equips the first matching item found in the player's bags.

local function EquipItemByLink(link)
	for bag=0,4 do
		for slot=1,GetContainerNumSlots(bag) do
			local item = GetContainerItemLink(bag, slot)
			if item and item == link then
				if CursorHasItem() or CursorHasMoney() or CursorHasSpell() then ClearCursor() end
				PickupContainerItem(bag, slot)
				AutoEquipCursorItem()
				return true
			end
		end
	end
end