|
Post by enissay on Apr 14, 2019 14:31:01 GMT
Hi all,
I do have a function which returns true/false if image is found. Similarly to exists(), but it tries up to 3 times in a row to make sure nothing is found given the environment is dynamic.
I have been using the first one below for weeks and it works fine, until I found a case in which I started suspecting a flaw in the logic. I then made the 2nd one which was even worse.
I am out of clues about what is wrong and would appreciate a 3rd party advice.
function isImageInRegion1(img, reg) local waitCounter = 0
while not reg:exists(Pattern(img):similar(accuracy)) do toast("cant find "..img)
waitCounter = waitCounter + 1 if waitCounter > 3 then toast("cant find "..img.." - Limit reached - Abort!") return false end end
return true end
function isImageInRegion2(img, reg)
for i = 1,3,1 do if reg:exists(Pattern(img):similar(accuracy)) then return true
else toast("cant find "..img)
if i == 3 then toast("cant find "..img.." - Limit reached - Abort!") return false end end end end Cordially, Enissay
|
|