脚本目录
脚本的安装目录为 溪流 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 的全局对象,而不是返回一个匿名对象。
该对象内部结构和上文基本一样,部分版本要求有一个 NameSpace 属性,其值如下:
- 3.0 beta1 开始要求
NameSpace=http://www.streamlet.org/xlwarkey_api_3.0.php - 3.0.3.1 开始增加
NameSpace=http://www.streamlet.org/xlwarkey/3-x/api/ -- 兼容旧版本的值 - 3.0.3.2 开始增加
NameSpace=http://www.streamlet.org/Software/xlWarKey/ -- 兼容旧版本的值 - 3.2.1 开始增加
NameSpace=http://xlwarkey.streamlet.org/extension/ -- 兼容旧版本的值 - 3.3 开始已经不要求有
NameSpace