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 获取具体错误信息。
文档更新时间: 2023-04-21 15:45   作者:105493660