首页
来自天龙知识库
跳到导航跳到搜索
接口分类
常用函数
服务端 Lua 接口
| 函数 | Lua 调用 | 用途 |
|---|---|---|
| GetName | GetName(sceneId, selfId)
|
获取角色名称。 |
| GetLevel | GetLevel(sceneId, selfId)
|
获取角色等级。 |
| GetHp | GetHp(sceneId, selfId)
|
获取角色当前生命值。 |
| GetItemCount | GetItemCount(sceneId, selfId, itemTypeSn)
|
统计指定物品数量,包含已装备与背包中的物品。 |
示例与常见问题
读取角色信息
local name = GetName(sceneId, selfId) local level = GetLevel(sceneId, selfId) local hp = GetHp(sceneId, selfId)
适用于服务端脚本回调中的有效角色。
sceneId 为当前场景 ID,selfId 为场景内对象 ID,取自当前回调参数。