背包函数¶
InventoryGetItemCount(aIndex, itemIndex, itemLevel)¶
统计玩家背包中指定物品(按索引和等级)的数量。
- 返回值:
number
local count = InventoryGetItemCount(aIndex, GET_ITEM(14, 13), 0)
LogAdd(LOG_BLUE, "Player has " .. count .. " Jewels of Bless.")
InventoryDelItemIndex(aIndex, slot)¶
删除指定背包格子中的物品。
- 返回值:
boolean
InventoryDelItemCount(aIndex, itemIndex, itemLevel, count)¶
从背包中删除最多 count 个指定类型的物品。
- 返回值:
boolean
InventoryGetFreeSlotCount(aIndex)¶
返回主背包区域中空闲的 1x1 格子数量。
- 返回值:
number
local free = InventoryGetFreeSlotCount(aIndex)
if free < 4 then
GCNoticeSend(aIndex, 1, "Your inventory is almost full!")
end
InventoryCheckSpaceByItem(aIndex, itemIndex)¶
检查背包是否有足够空间容纳指定物品(使用其实际尺寸)。
- 返回值:
boolean
if not InventoryCheckSpaceByItem(aIndex, GET_ITEM(0, 18)) then
GCNoticeSend(aIndex, 1, "Not enough inventory space.")
end
InventoryCheckSpaceBySize(aIndex, width, height)¶
检查背包是否有 width x height 大小的空闲矩形区域。
- 返回值:
boolean
背包事务函数¶
当 CHARACTER_RESTORE_INFO == 0 时可用。提供原子性背包操作。
| 函数 | 说明 |
|---|---|
gObjFixInventoryPointer(aIndex) |
重置背包指针为主背包 |
gObjSetInventory1Pointer(aIndex) |
指向备份背包 1 |
gObjSetInventory2Pointer(aIndex) |
指向备份背包 2 |
gObjFixEventInventoryPointer(aIndex) |
重置活动背包指针 |
gObjSetEventInventory1Pointer(aIndex) |
指向活动备份 1 |
gObjSetEventInventory2Pointer(aIndex) |
指向活动备份 2 |
gObjInventoryTransaction(aIndex) |
开始背包事务 |
gObjInventoryCommit(aIndex) |
提交事务 |
gObjInventoryRollback(aIndex) |
回滚事务 |
gObjInventoryTransaction(aIndex)
-- ... 修改背包 ...
if success then
gObjInventoryCommit(aIndex)
else
gObjInventoryRollback(aIndex)
end
Help