|
Post by oomkoos on Dec 1, 2019 6:36:24 GMT
I have a function below, that looks for a image , and moves it to the center of the screen.
Then perform functions and move around , and return the image back to the center of the screen.
This works perfectly for exactly 3 times, the forth time i call the function, it activates the image not found, even tho the image is on the screen Pattern similar is set to 0.6, i have tried it lower as well with the same results The swipe in the not exist section is to move the screen if it is not found until the image comes onto the screen
Am i missing some logic as to why it only works exactly 3 times ?
function ctrcatterpillar(n)
while not exists(catterpillarPattern) do
toast("Catterpillar NOT Found")
swipe(Location(90, 110), Location(400, 100))
wait(1)
swipe(Location(90, 110), Location(100, 400))
wait(1)
end
wait(1)
if exists(catterpillarPattern) then
match = getLastMatch(catterpillarPattern)
x = match:getX()
y = match:getY()
dragDrop(Location(x,y), screenCenter)
end
wait(1)
end
|
|
|
Post by Mercobots on Dec 1, 2019 12:29:24 GMT
hi there can you provide the code calling this function or a video ?
btw you can use
match = getLastMatch()
instead
match = getLastMatch(catterpillarPattern)
|
|
|
Post by oomkoos on Dec 1, 2019 12:49:05 GMT
Hi Mercobots Thank you for the reply and the better way of assigning match This is the main code below : while true do if(productionValue) and (firstRoundValue) and (runs==1) then FirstRoundProduction(1) end if (dairyTimer:check() >= (dairyCheck*60)) and (dairyUseValue) and (productionValue) and (runs > 1) then firstMachinesPos(1) wait(1) useDairy(1) ctrcatterpillar(1) dairyTimer:set() end if (juiceTimer:check() >= (juiceCheck*60)) and (juicerUseValue) and (productionValue) and (runs >1) then firstMachinesPos(1) wait(1) useJuicer(1) ctrcatterpillar(1) juiceTimer:set() end runs=runs+1 if exists(reachPattern) then break end end The function firstmachinespos : function firstMachinesPos(n) ctrcatterpillar(1) wait(1) dragDrop(screenCenter, catterFirstMachines) end
|
|
|
Post by Mercobots on Dec 1, 2019 14:11:47 GMT
Thinking better, is a long shot but I think your problem is due the similarity, you are getting a positive false, so in other words the Bot can detect the image but is not the right one and he continues the script... So my advice is to highlight the match for debug porpuse
if exists() then getLastMatch():highlight() End
|
|
|
Post by oomkoos on Dec 1, 2019 14:16:04 GMT
Thank you Mercobot , I will do that
|
|
|
Post by oomkoos on Dec 1, 2019 15:01:28 GMT
Am i correct in saying it keeps the last 4 matches in memory and keep them highlighted on the screen ?
The minute it reaches the 4th match highlighted on the screen , it stops finding the image
|
|
|
Post by oomkoos on Dec 1, 2019 15:18:16 GMT
Not sure if it will fix my problem , but is there a way to clear the last match before going to the next ?
|
|
|
Post by Mercobots on Dec 1, 2019 15:23:21 GMT
Last match highlighted? Yes you can set a timer match:highlight(2) or highlightOff()
|
|
|
Post by oomkoos on Dec 2, 2019 4:10:54 GMT
Problem solved, I accidentally assigned a different image to catterpillarPattern elsewhere in the scrip Thanks for the help Mercobots , highlighting the match as suggested helped , and using it in all matches now
|
|