RegOpenBox
RegOpenBox(DoFile, InitFuncName);
函数功能:
创建一个开启宝箱就会触发的Lua函数。
请求方式:
| 参数名 | 是否必须 | 类型 | 说明 |
|---|---|---|---|
| DoFile | 是 | string | 脚本文件路径(如是本文件则填写nil) |
| InitFuncName | 是 | string | 响应事件处理函数的名称,声明格式参考如下 |
参数说明:
| 参数名 | 是否必须 | 类型 | 说明 |
|---|---|---|---|
| CharIndex | 是 | int | 响应事件的人物对象索引 |
| Box | 是 | int | 开启的宝箱类型参考常量 [宝箱] |
| Type | 是 | int | 0为道具,1为金钱,2为遇到怪物 |
| TypeVal | 是 | int | Type为0此处值为道具ID,Type为1此处值为得到的魔币数量(当Gold为1的时候,那么是玩家身上道具已经满了),Type为2此处值Encounid |
返回值:
| 类型 | 是否必须 | 范围数值 |
|---|---|---|
| int | 是 | 0~2 【0为道具,1为金钱,2为遇到怪物】 |
| int | 是 | 道具 或 金钱 或 怪物EnCountID |
操作实例:
function OpenBox_Event(CharIndex,Box,Type,TypeVal)
local Name = Char.GetData(CharIndex, 2000);
if( Type == 0 )then
local String = string.format("人物:%s 得到道具ID:%d",Name,TypeVal);
NLG.SystemMessage( CharIndex, String);
--返回得到魔石
return 0,18026;
end
if( Type == 1 )then
local String = string.format("人物:%s 得到魔币:%d",Name,TypeVal);
NLG.SystemMessage( CharIndex, String);
--返回得到魔石
return 0,18026;
end
if( Type == 2 )then
local String = string.format("人物:%s 触发战斗ENCOUNID:%d",Name,TypeVal);
NLG.SystemMessage( CharIndex, String);
--返回得到魔石
return 0,18026;
end
return Type,TypeVal;
end
备注:
- 返回错误代码请使用 GetErrorStr 获取具体错误信息。
作者:105493660 创建时间:2019-05-11 15:49
更新时间:2025-12-24 21:35
更新时间:2025-12-24 21:35