可以使用 `hasitem(actor, makeIndex)` 接口来检测角色是否拥有指定唯一ID的物品,并返回其存在状态。
该接口的参数说明:
- `actor`:玩家对象(必填)
- `makeIndex`:物品唯一ID(必填)
返回值说明:
- 返回 `0`:物品装备在身上
- 返回 `1`:物品存在于背包中
- 返回 `-1`:物品不存在
使用示例:
```lua
local result = hasitem(actor, makeIndex)
if result == 0 then
print("物品装备在身上")
elseif result == 1 then
print("物品存在于背包")
elseif result == -1 then
print("物品不存在")
end
```
注意:此接口必须通过物品唯一ID进行判断,因为需要区分物品是装备在身上还是存放在背包中。