我要获取装备信息表
🤖 回答引擎: 后端Lua |
🕒 时间: 2026-07-07 17:23:21 |
👁️ 阅读: 0
我是lua后端老师!
修仙者,要获取装备信息表,你需要使用几个关键的函数来获取装备的基础信息和属性。让我详细为你讲解:
**1. 获取物品基础信息 - `getiteminfo()`**
```lua
-- 首先获取装备对象
local item = linkbodyitem(actor, 0) -- 0表示武器位置,其他位置参考装备位置表
if item then
-- 获取物品的唯一ID
local uniqueId = getiteminfo(actor, item, 1)
-- 获取物品ID
local itemId = getiteminfo(actor, item, 2)
-- 获取剩余持久
local curDura = getiteminfo(actor, item, 3)
-- 获取最大持久
local maxDura = getiteminfo(actor, item, 4)
-- 获取叠加数量
local stackCount = getiteminfo(actor, item, 5)
-- 获取绑定状态
local bindState = getiteminfo(actor, item, 6)
-- 获取物品名称(引擎64_23.08.30新增)
local itemName = getiteminfo(actor, item, 7)
-- 获取物品改名后的名称(引擎64_24.08.07新增)
local renamedName = getiteminfo(actor, item, 8)
release_print("物品ID:" .. itemId .. ",名称:" .. itemName .. ",持久:" .. curDura .. "/" .. maxDura)
else
release_print("该位置没有装备")
end
```
**2. 获取物品基础属性 - `getstditeminfo()`**
```lua
-- 根据物品ID获取基础属性
local itemId = 1001 -- 假设的物品ID
-- 获取物品名称
local name = getstditeminfo(itemId, 1)
-- 获取StdMode
local stdMode = getstditeminfo(itemId, 2)
-- 获取Shape
local shape = getstditeminfo(itemId, 3)
-- 获取重量
local weight = getstditeminfo(itemId, 4)
-- 获取AniCount
local aniCount = getstditeminfo(itemId, 5)
-- 获取最大持久
local maxDura = getstditeminfo(itemId, 6)
-- 获取叠加数量
local stackCount = getstditeminfo(itemId, 7)
-- 获取价格
local price = getstditeminfo(itemId, 8)
-- 获取使用条件
local condition = getstditeminfo(itemId, 9)
-- 获取使用等级
local requireLevel = getstditeminfo(itemId, 10)
-- 获取自定义常量(29列)
local custom1 = getstditeminfo(itemId, 11)
-- 获取自定义常量(30列)
local custom2 = getstditeminfo(itemId, 12)
-- 获取道具颜色(引擎64_23.06.28新增)
local itemColor = getstditeminfo(itemId, 13)
release_print("物品" .. itemId .. "信息:名称=" .. name .. ",StdMode=" .. stdMode .. ",等级要求=" .. requireLevel)
```
**3. 获取物品基础属性值 - `getstditematt()`**
```lua
-- 根据属性ID获取具体属性值
local itemId = 1001 -- 假设的物品ID
-- 获取基础防御下限(属性ID=9)
local defMin = getstditematt(itemId, 9)
-- 获取基础防御上限(属性ID=10)
local defMax = getstditematt(itemId, 10)
-- 获取基础魔防下限(属性ID=11)
local mdefMin = getstditematt(itemId, 11)
-- 获取基础魔防上限(属性ID=12)
local mdefMax = getstditematt(itemId, 12)
-- 获取基础攻击下限(属性ID=13)
local atkMin = getstditematt(itemId, 13)
-- 获取基础攻击上限(属性ID=14)
local atkMax = getstditematt(itemId, 14)
-- 获取基础魔法下限(属性ID=15)
local magicMin = getstditematt(itemId, 15)
-- 获取基础魔法上限(属性ID=16)
local magicMax = getstditematt(itemId, 16)
-- 获取基础道术下限(属性ID=17)
local taoMin = getstditematt(itemId, 17)
-- 获取基础道术上限(属性ID=18)
local taoMax = getstditematt(itemId, 18)
release_print("物品" .. itemId .. "基础属性:攻击" .. atkMin .. "-" .. atkMax .. ",防御" .. defMin .. "-" .. defMax)
```
**4. 综合示例 - 获取装备完整信息表**
```lua
-- 封装函数:获取装备完整信息表
function getEquipmentInfoTable(actor, equipPos)
local infoTable = {}
-- 获取装备对象
local item = linkbodyitem(actor, equipPos)
if not item then
release_print("位置" .. equipPos .. "没有装备")
return nil
end
-- 获取基础信息
infoTable.uniqueId = getiteminfo(actor, item, 1)
infoTable.itemId = getiteminfo(actor, item, 2)
infoTable.curDura = getiteminfo(actor, item, 3)
infoTable.maxDura = getiteminfo(actor, item, 4)
infoTable.stackCount = getiteminfo(actor, item, 5)
infoTable.bindState = getiteminfo(actor, item, 6)
infoTable.itemName = getiteminfo(actor, item, 7)
infoTable.renamedName = getiteminfo(actor, item, 8)
-- 获取基础属性
infoTable.baseName = getstditeminfo(infoTable.itemId, 1)
infoTable.stdMode = getstditeminfo(infoTable.itemId, 2)
infoTable.shape = getstditeminfo(infoTable.itemId, 3)
infoTable.weight = getstditeminfo(infoTable.itemId, 4)
infoTable.aniCount = getstditeminfo(infoTable.itemId, 5)
infoTable.baseMaxDura = getstditeminfo(infoTable.itemId, 6)
infoTable.baseStackCount = getstditeminfo(infoTable.itemId, 7)
infoTable.price = getstditeminfo(infoTable.itemId, 8)
infoTable.condition = getstditeminfo(infoTable.itemId, 9)
infoTable.requireLevel = getstditeminfo(infoTable.itemId, 10)
infoTable.custom1 = getstditeminfo(infoTable.itemId, 11)
infoTable.custom2 = getstditeminfo(infoTable.itemId, 12)
infoTable.itemColor = getstditeminfo(infoTable.itemId, 13)
-- 获取战斗属性
infoTable.defMin = getstditematt(infoTable.itemId, 9)
infoTable.defMax = getstditematt(infoTable.itemId, 10)
infoTable.mdefMin = getstditematt(infoTable.itemId, 11)
infoTable.mdefMax = getstditematt(infoTable.itemId, 12)
infoTable.atkMin = getstditematt(infoTable.itemId, 13)
infoTable.atkMax = getstditematt(infoTable.itemId, 14)
infoTable.magicMin = getstditematt(infoTable.itemId, 15)
infoTable.magicMax = getstditematt(infoTable.itemId, 16)
infoTable.taoMin = getstditematt(infoTable.itemId, 17)
infoTable.taoMax = getstditematt(infoTable.itemId, 18)
return infoTable
end
-- 使用示例
local equipInfo = getEquipmentInfoTable(actor, 0) -- 获取武器信息
if equipInfo then
release_print("装备信息表:")
release_print("名称:" .. equipInfo.itemName)
release_print("等级要求:" .. equipInfo.requireLevel)
release_print("攻击:" .. equipInfo.atkMin .. "-" .. equipInfo.atkMax)
release_print("持久:" .. equipInfo.curDura .. "/" .. equipInfo.maxDura)
end
```
**函数说明:**
- `linkbodyitem(actor, pos)` - 获取指定位置的装备对象
- `getiteminfo(actor, item, type)` - 获取装备的详细信息
- `getstditeminfo(itemId, type)` - 获取物品的基础配置信息
- `getstditematt(itemId, attrId)` - 获取物品的基础属性值
**装备位置参考:**
- 0: 武器
- 1: 衣服
- 2: 头盔
- 3: 项链
- 4: 左手镯
- 5: 右手镯
- 6: 左戒指
- 7: 右戒指
- 8: 腰带
- 9: 鞋子
- 10: 宝石
- 11: 斗笠
这样你就可以获取到完整的装备信息表了!如果还需要获取装备的自定义属性、附加属性等信息,可以继续问我。
← 返回问答库