如何让脚本实现检测到颜色后随机选择命令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
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
谢谢E大