util脚本

--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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值