找到某个颜色的点如何随机运行两个命令其中一个?

发布于 2021-02-02 15:22:20

如何让脚本实现检测到颜色后随机选择命令A或者命令B运行一次?求大神教教。。

-- 自动打怪1
x, y = findColorInRegion(0x7AA300,966,26,966,26)--检测到颜色
if x~= -1 and y~= -1 then

    命令A
mSleep(500+math.random(-200,200))    
touchDown(0, 161+math.random(-30,30), 1709+math.random(-30,30))    
mSleep(500+math.random(-200,200))        
touchUp(0)    
mSleep(500+math.random(-200,200))        
for i=1, math.random(1, 3) do
touchDown(0, 386+math.random(-30,30), 1648+math.random(-30,30))    
mSleep(500+math.random(-200,200))    
touchUp(0)    
mSleep(500+math.random(-200,200))    

命令B
mSleep(500+math.random(-200,200))    
touchDown(0, 161+math.random(-30,30), 1709+math.random(-30,30))        
mSleep(500+math.random(-200,200))        
touchUp(0)    
mSleep(500+math.random(-200,200))        
for i=1, math.random(1, 3) do
touchDown(0, 281+math.random(-30,30), 1500+math.random(-30,30))        
mSleep(500+math.random(-200,200))    
touchUp(0)    
mSleep(500+math.random(-200,200))

end
end

查看更多

关注者
0
被浏览
591
Evan
Evan 认证专家 2021-02-02
function main()
  math.randomseed(tostring(os.time()):sub(5):reverse()); -- 随机种子
  x, y = screen.findImage("/var/touchelf/a.png");--这里是描述中的检测到图片
  if x ~= -1 and y ~= -1 then
    act = math.random(1, 2); --这里是随机
    if act == 1 then
      fight1()
    elseif act == 2 then
      fight2()
    end
  end
end
function fight1()
  --自动打怪1
end
function fight2()
  --自动打怪2
end
1 个回答

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览