函数:multiColor 多点比色

函数名称:多点比色

函数分类:TSLib(内置,无需下载)

函数功能:判断多个坐标相应颜色是否成立,成立返回 true,不成立返回 false

函数方法

bool = multiColor(array,dim,flag)

参数 类型 必填 默认值 说明
array table 是 — 需要判断的颜色数组
dim number 否 90 精度:0~100;精度越高越不容易找到,100 为完全匹配
flag boolean 否 true 是否保持屏幕
保持屏幕 - true,取消保持屏幕 - false
仅支持 TSLib v1.2.6 及其以上版本
main number 否 — 偏色值,例如 main = 0x101010(十六进制)
仅支持 TSLib v1.4.6 及其以上版本,
填写偏色后精度将失效
返回值 类型 说明
bool boolean true - 全部坐标和颜色一致,false - 坐标和颜色值不符

函数用例

方式一

require "TSLib"
--全部坐标点和颜色一致时返回 true,== true 可省略不写
if multiColor({{78,272,0x00a8e9},{120,44,0xffffff},{122,197,0x00a8e9}},90,false) == true then
    tap(x,y)
    mSleep(50)
    toast("找到颜色并点击")
    mSleep(3000)
end

方式二(table 格式)

require "TSLib"
local options = {
    ["dim"] = 90,
    ["flag"] = false
}
local color_table = {
    {   45,  171, 0xff5722},
    {   45,  168, 0xfce6a8},
    {   45,  174, 0xfce6a8},
}
if multiColor(color_table,options) then--全部坐标点和颜色一致时返回 true,== true 可省略不写
    toast("找到颜色")
else
    toast("未找到颜色")
end

偏色方式一

require "TSLib"
--偏色可以填写到 array 颜色数组中,仅对当前颜色生效
--偏色仅支持 TSLib v1.4.6 及其以上版本,填写偏色后精度将失效
if multiColor({{78,272,0x00a8e9},{120,44,0xffffff},{122,197,0x00a8e9,0x101010}},90,false) == true then
    tap(x,y)
    mSleep(50)
    toast("找到颜色并点击")
    mSleep(3000)
end

偏色方式二

require "TSLib"
--偏色可以填写到 options 中,对所有颜色生效
--偏色仅支持 TSLib v1.4.6 及其以上版本,填写偏色后精度将失效
--如果偏色在 array 颜色数组中及 options 都存在,options 填写的偏色优先级最高
local options = {
    ["dim"] = 90,
    ["flag"] = false,
    ["main"] = 0x30beaa
}
local color_table = {
    {   45,  171, 0xff5722},
    {   45,  168, 0xfce6a8},
    {   45,  174, 0xfce6a8},
}
if multiColor(color_table,options) then--全部坐标点和颜色一致时返回 true,== true 可省略不写
    toast("找到颜色")
else
    toast("未找到颜色")
end

注意事项

  • array 为 table 表,坐标颜色值数量任意(填一个坐标和颜色值时为单点找色),可配合触动精灵抓色器自动生成代码使用
Copyright 北京帮你玩科技有限公司 2026 all right reserved,powered by Gitbook该文章修订时间: 2026-11-12 11:02:23

results matching ""

    No results matching ""