溪流 WarKey

脚本扩展

脚本目录

脚本的安装目录为 溪流 WarKey 根目录下的 scripts 目录下。 添加或删除脚本后,需要重新打开溪流 WarKey 才能生效。 3.4.0.0 开始,在脚本配置对话框刷新脚本列表也可生效。

脚本格式

脚本使用 lua 引擎运行,需要保存为 .lua 文件。文件内容如下:
return {
    Application      = "xlWarKey", -- 宿主应用,固定为“xlWarKey”
    Version          = "3.4",      -- 可运行该脚本的溪流 WarKey 的最低版本号

    ExtensionName    = "SampleExtension",                  -- 脚本名称
    ExtensionVersion = "1.0",                              -- 脚本版本号(可选,3.4开始支持,不写默认为 1.0)
    Author           = "YourName",                         -- 脚本作者
    Description      = "This extension is rather good.",   -- 脚本描述

    -- 参数配置,溪流 WayKey 会在脚本配置页面引导用户填写
    Configuration = {
        -- 参数名为 setting1,类型为 number,描述为“Please input an integer.”
        setting1  = {
            Type  = "number",
            Desc  = "Please input an integer."
        },
        -- 参数名为 setting2,类型为 string,描述为“Please input a string.”
        setting2  = {
            Type  = "string",
            Desc  = "Please input a string."
        },
        -- ...
    },

    -- 入口函数。
    Entrance      = function (config)
        -- 运行时,请使用 config.setting1、config.setting2 读取配置值

        -- 所有代码都请写在这里
        -- ...

        return true;  -- 请返回 boolean 值。
    end
};

如果要支持 3.4 以前的版本,请按如下格式:

-- 要定义一个名为“Extension”的全局变量
Extension =
{
    Application   = "xlWarKey", -- 宿主应用,固定为“xlWarKey”
    Version       = "3.0",      -- 固定为 3.0

    -- 命名空间
    -- 3.0 beta1 开始要求 http://www.streamlet.org/xlwarkey_api_3.0.php
    -- 3.0.3.1 开始要求 http://www.streamlet.org/xlwarkey/3-x/api/ (向下兼容)
    -- 3.0.3.2 开始要求 http://www.streamlet.org/Software/xlWarKey/(向下兼容)
    -- 3.2.1 开始要求 http://xlwarkey.streamlet.org/extension/(向下兼容)
    -- 3.3 开始已经不要求
    NameSpace     = "http://xlwarkey.streamlet.org/extension/",

    ExtensionName = "SampleExtension",                  -- 脚本名称
                                                        -- 不支持脚本版本号
    Author        = "YourName",                         -- 脚本作者
    Description   = "This extension is rather good.",   -- 脚本描述

    -- 参数配置写法不变
    Configuration =
    {
        setting1  =
        {
            Type  = "number",
            Desc  = "Please input an integer."
        },
        setting2  =
        {
            Type  = "string",
            Desc  = "Please input a string."
        }
        -- ...
    },

    -- 入口函数
    Entrance      = function (id)   -- 参数 id 仅占位,实际不使用
        -- 运行时,请使用 Extension.Configuration.setting1、Extension.Configuration.setting2 读取配置值

        -- 所有代码都请写在这里
        -- ...

        return true;
    end
};

©2004-2025 溪流网站 保留所有权利