[关闭]
@miniknife 2020-03-17T03:48:14.000000Z 字数 40089 阅读 38280

触动精灵企业版脚本开发手册

已不进行更新,最新版请查看:http://helpdoc.touchsprite.com/dev_docs/2181/2149.html
开发手册 企业版


Windows 平台按 Ctrl + F 打开快捷搜索

Mac 平台按 command + F 打开快捷搜索

※右侧文本列表可以找到全部手册


目录


企业版专用脚本库


函数:TSUserType、TSUserID、TSUserEmail 获取企业产品类型、用户 ID、用户邮箱

函数功能:获取产品类型、用户ID、用户邮箱

参数 类型 说明
TSUserType number 产品类型
TSUserID number 用户 ID
TSUserEmail number 用户邮箱
返回值 类型 说明
text number 产品类型,1 为云控,2 为中控,nil 为未知连接方式;用户 ID,nil 为未获取到用户 ID;用户邮箱,nil 为未获取到用户邮箱

函数用例:

  1. local text = (TSUserType == 1 and "云控" or TSUserType == 2 and "中控" or "未知连接方式").."\r\n"..
  2. (TSUserID == nil and "未获取到用户 ID" or "ID : " .. TSUserID).."\r\n"..
  3. (TSUserEmail == nil and "未获取到用户邮箱" or "邮箱 : " .. TSUserEmail)
  4. dialog(text)

注意事项:

获取的是当前运行脚本所在的企业产品类型、用户 ID、用户邮箱

方法: messageBox 在中控器中显示提示框

方法名称:在中控器中显示提示框
方法功能:在中控器中显示提示框
调用方法
ts_enterprise_lib:messageBox(title,text)
参数 类型 说明
title string 提示框标题
text string 提示框内容

脚本实例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. ts_enterprise_lib:messageBox("提示","我是来自脚本的提示!")

方法: timeout 中控设置全局超时时间

方法名称:设置全局超时时间
方法功能:设置全局超时时间,仅中控有效
调用方法
ts_enterprise_lib.timeout = sec
参数 类型 说明
sec number 超时时间,单位为秒,默认为5秒

脚本实例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. ts_enterprise_lib.timeout = 60 -- 设置超时时间为 60

方法: version 获取中控版本号

方法名称:获取中控版本号
方法功能:获取中控版本号,build 号,仅中控有效
调用方法
ret = ts_enterprise_lib:version()
参数 类型 说明
ret table ret.build - 中控build号,ret.version - 中控版本号

脚本实例:

  1. --取中控版本号和 build
  2. --引入中控库
  3. ts_enterprise_lib = require("ts_enterprise_lib")
  4. assert(ts_enterprise_lib,"无法引入企业专用库")
  5. if ts_enterprise_lib.version then
  6. --判断 version 函数是否存在,旧版的中控(build 1080前)没有这个函数
  7. local ret = ts_enterprise_lib:version()
  8. -- ret :失败 ret=false
  9. -- 成功 ret 返回tableret.build build号,ret.version=版本字符串
  10. if ret then
  11. toast("中控版本"..ret.version..',build:'..ret.build)
  12. else
  13. --
  14. toast('获取失败')
  15. end
  16. end

方法: controller_injection 注入中控器运行

方法名称:注入中控器运行
方法功能:注入中控器运行代码
调用方法
ok,msg = ts_enterprise_lib:controller_injection(code)
参数 类型 说明
code string 注入代码内容
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
msg string 操作结果详情,失败返回失败原因

脚本实例:

  1. --[[
  2. 请注意注入代码的安全,不安全的代码会导致中控器崩溃
  3. 简单的发账号示例
  4. script/account.txt内保存账号密码
  5. --]]
  6. local ok,account = ts_enterprise_lib:controller_injection(
  7. [[
  8. local f = io.open("script/account.txt", "r")
  9. if f then
  10. local account_tab = {}
  11. local account = f:read()
  12. while account do
  13. table.insert(account_tab,account)
  14. account = f:read()
  15. end
  16. f:close()
  17. if #account_tab > 0 then
  18. local f = io.open("script/account.txt", "w")
  19. if f then
  20. for i = 2,#account_tab do
  21. f:write(account_tab[i].."\n")
  22. end
  23. f:close()
  24. end
  25. return account_tab[1]
  26. else
  27. return false
  28. end
  29. end
  30. return false
  31. ]]
  32. )
  33. assert(ok,account)
  34. if account then
  35. nLog("获取账号:"..account)
  36. toast("获取账号:"..account)
  37. else
  38. nLog("获取账号失败")
  39. toast("获取账号失败")
  40. end
  41. mSleep(1000)

方法: controller_ocr 中控端打码

方法名称:中控端打码
方法功能:客户端向中控端发送识别内容,人工值守返回打码结果到设备
调用方法
图片打码:ok,msg = ts_enterprise_lib:controller_ocr(x1,y1,x2,y2,timeout)
文字打码:ok,msg = ts_enterprise_lib:controller_txt(text,timeout)
参数 类型 说明
x1 number 左上角顶点屏幕横坐标
y1 number 左上角顶点屏幕纵坐标
x2 number 右下角顶点屏幕横坐标
y2 number 右下角顶点屏幕纵坐标
text string 文字打码内容
timeout timeout 超时时间,单位秒,可缺省,默认 60
返回值 类型 说明
ok boolean 成功返回 true,失败返回 false
msg string 返回打码结果,超时未处理返回"timeout"

脚本实例:

  1. -- 中控端打码,发送图片
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert( ts_enterprise_lib,"无法引入企业专用库")
  4. local x1 = 1 --打码左上角坐标
  5. local y1 = 1 --打码左上角坐标
  6. local x2 = 200 --打码右下角坐标
  7. local y2 = 100 --打码右下角坐标
  8. local timeout = 300 --打码超时,单位秒,缺省60,如果中控器超时没有处理,会返回false,"timeout"
  9. local ok,msg = ts_enterprise_lib:controller_ocr(x1,y1,x2,y2,timeout)
  10. assert(ok,msg)
  11. nLog("打码成功!"..msg)
  12. toast("打码成功!"..msg)
  13. mSleep(1000)
  1. -- 中控端打码,发送字符串
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert( ts_enterprise_lib,"无法引入企业专用库")
  4. local text = "test!"
  5. local timeout = 300 --打码超时,单位秒,缺省60,如果中控器超时没有处理,会返回false,"timeout"
  6. local ok,msg = ts_enterprise_lib:controller_txt(text,timeout)
  7. assert(ok,msg)
  8. nLog("打码成功!"..msg)
  9. toast("打码成功!"..msg)
  10. mSleep(1000)

方法: reboot_restart 重启设备后启动脚本

方法名称:重启设备后启动脚本
方法功能:重启设备后启动脚本
调用方法
ret,msg = ts_enterprise_lib:reboot_restart()
返回值 类型 说明
ret boolean 操作结果,成功返回 true,失败返回 false
msg string 操作结果详情,失败返回失败原因

脚本实例:

  1. --设备重启期间不要关闭中控器
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. local ret,msg = ts_enterprise_lib:reboot_restart()
  4. if ret then
  5. toast("设备即将重启")
  6. else
  7. toast("设备重启失败:"..msg)
  8. end

方法: remote_file_load 读取中控文件

方法名称:读取中控文件
方法功能:读取中控文件
调用方法
ok,data = ts_enterprise_lib:remote_file_load(filepath)
参数 类型 说明
path string 文件路径,可以是相对中控器文件夹的相对路径,也可以是绝对路径
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
data string 当 ok 等于 true,返回文件数据,当 ok等于 false,返回错误原因

脚本实例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. --文件名:中控器上的文件名,可以是相对中控器文件夹的相对路径,也可以是绝对路径
  5. --如果文件名所在的文件夹不存在,或者没有权限,或者文件名存在非法字符,文件会创建失败
  6. local filename = "abc" --这是相对路径
  7. local filename = "c:\\abc" --这是 win 绝对路径
  8. local filename = "/Users/xxxx/Documents/abc" --这是 mac 绝对路径
  9. -- 读取远程文件
  10. local ok,data = ts_enterprise_lib:remote_file_load(filename)
  11. if ok then
  12. toast("读成功:"..data)
  13. else
  14. toast("读失败:"..data)
  15. end
  16. -- 返回值 ok:调用是否成功,如果 true,第二个参数返回文件数据,如果 false,第二个返回值返回错误原因

方法: remote_file_save 写入中控文件

方法名称:写入中控文件
方法功能:写入中控文件
调用方法
ok,data = ts_enterprise_lib:remote_file_save(filepath,filedata)
参数 类型 说明
filepath string 文件路径,可以是相对中控器文件夹的相对路径,也可以是绝对路径
filedata string 需要写入的文件数据
返回值 类型 说明
ok boolean 操作结果,成功返回true,失败返回false
data string 当 ok 等于 true,无返回值;当 ok 等于 false,返回错误原因

脚本实例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. --文件名:中控器上的文件名,可以是相对中控器文件夹的相对路径,也可以是绝对路径
  5. --如果文件名所在的文件夹不存在,或者没有权限,或者文件名存在非法字符,文件会创建失败
  6. local filename = "abc" --这是相对路径
  7. local filename = "c:\\abc" --这是 win 绝对路径
  8. local filename = "/Users/xxxx/Documents/abc" --这是 mac 绝对路径
  9. --文件数据,支持二进制数据
  10. local filedata = [[
  11. 1111
  12. 2222
  13. 3333
  14. ]]
  15. -- 写入远程文件
  16. local ok,msg = ts_enterprise_lib:remote_file_save(filename,filedata)
  17. if ok then
  18. toast("写入成功")
  19. else
  20. toast("写入失败:"..msg)
  21. end
  22. -- 返回值 ok:调用是否成功,如果 true,没有第二个返回值,如果 false,第二个返回值返回错误原因

方法: push_file 上传文件

方法名称:上传文件
方法功能:从设备上传文件到中控
调用方法
ok,err = ts_enterprise_lib:push_file(local_file,remote_file)
参数 类型 说明
local_file string 设备的文件路径
remote_file string 中控的文件路径,可以是相对中控器文件夹的相对路径,也可以是绝对路径
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
err string 当 ok 等于 true,无返回值;当 ok 等 于false,返回错误原因

脚本实例:

  1. ts_enterprise_lib = require("ts_enterprise_lib")
  2. assert(ts_enterprise_lib,"无法引入企业专用库")
  3. toast("开始测试")
  4. --上传文件到中控器
  5. local local_file = userPath().."/res/aaa/test2.zip" --本地的文件名(手机上)
  6. local remote_file = 'test2.zip' --中控的文件名(相对于中控器的根路径)
  7. local ok,err = ts_enterprise_lib:push_file(local_file,remote_file)
  8. -- 返回:ok :true or false
  9. -- error: 失败原因
  10. if ok then
  11. toast("上传成功")
  12. else
  13. toast(err)
  14. end
  15. --测试速度结果:80M 文件 11 - 18
  16. --此功能需要配合 1069 以上版本中控器方可使用

方法: pull_file 下载文件

方法名称:下载文件
方法功能:从中控下载文件到设备
调用方法
ok,err = ts_enterprise_lib:pull_file(local_file,remote_file)
参数 类型 说明
local_file string 设备的文件路径
remote_file string 中控的文件路径,可以是相对中控器文件夹的相对路径,也可以是绝对路径
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
err string 当 ok 等于 true,无返回值;当 ok 等于 false,返回错误原因

脚本实例:

  1. ts_enterprise_lib = require("ts_enterprise_lib")
  2. assert(ts_enterprise_lib,"无法引入企业专用库")
  3. toast("开始测试")
  4. --从中控器下载文件
  5. local local_file = userPath().."/res/aaa/test.zip" --本地的文件名(手机上)
  6. local remote_file = 'test.zip' --中控的文件名(相对于中控器的根路径)
  7. local ok,err = ts_enterprise_lib:pull_file(local_file,remote_file)
  8. -- 返回:ok :true or false
  9. -- error: 失败原因
  10. if ok then
  11. toast("下载成功")
  12. else
  13. toast(err)
  14. return
  15. end
  16. --测试速度结果:80M 文件 11 - 18
  17. --此功能需要配合 1069 以上版本中控器方可使用

方法: plugin_api_call("VariableMonitor",...) 变量监控

方法名称:变量监控
方法功能:通过上传数据到中控进行变量监控
调用方法
ok,msg = ts_enterprise_lib:plugin_api_call("VariableMonitor",action,
str1,
str2,
str3,...)
参数 类型 说明
action string 设置模式,
填写 "set_column" 为设置变量监控列名,
填写 "set_variable" 为上传每列列值
*str string 列名或列值
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
msg string 当 ok 等于 true,无返回值;当 ok 等于 false,返回错误原因

脚本实例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. --设置变量监控列信息
  5. local ok,msg = ts_enterprise_lib:plugin_api_call("VariableMonitor","set_column","序号","随机数","序号+随机数","序号*随机数")
  6. toast(ok and "set_column 成功" or "set_column 失败:"..msg)
  7. mSleep(1000)
  8. math.randomseed(os.time())
  9. for i = 1 , 100 do
  10. local var1 = i
  11. local var2 = math.random()
  12. local var3 = var1+var2
  13. local var4 = var1*var2
  14. --上传每列数据
  15. local ok,msg = ts_enterprise_lib:plugin_api_call("VariableMonitor","set_variable",var1,var2,var3,var4)
  16. toast(ok and "set_variable 成功" or "set_variable 失败:"..msg)
  17. mSleep(1000)
  18. end

企业版数据中心

当调用企业库 plugin_api_call 方法第一个参数填写"DataCenter"时,可以调用企业版数据中心的相关函数功能,第二个参数为函数名称。


方法:add_category 创建分类

函数名称:创建分类
函数功能:创建分类
函数方法:
local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","add_category",category)
参数 类型 说明
category string 数据中心分类名
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
ret1 string/boolean 当 ok 等 于 true,创建成功;当 ok 等于 false,创建成功
ret2 string 当 ret1 等 true,返回成功;当 ret1 等于 false,返回失败原因

函数用例:

  1. ts_enterprise_lib = require("ts_enterprise_lib")
  2. assert(ts_enterprise_lib,"无法引入企业专用库")
  3. local category = "分类"
  4. local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","add_category",category)
  5. if ok then
  6. dialog("创建成功")
  7. else
  8. dialog("创建失败 : " .. ret1)
  9. end

方法: get_data 获取数据

方法名称:获取数据
方法功能:从数据中心获取一条数据
调用方法
ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","get_data",category)
参数 类型 说明
category string 数据中心分类名
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
ret1 string/boolean 当 ok 等 于 true,返回数据获取状态;当 ok 等于 false,返回错误原因
ret2 string 当 ret1 等 于true,返回数据;当 ret1 等于 false,返回失败原因

函数用例:

  1. --
  2. -- Date: 16/8/1
  3. -- Time: 下午6:10
  4. -- 本例子为设备脚本调用 api 示例
  5. -- 本例子所调用的api,在中控根目录 plugin/DataCenter/api.lua 中都有实现源码,可根据自己的实际需要做功能调整
  6. --引入中控库
  7. ts_enterprise_lib = require("ts_enterprise_lib")
  8. assert(ts_enterprise_lib,"无法引入企业专用库")
  9. local category = "测试分类"
  10. -- 取数据操作,每 5 秒取一次数据,取 100
  11. for i = 1 , 100 do
  12. -- 使用中控库的插件 api 调用接口
  13. -- DataCenter 是插件 id
  14. -- get_data api name
  15. -- category api 参数,这个 api 是分类名
  16. local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","get_data",category)
  17. -- 返回 ok 表示插件 api 是否调用成功,ret1,ret2 api 的返回值
  18. if ok then
  19. if ret1 then
  20. nLog("get_data 成功:"..ret2)
  21. else
  22. nLog("get_data 失败:"..ret2)
  23. end
  24. else
  25. nLog("get_data 失败:"..ret1)
  26. end
  27. mSleep(5000)
  28. end

方法: batch_data 批量获取数据

方法名称:批量获取数据
方法功能:从数据中心单次获取多条数据
调用方法
ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","batch_data",category,count)
参数 类型 说明
category string 数据中心分类名
count number 获取数据数量
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
ret1 string/boolean 当 ok 等于 true,返回数据获取状态;当 ok 等于 false,返回错误原因
ret2 string/table 当 ret1 等于 true,返回 table 格式的数据;当 ret1 等于 false,返回失败原因

函数用例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. local ts = require("ts")--使用扩展库前必须插入这一句
  5. local json = ts.json--使用 JSON 模块前必须插入这一句
  6. --批量取数据
  7. local count = 10 --取数据数量
  8. local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","batch_data",category,count)
  9. if ok then
  10. if ret1 then
  11. --返回一个数组table
  12. nLog("batch_data 成功:"..json.encode(ret2))
  13. else
  14. nLog("batch_data 失败:"..ret2)
  15. end
  16. else
  17. nLog("batch_data 失败:"..ret1)
  18. end
  19. mSleep(5000)

方法: get_remain_count 获取剩余有效数据数量

方法名称:获取剩余有效数据数量
方法功能:获取剩余有效数据数量,即未使用状态的数据数量
调用方法
ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","get_remain_count",category)
参数 类型 说明
category string 数据中心分类名
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
ret1 string/boolean 当 ok 等于 true,返回数据获取状态;当 ok 等于 false,返回错误原因
ret2 string 当 ret1 等于 true,返回剩余数据数量;当 ret1 等于 false,返回失败原因

函数用例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. --获取剩余有效数据数量(未使用)
  5. local ok,ret1,ret2 =ts_enterprise_lib:plugin_api_call("DataCenter","get_remain_count",category)
  6. if ok then
  7. if ret1 then
  8. nLog("get_remain_count 成功,剩余有效数据数量为:"..ret2)
  9. else
  10. nLog("get_remain_count 失败:"..ret2)
  11. end
  12. else
  13. nLog("get_remain_count 失败:"..ret1)
  14. end
  15. mSleep(5000)

方法: insert_data 插入数据

方法名称:插入数据
方法功能:在数据中心中插入一条新数据
调用方法
ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","insert_data",category,data)
参数 类型 说明
category string 数据中心分类名
data string 要插入的数据
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
ret1 string/boolean 当 ok 等于 true,返回数据获取状态;当 ok 等于 false,返回错误原因
ret2 string 当 ret1 等于 true,无返回;当 ret1 等 于false,返回失败原因

函数用例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. --添加一个数据
  5. local data = "要插入的数据"
  6. local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","insert_data",category,data)
  7. if ok then
  8. if ret1 then
  9. nLog("insert_data 成功")
  10. else
  11. nLog("insert_data 失败:"..ret2)
  12. end
  13. else
  14. nLog("insert_data 失败:"..ret1)
  15. end
  16. mSleep(5000)

方法: revert_data 还原数据

方法名称:还原数据
方法功能:将单条数据还原为未使用状态
调用方法
ok,ret1,ret2 =ts_enterprise_lib:plugin_api_call("DataCenter","revert_data",category,data)
参数 类型 说明
category string 数据中心分类名
data string 要还原的数据
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
ret1 string/boolean 当 ok 等于 true,返回数据获取状态;当 ok 等于 false,返回错误原因
ret2 string 当 ret1 等于 true,无返回;当 ret1 等于 false,返回失败原因

脚本实例:

  1. --注意: 以下函数在中控器 build 1081 及以后的版本才支持
  2. --引入中控库
  3. ts_enterprise_lib = require("ts_enterprise_lib")
  4. assert(ts_enterprise_lib,"无法引入企业专用库")
  5. --归还数据操作
  6. local data = "要归还的数据"
  7. local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","revert_data",category,data)
  8. if ok then
  9. if ret1 then
  10. nLog("revert_data 成功:")
  11. else
  12. nLog("revert_data 失败:"..ret2)
  13. end
  14. else
  15. nLog("revert_data 失败:"..ret1)
  16. end

方法: delete_data 删除数据

方法名称:删除数据
方法功能:删除指定分类下的指定数据
调用方法
ok,ret1,ret2= ts_enterprise_lib:plugin_api_call("DataCenter","delete_data",category,data)
参数 类型 说明
category string 数据中心分类名
data string 要删除的数据
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
ret1 string/boolean 当 ok 等于 true,返回数据获取状态;当 ok 等于 false,返回错误原因
ret2 string 当 ret1 等于 true,无返回;当 ret1 等于 false,返回失败原因

脚本实例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. --删除一个分类下的某个数据
  5. local data="13321638994";
  6. local ok,ret1,ret2= ts_enterprise_lib:plugin_api_call("DataCenter","delete_data",category,data)
  7. if ok then
  8. if ret1 then
  9. dialog("删除成功", 5)
  10. return true
  11. else
  12. dialog("ret1 失败:"..ret1)
  13. end
  14. else
  15. dialog("ok 失败:"..ret1)
  16. end
  17. mSleep(5000)

方法: clear_dataCenterUser 重置数据中心

方法名称:重置数据中心
方法功能:将指定分类下的数据全部重置为未使用状态
调用方法
ok,msg = ts_enterprise_lib:clear_dataCenterUser(category)
参数 类型 说明
category string 数据中心分类名
返回值 类型 说明
ok boolean 操作结果,成功返回true,失败返回false
msg string 当ok等于true,无返回值;当ok等于false,返回错误原因

脚本实例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. --重置某个分类下的数据
  5. local ok,msg = ts_enterprise_lib:clear_dataCenterUser(category)
  6. assert(ok)
  7. if ok then
  8. nLog("重置成功!")
  9. toast("重置成功!")
  10. else
  11. nLog("重置失败!"..msg)
  12. toast("重置失败!"..msg)
  13. end
  14. mSleep(1000)

完整脚本示例

  1. ts_enterprise_lib = require("ts_enterprise_lib")
  2. assert(ts_enterprise_lib,"无法引入企业专用库")
  3. local category = "insert_data"
  4. local ts = require("ts")--使用扩展库前必须插入这一句
  5. local json = ts.json--使用 JSON 模块前必须插入这一句
  6. toast("创建分类名 测试")
  7. local category = "分类"
  8. local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","add_category",category)
  9. if ok then
  10. dialog("创建成功")
  11. else
  12. dialog("创建失败 : " .. ret1)
  13. end
  14. toast("插入数据 测试")
  15. mSleep(1000)
  16. local data = "要插入的数据"
  17. local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","insert_data",category,data..os.date("%H%M%S"))
  18. if ok then
  19. if ret1 then
  20. dialog("插入数据 insert_data 成功")
  21. else
  22. dialog("插入数据 insert_data 失败:"..ret2)
  23. end
  24. else
  25. dialog("插入数据 insert_data 失败:"..ret1)
  26. end
  27. toast("获取数据 测试")
  28. mSleep(1000)
  29. local ok,ret1,ret3 = ts_enterprise_lib:plugin_api_call("DataCenter","get_data",category)
  30. if ok then
  31. if ret1 then
  32. dialog("获取数据 get_data 成功:"..ret3)
  33. else
  34. dialog("获取数据 get_data 失败:"..ret3)
  35. end
  36. else
  37. dialog("获取数据 get_data 失败:"..ret1)
  38. end
  39. toast("还原数据 测试")
  40. mSleep(1000)
  41. local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","revert_data",category,ret3)
  42. if ok then
  43. if ret1 then
  44. dialog("还原数据 revert_data 成功:")
  45. else
  46. dialog("还原数据 revert_data 失败:"..ret2)
  47. end
  48. else
  49. dialog("还原数据 revert_data 失败:"..ret1)
  50. end
  51. toast("批量获取数据 测试") mSleep(1000)
  52. local count = 2 --取数据数量
  53. local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","batch_data",category,count)
  54. if ok then
  55. if ret1 then
  56. dialog("批量获取数据 batch_data 成功:"..json.encode(ret2))
  57. else
  58. dialog("批量获取数据 batch_data 失败:"..ret2)
  59. end
  60. else
  61. dialog("批量获取数据 batch_data 失败:"..ret1)
  62. end
  63. toast("重置数据中心 测试") mSleep(1000)
  64. local ok,msg = ts_enterprise_lib:clear_dataCenterUser(category)
  65. assert(ok)
  66. if ok then
  67. dialog("重置数据中心 重置成功!")
  68. else
  69. dialog("重置数据中心 重置失败!"..msg)
  70. end
  71. toast("剩余有效数据 测试")
  72. mSleep(1000)
  73. local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","get_remain_count",category)
  74. if ok then
  75. if ret1 then
  76. dialog("剩余有效数据 get_remain_count 成功,剩余有效数据数量为:"..ret2)
  77. else
  78. dialog("剩余有效数据 get_remain_count 失败:"..ret2)
  79. end
  80. else
  81. dialog("剩余有效数据 get_remain_count 失败:"..ret1)
  82. end
  83. toast("删除数据 测试")
  84. mSleep(1000)
  85. local ok,ret1,ret2= ts_enterprise_lib:plugin_api_call("DataCenter","delete_data",category,ret3)
  86. if ok then
  87. if ret1 then
  88. dialog("删除数据 删除成功", 5)
  89. else
  90. dialog("删除数据 ret1 失败:"..ret1)
  91. end
  92. else
  93. dialog("删除数据 ok 失败:"..ret1)
  94. end

企业版云盘

此功能模块为云控用户提供云端文件存储、调用服务
云盘访问地址: http://pan.touchsprite.com/


函数:cloud_file_list 获取云盘文件列表

函数名称:获取文件列表
函数功能:获取云盘文件列表。
函数方法
ts_enterprise_lib:cloud_file_list(file)
返回值:table
参数 类型 说明
file string 需要获取文件的文件夹路径
返回值 类型 说明
ret table true/fale和文件列表

脚本实例:

  1. local ts = require("ts")
  2. local json = ts.json
  3. ts_enterprise_lib = require("ts_enterprise_lib")
  4. assert(ts_enterprise_lib,"无法引入企业专用库")
  5. dialog(json.encode({ts_enterprise_lib:cloud_file_list("/")}))

函数:cloud_file_new 创建文件(夹)

函数名称:创建文件(夹)
函数功能:创建文件(夹)
函数方法
ts_enterprise_lib:cloud_file_list(file)
返回值:table
参数 类型 说明
file string 需要创建的文件(夹)路径,创建文件请写明后缀,否则将无法显示后缀
返回值 类型 说明
ret table 成功 - true,失败 - false

脚本实例:

  1. local ts = require("ts")
  2. local json = ts.json
  3. ts_enterprise_lib = require("ts_enterprise_lib")
  4. assert(ts_enterprise_lib,"无法引入企业专用库")
  5. --创建 a1 文件夹
  6. dialog(json.encode({ts_enterprise_lib:cloud_file_new("/a1/")}))
  7. --在 a1 文件夹下创建 1.txt 文件
  8. dialog(json.encode({ts_enterprise_lib:cloud_file_new("/a1/1.txt")}))

函数:cloud_file_rename 文件(夹)重命名

函数名称:文件(夹)重命名
函数功能:文件(夹)重命名
函数方法
ts_enterprise_lib:cloud_file_list(file,rename)
返回值:table
参数 类型 说明
file string 需要修改的文件(夹)路径
rename string 需要修改的文件(夹)名称
返回值 类型 说明
ret table 成功 - true,失败 - false

脚本实例:

  1. local ts = require("ts")
  2. local json = ts.json
  3. ts_enterprise_lib = require("ts_enterprise_lib")
  4. --修改 a1 文件夹下 1.txt 文件名称为 2.txt
  5. dialog(json.encode({ts_enterprise_lib:cloud_file_rename("/a1/1.txt","2")}))
  6. --修改 a1 文件夹下的 1 文件夹名称为 2
  7. dialog(json.encode({ts_enterprise_lib:cloud_file_rename("/a1/1/","2")}))

函数:cloud_file_del(file) 删除文件(夹)

函数名称:删除文件(夹)
函数功能:删除文件(夹)
函数方法
ts_enterprise_lib:cloud_file_del(file)
返回值:table
参数 类型 说明
file string 需要删除文件(夹)的路径
返回值 类型 说明
ret table 成功 - true,失败 - false

脚本实例:

  1. local ts = require("ts")
  2. local json = ts.json
  3. ts_enterprise_lib = require("ts_enterprise_lib")
  4. --删除 a1 文件夹下的 2 文件夹
  5. dialog(json.encode({ts_enterprise_lib:cloud_file_del("/a1/2/")}))
  6. --删除 a1 文件夹下的 2.txt 文件
  7. dialog(json.encode({ts_enterprise_lib:cloud_file_del("/a1/2.txt")}))

方法: cloud_file_save 向云盘写入文件

方法名称:向云盘中写入文件
方法功能:向云盘中写入一个文件
调用方法
ok,err = ts_enterprise_lib:cloud_file_save(cloud_file_name,file_data,timeout_seconds)
参数 类型 说明
cloud_file_name string 写入文件路径,需包含完整文件名
file_data string 文件内容
timeout_seconds number 超时时间,单位秒。数据较大时,应适当延长
返回值 类型 说明
ok boolean 操作结果,成功返回true,失败返回false
err string 当ok等于true,无返回值;当ok等于false,返回错误原因

脚本实例:

  1. ts_enterprise_lib = require("ts_enterprise_lib")
  2. assert(ts_enterprise_lib,"无法引入企业专用库")
  3. local cloud_file_name = "/aaa/bbb/脚本2.lua" --云文件名,包含目录的完整文件名
  4. local file_data = "123" --文件数据
  5. local timeout_seconds = 30; --超时秒数,数据较大时,适当延长
  6. local ok,err = ts_enterprise_lib:cloud_file_save(cloud_file_name,file_data,timeout_seconds)
  7. if ok then
  8. dialog("成功")
  9. else
  10. dialog(err)
  11. end

方法: cloud_file_load 从云盘读取文件

方法名称:从云盘中读取文件
方法功能:从云盘中读取一个文件
调用方法
ok,data = ts_enterprise_lib:cloud_file_load(cloud_file_name,timeout_seconds)
参数 类型 说明
cloud_file_name string 读取文件路径,需包含完整文件名
timeout_seconds number 超时时间,单位秒。数据较大时,应适当延长
返回值 类型 说明
ok boolean 操作结果,成功返回true,失败返回false
err string 当ok等于true,无返回值;当ok等于false,返回错误原因

脚本实例:

  1. ts_enterprise_lib = require("ts_enterprise_lib")
  2. assert(ts_enterprise_lib,"无法引入企业专用库")
  3. local cloud_file_name = "/aaa/bbb/脚本2.lua" --云文件名,包含目录的完整文件名
  4. local timeout_seconds = 30; --超时秒数,数据较大时,适当延长
  5. local ok,data = ts_enterprise_lib:cloud_file_load(cloud_file_name,timeout_seconds)
  6. if ok then
  7. dialog("loal success:"..data)
  8. else
  9. dialog("fail:"..data)
  10. end

方法: cloud_file_pull 从云盘下载文件

方法名称:从云盘下载文件
方法功能:从云盘中下载一个文件到本地
调用方法
ok,err = ts_enterprise_lib:cloud_file_pull(local_file,cloud_file_name,timeout_seconds)
参数 类型 说明
local_file string 本地文件路径,需包含完整文件名
cloud_file_name string 云盘文件路径,需包含完整文件名
timeout_seconds number 超时时间,单位秒。数据较大时,应适当延长
返回值 类型 说明
ok boolean 操作结果,成功返回true,失败返回false
err string 当ok等于true,无返回值;当ok等于false,返回错误原因

脚本实例:

  1. ts_enterprise_lib = require("ts_enterprise_lib")
  2. assert(ts_enterprise_lib,"无法引入企业专用库")
  3. local local_file = userPath().."/1.lua" --本地文件名
  4. local cloud_file_name = "/aaa/bbb/脚本2.lua" --云文件名,包含目录的完整文件名
  5. local timeout_seconds = 30; --超时秒数,数据较大时,适当延长
  6. local ok,err = ts_enterprise_lib:cloud_file_pull(local_file,cloud_file_name,timeout_seconds)
  7. if ok then
  8. dialog("成功")
  9. else
  10. dialog(err)
  11. end

方法: cloud_file_push 上传文件到云盘

方法名称:上传文件到云盘
方法功能:从本地上传一个文件到云盘
调用方法
ok,err = ts_enterprise_lib:cloud_file_push(local_file,cloud_file_name,timeout_seconds)
参数 类型 说明
local_file string 本地文件路径,需包含完整文件名
cloud_file_name string 云盘文件路径,需包含完整文件名
timeout_seconds number 超时时间,单位秒。数据较大时,应适当延长
返回值 类型 说明
ok boolean 操作结果,成功返回true,失败返回false
err string 当ok等于true,无返回值;当ok等于false,返回错误原因

脚本实例:

  1. ts_enterprise_lib = require("ts_enterprise_lib")
  2. assert(ts_enterprise_lib,"无法引入企业专用库")
  3. local local_file = userPath().."/1.lua" --本地文件名
  4. local cloud_file_name = "push.lua" --云文件名,包含目录的完整文件名
  5. local timeout_seconds = 30; --超时秒数,数据较大时,适当延长
  6. local ok,err = ts_enterprise_lib:cloud_file_push(local_file,cloud_file_name,timeout_seconds)
  7. if ok then
  8. dialog("成功")
  9. else
  10. dialog(err)
  11. end
  • 此功能模块需配合触动精灵企业版使用

企业版云数据库

此功能模块为云控用户提供云端数据存储、查询等功能
云数据库访问地址: http://cloud-db.touchsprite.com/
云数据库开发教程:http://v.youku.com/v_show/id_XMzE4MTY4MTc1Mg==.html?qq-pf-to=pcqq.c2c

用户操作

  1. 用户可在数据库管理平台中对已经有操作权限的表进行导入、添加、修改、删除等操作(导入数据大小限制为5m,仅支持 txt 格式文件导入,文件中数据需以空格进行列分割、以回车进行行分割)
  2. 用户可在数据库管理平台为已经有操作权限的表添加视图,可针对视图设置权限(公开、私有)

开发者操作

  1. 开发者可在数据库管理平台建立表结构供脚本用户使用
  2. 开发者需设置数据库中每条记录的大小(单位:kb)
  3. 开发者需设置允许访问表的用户列表(关联企业用户账号至该表)
  4. 添加列名(用于在脚本中访问,必须为英文)
  5. 添加列显示名(用于在用户视图中展示数据时使用,仅限使用中英文)

方法: cloud_db_add 插入数据

方法名称:插入数据
方法功能:插入数据到云数据库表内
调用方法
ok,err = ts_enterprise_lib:cloud_db_add(table_id,data,timeout_seconds)
参数 类型 说明
table_id string 云数据库表ID,可在数据库管理平台查看
data table 需要插入的数据,格式为键值对,对应列名和数据
timeout_seconds number 超时时间,单位秒。数据较大时,应适当延长
返回值 类型 说明
ok boolean 操作结果,成功返回true,失败返回false
err string 当 ok 等于 true,返回用户查询的实际结果;当ok等于false,返回错误原因

脚本实例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. --添加数据
  5. local table_id = '58b7968986d4e24f4a0cf4e5' --可在数据库管理平台查看
  6. local data = {a=1,b=1} --需要写入的数据
  7. local timeout_seconds = 30 --超时设置,单位:秒
  8. local ok,err = ts_enterprise_lib:cloud_db_add(table_id,data,timeout_seconds)
  9. if ok then
  10. dialog("成功")
  11. else
  12. dialog(err)
  13. end

方法: cloud_db_delete 删除数据

方法名称:删除数据
方法功能:删除指定数据
调用方法
ok,err = ts_enterprise_lib:cloud_db_delete(table_id,where,timeout_seconds)
参数 类型 说明
table_id string 云数据库表ID,可在数据库管理平台查看
where table 删除条件,格式为键值对,对应列名和数据
可写多个条件,条件更多写法参考查询数据
timeout_seconds number 超时时间,单位秒。数据较大时,应适当延长
返回值 类型 说明
ok boolean 操作结果,成功返回true,失败返回false
err string 当 ok 等于 true,返回用户查询的实际结果;当ok等于false,返回错误原因

脚本实例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. --删除数据
  5. local table_id = '58b7968986d4e24f4a0cf4e5' --表id
  6. local where = {a=3} --条件(可多个条件)
  7. local timeout_seconds = 30 --超时
  8. local ok,err = ts_enterprise_lib:cloud_db_delete(table_id,where,timeout_seconds)
  9. if ok then
  10. dialog("成功")
  11. else
  12. dialog(err)
  13. end

方法: cloud_db_update 修改数据

方法名称:修改数据
方法功能:修改指定数据
调用方法
ok,err = ts_enterprise_lib:cloud_db_update(table_id,where,data,timeout_seconds)
参数 类型 说明
table_id string 云数据库表ID,可在数据库管理平台查看
where table 删除条件,格式为键值对,对应列名和数据
可写多个条件,条件更多写法参考查询数据
data table 修改数据,格式为键值对,对应列名和数据
timeout_seconds number 超时时间,单位秒。数据较大时,应适当延长
返回值 类型 说明
ok boolean 操作结果,成功返回true,失败返回false
err string 当 ok 等于 true,返回用户查询的实际结果;当ok等于false,返回错误原因

脚本实例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. --修改数据
  5. local table_id = '58b7968986d4e24f4a0cf4e5' --表id
  6. local where = {a=2} --条件
  7. local data= {a=5}
  8. local timeout_seconds = 30 --超时
  9. local ok,err = ts_enterprise_lib:cloud_db_update(table_id,where,data,timeout_seconds)
  10. if ok then
  11. dialog("成功")
  12. else
  13. dialog(err)
  14. end

方法: cloud_db_query 查询数据

方法名称:查询数据
方法功能:查询数据
调用方法
ok,ret = ts_enterprise_lib:cloud_db_query(table_id,where,timeout_seconds)
参数 类型 说明
table_id string 云数据库表ID,可在数据库管理平台查看
where table 删除条件,格式为键值对,对应列名和数据
可写多个条件,条件写法参考脚本示例
timeout_seconds number 超时时间,单位秒。数据较大时,应适当延长
返回值 类型 说明
ok boolean 操作结果,成功返回true,失败返回false
ret string/table 当 ok 等于 true,返回用户查询的实际结果;当ok等于false,返回错误原因

脚本实例1:普通查询

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. local ts = require("ts")--使用扩展库前必须插入这一句
  5. local json = ts.json--使用 JSON 模块前必须插入这一句
  6. --查询数据
  7. local table_id = '58b7968986d4e24f4a0cf4e5' --表id
  8. local where = {a=5 } --条件
  9. local timeout_seconds = 30 --超时
  10. local ok,ret = ts_enterprise_lib:cloud_db_query(table_id,where,timeout_seconds)
  11. if ok then
  12. dialog("成功:"..ts_enterprise_lib.json.encode(ret))
  13. else
  14. dialog(ret)
  15. end

脚本实例2:分页查询

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. local ts = require("ts")--使用扩展库前必须插入这一句
  5. local json = ts.json--使用 JSON 模块前必须插入这一句
  6. --分页查询数据
  7. local table_id = '58b7968986d4e24f4a0cf4e5' --表id
  8. local where = {a=5 } --条件
  9. local option = {pageSize=1,pageIndex=0} --pageSize分页大小(<1000,default:50),pageIndex分页序号(default:0),
  10. local timeout_seconds = 30 --超时
  11. local ok,ret = ts_enterprise_lib:cloud_db_query(table_id,where,option,timeout_seconds)
  12. if ok then
  13. dialog("成功:"..ts_enterprise_lib.json.encode(ret))
  14. else
  15. dialog(ret)
  16. end

脚本实例3:排序查询

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. local ts = require("ts")--使用扩展库前必须插入这一句
  5. local json = ts.json--使用 JSON 模块前必须插入这一句
  6. --排序查询数据
  7. local table_id = '58b7968986d4e24f4a0cf4e5' --表id
  8. local where = {} --条件
  9. local option = {
  10. sort={
  11. a=-1 -- -1:从大到小、1:从小到大
  12. }
  13. }
  14. local timeout_seconds = 30 --超时
  15. local ok,ret = ts_enterprise_lib:cloud_db_query(table_id,where,option,timeout_seconds)
  16. if ok then
  17. dialog("成功:"..ts_enterprise_lib.json.encode(ret))
  18. else
  19. dialog(ret)
  20. end

脚本实例4:模糊条件查询

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. local ts = require("ts")--使用扩展库前必须插入这一句
  5. local json = ts.json--使用 JSON 模块前必须插入这一句
  6. --表id
  7. local table_id = '58a522d7f502b1263083b74b'
  8. local where = {a={lt=2},b={lte=1},c={gt=1},d={gte=1},e={ne=1},f={regex = "b", type="first" } }--条件
  9. --说明
  10. --小于:lt,小于或等于:lte,大于:gt,大于或等于:gte,不等于:ne
  11. --模糊: regex="b" type="first" 开头匹配 type="all" 任意匹配
  12. local timeout_seconds = 30 --超时
  13. local ok,ret = ts_enterprise_lib:cloud_db_query(table_id,where,timeout_seconds)
  14. if ok then
  15. dialog("成功:"..ts_enterprise_lib.json.encode(ret))
  16. else
  17. dialog(ret)
  18. end

方法: cloud_db_query_update 获取数据

方法名称:查询数据
方法功能:查询数据
调用方法
ok,ret = ts_enterprise_lib:cloud_db_query_update(
table_id,
where,
data,
timeout
)
参数 类型 说明
table_id string 云数据库表ID,可在数据库管理平台查看
where table 获取条件,填写为{used_device=""}即可
data table 更新数据,填写为{used_device=getDeviceID()}
timeout_seconds number 超时时间,单位秒。数据较大时,应适当延长
返回值 类型 说明
ok boolean 操作结果,成功返回true,失败返回false
ret string/table 当ok等于true,返回查询到的数据;当ok等于false,返回错误原因

脚本实例

  1. --获取数据
  2. --引入中控库
  3. ts_enterprise_lib = require("ts_enterprise_lib")
  4. assert(ts_enterprise_lib,"无法引入企业专用库")
  5. local ts = require("ts")--使用扩展库前必须插入这一句
  6. local json = ts.json--使用 JSON 模块前必须插入这一句
  7. --表id
  8. local table_id = '58a522d7f502b1263083b74b'
  9. --表中包括两个字段,data字段为取号的内容,used_device 为使用号的设备,如果为空,表示此号未使用
  10. --取号可以通过以下代码完成
  11. if ts_enterprise_lib.build and ts_enterprise_lib.build >=100 then
  12. local ok,ret = ts_enterprise_lib:cloud_db_query_update(
  13. table_id, --table id
  14. {used_device=""}, --未使用的号的条件
  15. {used_device=getDeviceID()}, --修改used_device为当前设备号,给该记录设置了使用标记
  16. 60
  17. )
  18. if ok then
  19. if #ret > 0 then
  20. dialog("成功取号:"..ts_enterprise_lib.json.encode(ret))
  21. --nLog(ts_enterprise_lib.json.encode(ret))
  22. else
  23. dialog("没号了")
  24. end
  25. else
  26. dialog(ret)
  27. end
  28. else
  29. dialog('ts_enterprise_lib版本太低')
  30. end

脚本参数配置

使用说明

启动参数有两种设置方式:
1. 在开发者平台的脚本参数设置内设置
2. 使用script.json文件配置
script.json文件放到脚本文件夹下即可生效

※json需要按照规范编写,不可以添加注释,否则会导致解析错误

※文件编码方式选择UTF-8,其他模式会导致中文乱码

※当两种方式都设置的时候,以json文件配置为准

参数调用方法

每个参数需定义 name 以做标识,在脚本中以name字段值为变量名调用即可
调用示例:
每个参数需定义 name 以做标识,在脚本中以 name 字段值为变量名调用即可
调用示例:

json:

  1. {
  2. "params": [{
  3. "display_name": "选项",
  4. "default": "1",
  5. "name": "mode",
  6. "type": 2
  7. }],
  8. "name": "lua 脚本测试变量监控"
  9. }

lua:

  1. dialog(mode,time)

script.json 格式规范

参数 类型 说明
params - 脚本参数模板
display_name 文本型 脚本显示名
name 文本型 变量名
default 文本型 该选项缺省值,即默认选项
type 数字型 指定选项类型,1 - 数字;2 - 字符串

json示例1:

  1. {
  2. "params":[
  3. {
  4. "display_name": "1游戏模式(1:升级模式,2:打怪模式)",
  5. "default": "1",
  6. "name": "mode",
  7. "type": 2
  8. },
  9. {
  10. "display_name": "登录用户名",
  11. "default": "test",
  12. "name": "user",
  13. "type": 2
  14. },
  15. {
  16. "display_name": "登录密码",
  17. "default": "123456",
  18. "name": "password",
  19. "type": 2
  20. }
  21. ],
  22. "name":"lua脚本测试变量监控" --修改脚本名称为 lua脚本测试变量监控
  23. }

json示例2:

  1. {
  2. "params": [
  3. {
  4. "display_name": "数字",
  5. "name": "number",
  6. "type": 1,
  7. "default": "1"
  8. },
  9. {
  10. "display_name": "字符串",
  11. "name": "string",
  12. "type": 2,
  13. "default": "string"
  14. },
  15. {
  16. "display_name": "单选",
  17. "name": "radio",
  18. "type": 3,
  19. "options": [
  20. {
  21. "name": "1",
  22. "value": 0
  23. },
  24. {
  25. "name": "2",
  26. "value": 1
  27. },
  28. {
  29. "name": "3",
  30. "value": 2
  31. },
  32. {
  33. "name": "4",
  34. "value": 3
  35. }
  36. ],
  37. "default": "0"
  38. },
  39. {
  40. "display_name": "多选",
  41. "name": "checkbox",
  42. "type": 4,
  43. "options": [
  44. {
  45. "name": "1",
  46. "value": 0
  47. },
  48. {
  49. "name": "2",
  50. "value": 1
  51. },
  52. {
  53. "name": "3",
  54. "value": 2
  55. },
  56. {
  57. "name": "4",
  58. "value": 3
  59. },
  60. {
  61. "name": "5",
  62. "value": 4
  63. }
  64. ],
  65. "default": "0@1@2"
  66. },
  67. {
  68. "name": "4m7yf7FJVxBPnlqY9ZFKyKLtrYoCduhc",
  69. "type": 5,
  70. "value": "<p>这是文字说明<br></p>",
  71. "default": "<p>这是文字说明<br></p>"
  72. }
  73. ]
  74. }

控件: switches 开关控件

参数 类型 说明
type 文本型 控件类型,填写switches
id 文本型 控件标识,脚本调用的变量名
list 文本型 开关名称,可写多项,用“,”隔开
select 文本型 选中项,可写多项,用“@”隔开,选项编号从0开始

json示例:

  1. {
  2. "params": [{
  3. "id": "kg",
  4. "type": "switches",
  5. "list": "开关1,开关2,开关3",
  6. "select": "0@2"
  7. }]
  8. }

控件: RadioGroup 单选框

参数 类型 说明
type 文本型 控件类型,填写RadioGroup
id 文本型 控件标识,脚本调用的变量名
list 文本型 开关名称,可写多项,用“,”隔开
select 文本型 选中项,选项编号从0开始

json示例:

  1. {
  2. "params": [{
  3. "id": "dx",
  4. "type": "RadioGroup",
  5. "list": "选项1,选项2,选项3",
  6. "select": "1"
  7. }]
  8. }

控件: CheckBoxGroup 多选框

参数 类型 说明
type 文本型 控件类型,填写CheckBoxGroup
id 文本型 控件标识,脚本调用的变量名
list 文本型 开关名称,可写多项,用“,”隔开
select 文本型 选中项,选项编号从0开始,可写多项,用“@”隔开

json示例:

  1. {
  2. "params": [{
  3. "id": "ceshi9",
  4. "type": "CheckBoxGroup",
  5. "list": "选项1,选项2,选项3,选项4",
  6. "select": "0@3"
  7. }]
  8. }

控件: Label 文本标签

参数 类型 说明
type 文本型 控件类型,填写Label
text 文本型 标题
size 文本型 字体大小
align 文本型 对齐方式,center-居中,left-左,right-右
color 文本型 字体颜色,格式:“255,255,255”

json示例:

  1. {
  2. "params": [{
  3. "type": "Label",
  4. "text": "文字标签",
  5. "size": 18,
  6. "align": "center",
  7. "color": "0,168,233"
  8. },
  9. {
  10. "id": "ceshi9",
  11. "type": "CheckBoxGroup",
  12. "list": "选项1,选项2,选项3,选项4",
  13. "select": "0@3"
  14. }]
  15. }
  • 注意:当json中只有label时无法显示,需要和其他控件一起使用

控件: Edit 普通编辑框

参数 类型 说明
type 文本型 控件类型,填写Edit
id 文本型 控件标识,脚本调用的变量名
prompt 文本型 提示内容
text 文本型 默认内容
row 文本型 编辑框行数,可缺省,默认为一行
kbtype 文本型 编辑框类型,填写ascii

json示例:

  1. {
  2. "params": [{
  3. "id": "input",
  4. "type": "Edit",
  5. "prompt": "请输入一个字母",
  6. "text": "默认值",
  7. "row": "5",
  8. "kbtype": "ascii"
  9. }]
  10. }

控件: Edit 密码编辑框

参数 类型 说明
type 文本型 控件类型,填写Edit
id 文本型 控件标识,脚本调用的变量名
prompt 文本型 提示内容
text 文本型 默认内容
kbtype 文本型 编辑框类型,填写password

json示例:

  1. {
  2. "params": [{
  3. "id": "ceshi8",
  4. "type": "Edit",
  5. "prompt": "请输入密码",
  6. "text": "hhkjkjh",
  7. "kbtype": "password"
  8. }]
  9. }

控件: Edit 数字编辑框

参数 类型 说明
type 文本型 控件类型,填写Edit
id 文本型 控件标识,脚本调用的变量名
prompt 文本型 提示内容
text 文本型 默认内容
kbtype 文本型 编辑框类型,填写number

json示例:

  1. {
  2. "params": [{
  3. "id": "num",
  4. "type": "Edit",
  5. "prompt": "请输入一个数字",
  6. "text": "2",
  7. "kbtype": "number"
  8. }]
  9. }

控件: Edit 滑块

参数 类型 说明
type 文本型 控件类型,填写Edit
id 文本型 控件标识,脚本调用的变量名
kbtype 文本型 编辑框类型,填写range
max 文本型 最大值
min 文本型 最小值

json示例:

  1. {
  2. "params": [{
  3. "id": "num",
  4. "type": "Edit",
  5. "kbtype": "range",
  6. "max": "100",
  7. "min": "0"
  8. }]
  9. }

控件: ComboBox 下拉框

参数 类型 说明
type 文本型 控件类型,填写ComboBox
id 文本型 控件标识,脚本调用的变量名
list 文本型 选择项,多个可选项目之间用英文半角逗号分割
select 文本型 选中项,选项编号从0开始

json示例:

  1. {
  2. "params": [{
  3. "id": "ceshi11",
  4. "type": "ComboBox",
  5. "list": "选项1,选项2,选项3,选项4,选项5,选项6,选项7",
  6. "select": "1"
  7. }]
  8. }

控件: ComboBox 联动下拉框

参数 类型 说明
type 文本型 控件类型,填写ComboBox
id 文本型 控件标识,脚本调用的变量名
list 文本型 一级下拉框选择项,多个可选项目之间用英文半角逗号分割
data 文本型 二级下拉框选择项,选择项有几项,需要用#号分割成几项
select 文本型 选中项,选项编号从0开始,一级和二级选项间用#分割

json示例:

  1. {
  2. "params": [{
  3. "id": "ceshi10",
  4. "type": "ComboBox",
  5. "list": "选项1,选项2,选项3",
  6. "select": "2#1",
  7. "data": "子选项1,子选项2,子选项3,子选项4#子选项5,子选项6,子选项7#子选项8,子选项9",
  8. "source": "test"
  9. }]
  10. }

控件: Image 图片控件

参数 类型 说明
type 文本型 控件类型,填写Image
id 文本型 控件标识,脚本调用的变量名
scr 文本型 图片地址,填写图片url地址

json示例:

  1. {
  2. "params": [{
  3. "type": "Image",
  4. "src": "http://www.touchsprite.com/wp-content/uploads/2016/10/banner2_790x230-790x0.png"
  5. }]
  6. }

UI 实例

  1. {
  2. "params": [{
  3. "type": "Label",
  4. "text": "标题1",
  5. "size": 18,
  6. "align": "center",
  7. "color": "0,168,233"
  8. }, {
  9. "type": "Image",
  10. "src": "http://www.touchsprite.com/wp-content/uploads/2016/10/banner2_790x230-790x0.png"
  11. }, {
  12. "type": "Label",
  13. "text": "switches控件",
  14. "size": 16,
  15. "align": "left",
  16. "color": "0,168,233"
  17. }, {
  18. "id": "kg",
  19. "type": "switches",
  20. "list": "开关1,开关2,开关3",
  21. "select": "0@2"
  22. }, {
  23. "type": "Label",
  24. "text": "RadioGroup控件",
  25. "size": 16,
  26. "align": "left",
  27. "color": "0,168,233"
  28. }, {
  29. "id": "dx",
  30. "type": "RadioGroup",
  31. "list": "选项1,选项2,选项3",
  32. "select": "1"
  33. }, {
  34. "type": "Label",
  35. "text": "Edit控件(普通)",
  36. "size": 16,
  37. "align": "left",
  38. "color": "0,168,233"
  39. }, {
  40. "id": "input",
  41. "type": "Edit",
  42. "prompt": "请输入一个字母",
  43. "text": "默认值",
  44. "kbtype": "ascii"
  45. }, {
  46. "type": "Label",
  47. "text": "Edit控件(多行)",
  48. "size": 16,
  49. "align": "left",
  50. "color": "0,168,233"
  51. }, {
  52. "id": "shuru",
  53. "type": "Edit",
  54. "prompt": "请输入一个字母",
  55. "text": "默认值",
  56. "row": "5",
  57. "kbtype": "ascii"
  58. }, {
  59. "type": "Label",
  60. "text": "Edit控件(滑块)",
  61. "size": 16,
  62. "align": "left",
  63. "color": "0,168,233"
  64. }, {
  65. "id": "num",
  66. "type": "Edit",
  67. "prompt": "请输入一个数字",
  68. "text": "2",
  69. "kbtype": "range",
  70. "max": "100",
  71. "min": "0"
  72. }, {
  73. "type": "Label",
  74. "text": "Edit控件(数字)",
  75. "size": 16,
  76. "align": "left",
  77. "color": "0,168,233"
  78. }, {
  79. "id": "num1",
  80. "type": "Edit",
  81. "prompt": "请输入一个数字",
  82. "text": "123456",
  83. "kbtype": "number"
  84. }, {
  85. "type": "Label",
  86. "text": "Edit控件(密码)",
  87. "size": 16,
  88. "align": "left",
  89. "color": "0,168,233"
  90. }, {
  91. "id": "ceshi8",
  92. "type": "Edit",
  93. "prompt": "请输入密码",
  94. "text": "hhkjkjh",
  95. "kbtype": "password"
  96. }, {
  97. "type": "Label",
  98. "text": "CheckBoxGroup控件",
  99. "size": 16,
  100. "align": "left",
  101. "color": "0,168,233"
  102. }, {
  103. "id": "ceshi9",
  104. "type": "CheckBoxGroup",
  105. "list": "选项1,选项2,选项3,选项4",
  106. "select": "0@3"
  107. }, {
  108. "type": "Label",
  109. "text": "ComboBox控件(二级)",
  110. "size": 16,
  111. "align": "left",
  112. "color": "0,168,233"
  113. }, {
  114. "id": "ceshi10",
  115. "type": "ComboBox",
  116. "list": "选项1,选项2,选项3",
  117. "select": "2#1",
  118. "data": "子选项1,子选项2,子选项3,子选项4#子选项5,子选项6,子选项7#子选项8,子选项9",
  119. "source": "test"
  120. }, {
  121. "type": "Label",
  122. "text": "ComboBox控件(一级)",
  123. "size": 16,
  124. "align": "left",
  125. "color": "0,168,233"
  126. }, {
  127. "id": "ceshi11",
  128. "type": "ComboBox",
  129. "list": "选项1,选项2,选项3,选项4,选项5,选项6,选项7",
  130. "select": "1"
  131. }]
  132. }

带分页显示实例

  1. {
  2. "params": {
  3. "width":590,
  4. "height":550,
  5. "titles":"第1页,第2页,第3页",
  6. "pages": [
  7. [
  8. {
  9. "type": "Label",
  10. "text": "标题1",
  11. "size": 18,
  12. "align": "center",
  13. "color": "0,168,233"
  14. },
  15. {
  16. "type": "Image",
  17. "src": "http://www.touchsprite.com/wp-content/uploads/2016/10/banner2_790x230-790x0.png"
  18. },
  19. {
  20. "type": "Label",
  21. "text": "switches控件",
  22. "size": 16,
  23. "align": "left",
  24. "color": "0,168,233"
  25. },
  26. {
  27. "type": "switches",
  28. "list": "开关1,开关2,开关3",
  29. "select": "0@2",
  30. "id":"swk"
  31. },
  32. {
  33. "type": "Label",
  34. "text": "RadioGroup控件",
  35. "size": 16,
  36. "align": "left",
  37. "color": "0,168,233"
  38. },
  39. {
  40. "id": "ceshi4",
  41. "type": "RadioGroup",
  42. "list": "选项1,选项2,选项3",
  43. "select": "1"
  44. },
  45. {
  46. "type": "Label",
  47. "text": "Edit控件(普通)",
  48. "size": 16,
  49. "align": "left",
  50. "color": "0,168,233"
  51. },
  52. {
  53. "id": "ceshi5",
  54. "type": "Edit",
  55. "prompt": "请输入一个字母",
  56. "text": "默认值",
  57. "kbtype": "ascii"
  58. },
  59. {
  60. "type": "Label",
  61. "text": "Edit控件(多行)",
  62. "size": 16,
  63. "align": "left",
  64. "color": "0,168,233"
  65. },
  66. {
  67. "id": "ceshi6",
  68. "type": "Edit",
  69. "prompt": "请输入一个字母",
  70. "text": "默认值",
  71. "row": "5",
  72. "kbtype": "ascii"
  73. },
  74. {
  75. "type": "Label",
  76. "text": "Edit控件(滑块)",
  77. "size": 16,
  78. "align": "left",
  79. "color": "0,168,233"
  80. },
  81. {
  82. "type": "Edit",
  83. "prompt": "请输入一个数字",
  84. "text": "2",
  85. "kbtype": "range",
  86. "max": "100",
  87. "min": "0",
  88. "id":"hk"
  89. },
  90. {
  91. "type": "Label",
  92. "text": "Edit控件(数字)",
  93. "size": 16,
  94. "align": "left",
  95. "color": "0,168,233"
  96. },
  97. {
  98. "id": "ceshi7",
  99. "type": "Edit",
  100. "prompt": "请输入一个数字",
  101. "text": "123456",
  102. "kbtype": "number"
  103. },
  104. {
  105. "type": "Label",
  106. "text": "Edit控件(密码)",
  107. "size": 16,
  108. "align": "left",
  109. "color": "0,168,233"
  110. },
  111. {
  112. "id": "ceshi8",
  113. "type": "Edit",
  114. "prompt": "请输入密码",
  115. "text": "hhkjkjh",
  116. "kbtype": "password"
  117. },
  118. {
  119. "type": "Label",
  120. "text": "CheckBoxGroup控件",
  121. "size": 16,
  122. "align": "left",
  123. "color": "0,168,233"
  124. },
  125. {
  126. "id": "ceshi9",
  127. "type": "CheckBoxGroup",
  128. "list": "选项1,选项2,选项3,选项4",
  129. "select": "0@3"
  130. },
  131. {
  132. "type": "Label",
  133. "text": "ComboBox控件(二级)",
  134. "size": 16,
  135. "align": "left",
  136. "color": "0,168,233"
  137. },
  138. {
  139. "id": "ceshi10",
  140. "type": "ComboBox",
  141. "list": "选项1,选项2,选项3",
  142. "select": "2#1",
  143. "data": "子选项1,子选项2,子选项3,子选项4#子选项5,子选项6,子选项7#子选项8,子选项9",
  144. "source": "test"
  145. },
  146. {
  147. "type": "Label",
  148. "text": "ComboBox控件(一级)",
  149. "size": 16,
  150. "align": "left",
  151. "color": "0,168,233"
  152. },
  153. {
  154. "id": "ceshi11",
  155. "type": "ComboBox",
  156. "list": "选项1,选项2,选项3,选项4,选项5,选项6,选项7",
  157. "select": "1"
  158. }
  159. ],
  160. [
  161. {
  162. "type": "Label",
  163. "size": 25,
  164. "text": "第二页设置",
  165. "align": "center",
  166. "color": "0,0,0"
  167. },
  168. {
  169. "text": "默认值",
  170. "type": "Edit",
  171. "kbtype": "ascii",
  172. "prompt": "请输入一个字母"
  173. },
  174. {
  175. "text": "默认值",
  176. "type": "Edit",
  177. "kbtype": "number",
  178. "prompt": "请输入一个数字"
  179. }
  180. ],
  181. [
  182. {
  183. "type": "Label",
  184. "size": 25,
  185. "text": "第三页设置",
  186. "align": "center",
  187. "color": "0,0,0"
  188. },
  189. {
  190. "type": "CheckBoxGroup",
  191. "list": "选项1,选项2,选项3,选项4,选项5,选项6,选项7",
  192. "select": "3@5"
  193. },
  194. {
  195. "list": "选项1,选项2,选项3",
  196. "source": "test",
  197. "type": "ComboBox",
  198. "data": "子选项1,子选项2,子选项3,子选项4#子选项5,子选项6,子选项7#子选项8,子选项9",
  199. "select": "1"
  200. },
  201. {
  202. "dataSource": "test",
  203. "type": "ComboBox",
  204. "select": "1"
  205. }
  206. ]
  207. ]
  208. }
  209. }

旧版本中控数据交换功能

以下功能仅在1200之前版本的中控版本可以使用,新版本已弃用

数据交换 使用示例

  1. --引入中控库
  2. local ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_libb,"无法引入企业专用库")
  4. local redis = ts_enterprise_lib.redis
  5. assert(redis,"无法引入redis库")
  6. local red = redis:new()
  7. red:set_timeout(5) -- 5 sec
  8. assert(red:connect())
  9. assert(red:set("dog", "an animal"))
  10. local ret,msg = red:get("dog")
  11. if ret then
  12. nLog("dog is "..ret)
  13. else
  14. nLog("redis get error"..msg)
  15. end
  16. assert(red:set("params", {aaa=111,bbb=222}))
  17. local params,msg = red:get("params")
  18. if params then
  19. nLog("params.aaa="..params.aaa..",params.bbb="..params.bbb)
  20. else
  21. nLog("redis get params error"..msg)
  22. end

新中控数据交换功能

以下功能仅在 1267之后版本的中控版本可以使用

数据交换 使用示例

方法:ts_enterprise_lib:variable_save() 保存数据交换的值

函数名称:保存数据交换的值
函数功能:保存数据交换的值
函数方法:

assert(ts_enterprise_lib:variable_save("k","v"))

参数 类型 说明
k string 必填,对应是 key
v string/number 选填,对应是 value
返回值 类型 说明
ret boolean true - 成功,false - 失败
msg string 操作结果或者错误信息

函数用例:

  1. --引入中控库
  2. local ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. assert(ts_enterprise_lib:variable_save("k","v"))
  5. if ret then
  6. nLog("params="..msg)
  7. else
  8. nLog("get params error")
  9. end

方法: ts_enterprise_lib:variable_get() 获取数据交换的值

函数名称:获取数据交换的值
函数功能:获取数据交换的 value 的值
函数方法

local ret,msg = ts_enterprise_lib:variable_get("k")

参数 类型 说明
k string 必填,对应是 key
返回值 类型 说明
ret boolean true - 成功,false - 失败
msg string 查询结果或者错误信息

函数用例:

  1. --引入中控库
  2. ts_enterprise_lib = require("ts_enterprise_lib")
  3. assert(ts_enterprise_lib,"无法引入企业专用库")
  4. local ret,msg = ts_enterprise_lib:variable_get("k")
  5. if ret then
  6. nLog("params="..msg)
  7. else
  8. nLog("get params error")
  9. end

触动企业版中控器插件开发参考手册

用途

目标

目录格式

  1. |____plugin
  2. | |____test --目录名为插件id
  3. | | |____1.png
  4. | | |____api.js
  5. | | |____api.lua
  6. | | |____EquipmentAuthor.css
  7. | | |____EquipmentAuthor.js
  8. | | |____main.lua
  9. | | |____plugin.json --插件配置文件
  10. | | |____plugin_index.html
  11. | | |____html.html

插件配置文件 plugin.json文件格式

  1. {
  2. "name": "插件演示", //插件显示名(桌面下的图标名)
  3. "window": {
  4. "title":"测试插件", //窗体的标题
  5. "width":1000, //窗体宽
  6. "height":500 //窗体高
  7. },
  8. "icon":"1.png", //桌面图标文件
  9. "index":"index.html", //桌面入口文件
  10. "main":"mail.lua", //插件的主函数入口
  11. "api":"api.lua" //插件api文件
  12. }

定制插件窗体 ui,index.html

  1. <!DOCTYPE html>
  2. <html>
  3. <head lang="en">
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <!--引入api调用的接口-->
  7. <script src="api"></script>
  8. </head>
  9. <body>
  10. <h1>测试插件</h1>
  11. </body>
  12. <script>
  13. <!--调用插件api,名字abc,参数10,10,返回值ret1,ret2,ret3-->
  14. api_call("abc",function(success,ret1,ret2,ret3){
  15. console.info(success,ret1,ret2,ret3)
  16. alert(ret1)
  17. }
  18. ,10,10)
  19. </script>
  20. </html>

开发插件 api

插件 api 范例文件

  1. local api = {}
  2. --取当前时间
  3. function api.current_time(task)
  4. return os.time()
  5. end
  6. --计算乘积
  7. function api.multiplication(task,a,b)
  8. return a*b
  9. end
  10. --多参数示例
  11. function api.multi_param(task,p1,p2,p3,p4)
  12. return p1,p2,p3,p4
  13. end
  14. --阻塞api示例
  15. local 退出条件 = false
  16. function api.block(task)
  17. while true do
  18. if 退出条件 then
  19. break
  20. end
  21. --在可能阻塞的代码段,必须调用task.sleep(x),其中x为等待x毫秒
  22. task.sleep(100)
  23. end
  24. end
  25. --获取设备号和脚本id示例
  26. function api.get_device(task)
  27. return task.deviceid
  28. end
  29. function api.get_tspid(task)
  30. return task.tspid
  31. end
  32. return api

js 调用 api 范例文件

  1. <!--引入api调用的接口-->
  2. <script src="api"></script>
  1. <script>
  2. <!--调用插件api,名字abc,参数1,2,3,4,返回值ret1,ret2,ret3,ret4-->
  3. api_call("multi_param",function(success,ret1,ret2,ret3,ret4){
  4. console.info(success,ret1,ret2,ret3,ret4)
  5. alert(ret1)
  6. }
  7. ,1,2,3,4)
  8. </script>
  1. <!--引入api调用的接口-->
  2. <script src="angular_api"></script>
  3. <script>
  4. <!--调用插件api,名字abc,参数1,2,3,4,返回值ret1,ret2,ret3,ret4-->
  5. angular_api_call($http,"multi_param",function(success,ret1,ret2,ret3,ret4){
  6. console.info(success,ret1,ret2,ret3,ret4)
  7. alert(ret1)
  8. }
  9. ,1,2,3,4)
  10. </script>

脚本调用 api 范例

  1. ts_enterprise_lib = require("ts_enterprise_lib")
  2. assert(ts_enterprise_lib,"无法引入企业专用库")
  3. -- 插件id(插件的目录名)
  4. local plugin_id = "test"
  5. -- 调用api的名字
  6. local api_name = "multi_param"
  7. local p1 = 1
  8. local p2 = 2
  9. local p3 = 3
  10. local p4 = 4
  11. --设置调用api等待的时间,缺省是5秒,对于立即返回的api,可以不用设置,如果是阻塞较长时间的api,根据需要调整大小,
  12. ts_enterprise_lib.timeout = 5
  13. local success,ret1,ret2,ret3,ret4 = ts_enterprise_lib:plugin_api_call(plugin_id,api_name,p1,p2,p3,p4)
  14. if success then
  15. toast("调用成功:"..ret1..ret2..ret3..ret4)
  16. else
  17. toast("调用失败:"..ret1)
  18. end

插件的主函数用途和示例

  1. local function init_plugin(task)
  2. -- todo 插件初始化
  3. end
  4. local function loop(task)
  5. -- todo 插件后台循环
  6. end
  7. return function(task)
  8. init_plugin(task)
  9. while true do
  10. loop(task)
  11. task.sleep(100)
  12. end
  13. end

附录

触动精灵企业版中控端和客户端使用手册

https://www.zybuluo.com/miniknife/note/288009

已知与触动精灵冲突的插件列表

showUI 不能弹出、点击没反应、滑动失效等问题有可能是由于安装了冲突插件引起的
https://www.zybuluo.com/miniknife/note/307651#已知与触动精灵冲突的插件列表

脚本编辑器

远程调试、运行脚本
TouchSprite Studio(v1.1.7):http://pan.baidu.com/s/1bn5b9Vp 密码:k9yf

抓色器

远程截图、取色、生成代码
触动精灵抓色工具(v1.7.10):http://dev.touchsprite.com/

脚本加密

https://www.zybuluo.com/miniknife/note/307651#脚本加密

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注