Warcraft III resources & community, 2003–2006 · archived

GetInventoryIndexOfItemType

not rated
Submitted by StarcraftfreakVariable Change0 downloads
Works the same way as the blizzard.j function, but works with 0-based slot indices.
Returns the 0-based slot index of the specified item type.
Are there more than 1 items of this type it returns the slot index of the first item it finds (= the one with the lower slot index).
Returns -1, if it can't find an item of that type.

Source

function GetInventoryIndexOfItemType takes unit whichUnit, integer itemId returns integer
    local integer index
    local item    indexItem

    set index = -1
    loop
        set indexItem = UnitItemInSlot(whichUnit, index)
        if (indexItem != null) and (GetItemTypeId(indexItem) == itemId) then
            return index
        endif

        set index = index +1
        exitwhen index >= bj_MAX_INVENTORY
    endloop
    return -1
endfunction

Comments

0

No comments.