GetCursorInfo

From Wowpedia
Jump to: navigation, search

Returns information about what the mouse cursor is holding.

"infoType", ... = GetCursorInfo()

Returns

The first return value is a string indicating the nature of an object on the cursor; additional return values provide detail. The following return value combinations have been observed:

  • "item", itemID, itemLink
    itemId : Number - Item ID of the item on the cursor.
    itemLink : String - ItemLink of the item on the cursor.
  • "spell", spellIndex, bookType, spellID
    spellIndex: Number - The index of the spell in the spell book.
    bookType : String - The spell book id. Only works for player spells, so this always returns BOOKTYPE_SPELL.
    spellID : Number - Spell ID of the spell on the cursor
  • "macro", index
    index : Number - The index of the macro on the cursor.
  • "money", amount
    amount : Number - The amount of money in copper.
  • "mount", useless_index, C_MountJournal index
    useless_index: this index is not useful since no other API receives it as a parameter.
    C_MountJournal index: index in the C_MountJournal (used by C_MountJournal API functions). These indexes varies with game locale.
  • "merchant", index
    index : Number - The index of the merchant item.
  • "battlepet", petGUID
    petGUID : String - GUID of a battle pet in your collection.

Example

The following snippet, if you're holding an item, prints out the amount of that item in your bags.

local infoType, itemID, itemLink = GetCursorInfo()
if infoType == "item" then
 print("You have " .. GetItemCount(itemLink) .. "x" .. itemLink .. " in your bags.")
else
 print("You're not holding an item on your cursor.")
end