--rgb转hsv,返回h,s,v三个值
function rgb2hsv(r,g,b)
-- 找出r,g,b最小值和最大值
local min = math.min(r,g,b)
local max = math.max(r,g,b)
local diff = max - min
local h,s,v = 0,0,0
v = max
if max == 0 then
s = 0
else
s = diff
end
if diff ~= 0 then
if r == max then
h = 60 * (g - b) / diff
elseif g == max then
h = 60 * (b - r) / diff + 120
else
h = 60 * (r - g) / diff + 240
end
if h < 0 then
h = h + 360
end
else
h = -1
end
local tmp = math.modf(h)
return tmp,s,v
end
function checkAndCloseMap()
--先检查有没有出卡
r1,g1,b1 = getColorRGB(707,636)
h1,s1,v1 = rgb2hsv(r1,g1,b1)
while h1>210 and s1>100 and v1>160 do
tap(707,636)
r1,g1,b1 = getColorRGB(707,636)
h1,s1,v1 = rgb2hsv(r1,g1,b1)
end
r,g,b = getColorRGB(826,421)
h,s,v = rgb2hsv(r,g,b)
r2,g2,b2 = getColorRGB(711,52)
h2,s2,v2 = rgb2hsv(r2,g2,b2)
while (v<80 and (s2<20 and v2>170)) do
tap(1077,58)
mSleep(1000)
r,g,b = getColorRGB(826,421)
h,s,v = rgb2hsv(r,g,b)
r2,g2,b2 = getColorRGB(711,52)
h2,s2,v2 = rgb2hsv(r2,g2,b2)
end
end
function checkIfFull()
r,g,b = getColorRGB(413,523)
h,s,v = rgb2hsv(r,g,b)
toast(string.format("h=%d s=%d v=%d",h,s,v))
if v<50 then
return true
end
return false
end
NeedKick = true
while 1 do
mSleep(10000)
time = getNetTime()
currentDate = os.date("%Y%m%d",time)
--dialog(currentDate)
currentHour = os.date("%H",time)
currentMin = os.date("%M",time)
currentHour = tonumber(currentHour)
currentMin = tonumber(currentMin)
if currentHour == 9 and NeedKick then
if checkIfFull()==true then
dialog(currentHour)
end
NeedKick = false
end
if currentHour ~= 9 then
NeedKick = true
end
end
util脚本
最新推荐文章于 2023-05-28 11:01:45 发布