Lua接口/消息与提示:修订间差异
来自天龙知识库
跳到导航跳到搜索
维护服务端 Lua 接口:核对参数、返回值、边界条件与调用示例 |
维护服务端 Lua 接口:核对参数、返回值、边界条件与调用示例 |
||
| (未显示同一用户的2个中间版本) | |||
| 第1行: | 第1行: | ||
__NOTOC__ | __NOTOC__ | ||
<div class="lua-reference | <div class="lua-reference"> | ||
[[首页|首页]] · [[Lua接口/服务端函数索引|服务端接口]] · [[Lua接口/服务端调用约定|调用约定]] | [[首页|首页]] · [[Lua接口/服务端函数索引|服务端接口]] · [[Lua接口/服务端调用约定|调用约定]] | ||
| 第6行: | 第6行: | ||
== 文本消息 == | == 文本消息 == | ||
{| class="wikitable | {| class="wikitable" | ||
! scope="col | ! scope="col" | 接口 | ||
! scope="col | ! scope="col" | 参数与返回 | ||
|- | |- | ||
| [[Lua接口/服务端/Msg2Player|Msg2Player]] | |||
| <code>sceneId, selfId, msg, type</code> → 1 / -1。 | |||
|- | |- | ||
| [[Lua接口/服务端/DispatchMissionTips|DispatchMissionTips]] | |||
| <code>sceneId, selfId</code>;无返回值。任务相关提示。 | |||
|- | |- | ||
| [[Lua接口/服务端/AddNumber|AddNumber]] | |||
| <code>sceneId, id</code>;无返回值。添加数目提示。 | |||
|- | |- | ||
| [[Lua接口/服务端/AddRandItemBonus|AddRandItemBonus]] | |||
| <code>sceneId</code>;无返回值。提示奖励随机道具。 | |||
|} | |} | ||
[[Lua接口/服务端/Msg2Player|Msg2Player]] 返回 1 表示已发送、-1 失败,是本组中少数有返回值的接口。[[Lua接口/服务端/DispatchMissionTips|DispatchMissionTips]]、[[Lua接口/服务端/AddNumber|AddNumber]]、[[Lua接口/服务端/AddRandItemBonus|AddRandItemBonus]] 都无返回值。 | [[Lua接口/服务端/Msg2Player|Msg2Player]] 返回 1 表示已发送、-1 失败,是本组中少数有返回值的接口。[[Lua接口/服务端/DispatchMissionTips|DispatchMissionTips]]、[[Lua接口/服务端/AddNumber|AddNumber]]、[[Lua接口/服务端/AddRandItemBonus|AddRandItemBonus]] 都无返回值。 | ||
== 操作结果 == | == 操作结果 == | ||
{| class="wikitable | {| class="wikitable" | ||
! scope="col | ! scope="col" | 接口 | ||
! scope="col | ! scope="col" | 参数与返回 | ||
|- | |- | ||
| [[Lua接口/服务端/SendOResultToPlayer|SendOResultToPlayer]] | |||
| <code>sceneId, selfId, resultCode</code> → 成功不返回 Lua 值,失败 -1。 | |||
|- | |- | ||
| [[Lua接口/服务端/LuaFnSendOpResult|LuaFnSendOpResult]] | |||
| <code>sceneId, selfId, resultCode</code> → 成功不返回 Lua 值,失败 -1。 | |||
|} | |} | ||
这两个接口 | 这两个接口'''成功时不返回值'''(赋值接收得到 nil),失败才返回 -1,不能用 <code>if result then</code> 判断成功。 | ||
== 界面提示 == | == 界面提示 == | ||
{| class="wikitable | {| class="wikitable" | ||
! scope="col | ! scope="col" | 接口 | ||
! scope="col | ! scope="col" | 参数与返回 | ||
|- | |- | ||
| [[Lua接口/服务端/LuaFnOpenPWBox|LuaFnOpenPWBox]] | |||
| <code>sceneId, selfId</code> → 0。二级密码未解锁时打开解锁界面。 | |||
|- | |- | ||
| [[Lua接口/服务端/OpenWorldReference|OpenWorldReference]] | |||
| <code>sceneId, selfId, pParam</code> → 1 / -1。打开江湖指南指定页面。 | |||
|- | |- | ||
| [[Lua接口/服务端/LuaFnSendGuajiQuestion|LuaFnSendGuajiQuestion]] | |||
| <code>sceneId, selfId</code> → 返回值;失败 -1。挂机验证码。 | |||
|} | |} | ||
[[Lua接口/服务端/LuaFnOpenPWBox|LuaFnOpenPWBox]] 返回 0。 | [[Lua接口/服务端/LuaFnOpenPWBox|LuaFnOpenPWBox]] 返回 0。 | ||
== 制造结果消息 == | == 制造结果消息 == | ||
{| class="wikitable | {| class="wikitable" | ||
! scope="col | ! scope="col" | 接口 | ||
! scope="col | ! scope="col" | 参数与返回 | ||
|- | |- | ||
| [[Lua接口/服务端/LuaFnSendAbilitySuccessMsg|LuaFnSendAbilitySuccessMsg]] | |||
| <code>sceneId, selfId, AbilityId, RecipeId, ItemSerialNum</code>;无返回值。 | |||
|- | |- | ||
| [[Lua接口/服务端/LuaFnSendAbilityFailureMsg|LuaFnSendAbilityFailureMsg]] | |||
| <code>sceneId, selfId, abilityId, recipeId, itemSerial</code>;无返回值。 | |||
|} | |} | ||
生活技能制造的成功 / 失败消息,都无返回值。 | 生活技能制造的成功 / 失败消息,都无返回值。 | ||
== 调试输出 == | == 调试输出 == | ||
{| class="wikitable | {| class="wikitable" | ||
! scope="col | ! scope="col" | 接口 | ||
! scope="col | ! scope="col" | 参数与返回 | ||
|- | |- | ||
| [[Lua接口/服务端/PrintNum|PrintNum]] | |||
| <code>num</code>;无返回值。弹出消息框(测试脚本用)。 | |||
|- | |- | ||
| [[Lua接口/服务端/PrintStr|PrintStr]] | |||
| <code>strText</code>;无返回值。弹出消息框(测试脚本用)。 | |||
|} | |} | ||
[[Lua接口/服务端/PrintNum|PrintNum]] 与 [[Lua接口/服务端/PrintStr|PrintStr]] 是 | [[Lua接口/服务端/PrintNum|PrintNum]] 与 [[Lua接口/服务端/PrintStr|PrintStr]] 是'''测试脚本用'''的弹框,正式脚本不要依赖。 | ||
== 发送文本消息 == | == 发送文本消息 == | ||
<pre | <pre>local result = Msg2Player(sceneId, selfId, "message", 0) | ||
if type(result) == "number" and result == 1 then | if type(result) == "number" and result == 1 then | ||
-- 消息已发送 | -- 消息已发送 | ||
| 第87行: | 第87行: | ||
== 发送操作结果 == | == 发送操作结果 == | ||
<pre | <pre>SendOResultToPlayer(sceneId, selfId, resultCode) | ||
-- 成功不返回 Lua 值,失败才返回 -1 | -- 成功不返回 Lua 值,失败才返回 -1 | ||
-- 不能写 if SendOResultToPlayer(...) then 判断成功</pre> | -- 不能写 if SendOResultToPlayer(...) then 判断成功</pre> | ||
| 第125行: | 第125行: | ||
[[Lua接口/函数不存在|函数不存在或提示 nil]] · [[Lua接口/参数类型与顺序|参数类型与顺序]] · [[Lua接口/返回值判断|返回值判断]] · [[Lua接口/对象ID与GUID|对象 ID 与 GUID]] | [[Lua接口/函数不存在|函数不存在或提示 nil]] · [[Lua接口/参数类型与顺序|参数类型与顺序]] · [[Lua接口/返回值判断|返回值判断]] · [[Lua接口/对象ID与GUID|对象 ID 与 GUID]] | ||
</div> | </div> | ||
2026年10月26日 (一) 17:29的最新版本
向玩家发送文本消息、操作结果提示与各类界面提示。消息接口多数不返回 Lua 值,不能靠返回值判断是否显示成功。
文本消息
| 接口 | 参数与返回 |
|---|---|
| Msg2Player | sceneId, selfId, msg, type → 1 / -1。
|
| DispatchMissionTips | sceneId, selfId;无返回值。任务相关提示。
|
| AddNumber | sceneId, id;无返回值。添加数目提示。
|
| AddRandItemBonus | sceneId;无返回值。提示奖励随机道具。
|
Msg2Player 返回 1 表示已发送、-1 失败,是本组中少数有返回值的接口。DispatchMissionTips、AddNumber、AddRandItemBonus 都无返回值。
操作结果
| 接口 | 参数与返回 |
|---|---|
| SendOResultToPlayer | sceneId, selfId, resultCode → 成功不返回 Lua 值,失败 -1。
|
| LuaFnSendOpResult | sceneId, selfId, resultCode → 成功不返回 Lua 值,失败 -1。
|
这两个接口成功时不返回值(赋值接收得到 nil),失败才返回 -1,不能用 if result then 判断成功。
界面提示
| 接口 | 参数与返回 |
|---|---|
| LuaFnOpenPWBox | sceneId, selfId → 0。二级密码未解锁时打开解锁界面。
|
| OpenWorldReference | sceneId, selfId, pParam → 1 / -1。打开江湖指南指定页面。
|
| LuaFnSendGuajiQuestion | sceneId, selfId → 返回值;失败 -1。挂机验证码。
|
LuaFnOpenPWBox 返回 0。
制造结果消息
| 接口 | 参数与返回 |
|---|---|
| LuaFnSendAbilitySuccessMsg | sceneId, selfId, AbilityId, RecipeId, ItemSerialNum;无返回值。
|
| LuaFnSendAbilityFailureMsg | sceneId, selfId, abilityId, recipeId, itemSerial;无返回值。
|
生活技能制造的成功 / 失败消息,都无返回值。
调试输出
| 接口 | 参数与返回 |
|---|---|
| PrintNum | num;无返回值。弹出消息框(测试脚本用)。
|
| PrintStr | strText;无返回值。弹出消息框(测试脚本用)。
|
PrintNum 与 PrintStr 是测试脚本用的弹框,正式脚本不要依赖。
发送文本消息
local result = Msg2Player(sceneId, selfId, "message", 0)
if type(result) == "number" and result == 1 then
-- 消息已发送
end
Msg2Player 需要 4 个参数,返回 1 表示已发送。
发送操作结果
SendOResultToPlayer(sceneId, selfId, resultCode) -- 成功不返回 Lua 值,失败才返回 -1 -- 不能写 if SendOResultToPlayer(...) then 判断成功
SendOResultToPlayer 成功路径不返回值。
相关主题
- 角色信息
- 属性读取与修改
- 等级与经验
- 货币相关
- 物品查询
- 物品发放与扣除
- 背包空间
- 装备操作
- 任务状态
- 任务变量
- NPC 对话
- 对话选项
- 技能相关
- 心法相关
- 状态效果
- 生活技能
- 珍兽查询
- 珍兽操作
- 场景查询
- 坐标与传送
- 副本相关
- 活动相关
- 时间与计时
- 怪物相关
- 队伍相关
- 帮会相关
- 消息与提示
- 聊天与公告
函数不存在或提示 nil · 参数类型与顺序 · 返回值判断 · 对象 ID 与 GUID