api示例

(1)检索背包

--NUM_BAG_SLOTS——背包个数
--GetContainerNumSlots(bag)——获取指定背包物品数量
--GetContainerItem(bag, slot)——获取背包指定位置物品链接
for bag = 0, NUM_BAG_SLOTS do
    for slot = 0, GetContainerNumSlots(bag) do
        local link = GetContainerItemLink(bag, slot)
        if(link ~= nil) then
            local itemId, enchantId = link:match("item:(%d+) : (%d+)")
        end
    end
end

(2)检索装备

--GetInventoryItemLink("palyer", slot)——获取指定部位装备链接
--0-弹药, 1-头, 2-项链, 3-肩膀, 4-衬衫, 5-胸, 6-腰带, 7-腿, 8-鞋子, 9-手腕, 10-手套,
--11-戒指(上), 12-戒指(下), 13-饰品(上), 14-饰品(下), 15-披风, 16-主手, 17-副手, 18-远程, 19-战袍 
local link = GetInventoryItemLink("player", 10)
if(link ~= nil) then
    local itemId, enchantId = link:match("item:(%d+):(%d+)")
end

 (3)穿装备

--EquipItemByName(itemId, slot)——装备物品到指定部位
EquipItemByName(12345, 10)

(4)常用判定

--是否骑马
IsMounted() and not UnitOnTaxi("player")

--是否在战斗
InCombatLockdown() or UnitAffectingCombat("player")

--是否死亡
UnitIsDeadOrGhost("player")

 

posted @ 2020-04-07 16:16  西贝雪  阅读(575)  评论(0编辑  收藏  举报