|
Post by zenkrye on Apr 14, 2022 15:48:15 GMT
I am working on cleaning up some code I wrote. while debugging the code I was putting in lots of highlights to make sure I was searching the right regions and found the right image. Since that seemed to add a lot of extra lines of code, I am working on creating some functions that will work better. I have come up with this so far:
function eClick(reg, img, debug, sec)
local r, m
if debug then reg:highlight(sec) end
if reg:existsClick(img) then
r = true
if debug then
m = reg:getLastMatch()
m:highlight(sec)
end
else
r = false
end
return r
end
-- example if eClick(Region(40, 50, 80, 80), 'target1.png', true, .25) then
eClick(Region(100, 75, 80, 80), 'target2.png', true, .25)
end
Is if possible to modify this to follow the current reg:function format? so a call would look like
if Region(40, 50, 80, 80):eClick('target1.png', true, .25) then
Region(100, 75, 80, 80):eClick('target2.png', true, .25)
end
|
|
|
Post by donscoy on Nov 6, 2022 19:49:16 GMT
Equivalent lua code entry, but slightly shorter. Enjoy
function c(x,y,w,h,img,debug,sec)
local r = Region(x,y,w,h)
_ = debug and r:highlight(sec)
_ = r:exists(img) and debug and r:getLastMatch():highlight(sec)
return r:getLastMatch() and click(r:getLastMatch()) or false
end
_ = c(0,0,1600,900,"test.png", false, .50) and c(0,0,1600,900,"test2.png", true, .50)
|
|