|
Post by crossa on Jan 30, 2021 6:17:45 GMT
Basically I want something like this, its written on Sikuli.
Iterator<Match> it = s.findAll(Imagepath);
while(it.hasNext()){
System.out.println("the match is "+it.next().click());
} Do we have hasNext() function in ankulua?
Here is what I try to write in lua
a = Pattern("image.png"):similar(0.7) b = Pattern("image2.png"):similar(0.7) r = Region(1922, 5, 400, 910)
all = r:findAll(a)
-- I know its not gonna work need advice to write this code in lua
while(all.hasNext()) do --I want to iterate as many as "a" images on "r" click(all[0]) --I want the script to click the first "a" if(notExist(b)) then click(all.next) --This mean, If "b" not exist, i want to click next "a". end end
So.. what I try to achieve here is. 1. I Want to iterate as many as image1 in a region. 2. If dont see image2, I want to check on next image1.
I'm bit new in programming. So I might be screw my logic here. Thank you.
|
|
|
Post by crossa on Jan 30, 2021 13:52:24 GMT
Solved by myself. After read some post in forum
incase someone face similar problem. you can use ipairs
a = Pattern("image.png"):similar(0.7) b = Pattern("image2.png"):similar(0.7) r = Region(1922, 5, 400, 910)
all = r:findAll(a)
for i, m in ipairs(all) do click(all[i]) if exists(b) then -- do something break end end Thank you.
|
|