Question about visual search and repeatif (can it be told to repeat x amount of times?)

so I have this in a loop:

loop
do
visualsearch pictureX (game item)
repeatif ${found}==0
and then actions to click the picture (item) and do actions ingame.
gotolabel loop

works wonders as long there is a certain picture in the inventory of those items. But how do I break the loop with the repeatif when there are no more simular pictures (items) of X?

Can I say in some way only do repeatif==0 (max 10 times?)
For example if I only have 10 items after that I want the macro to close the game.

Anyone has some insight how to do this? Or is there another alternative or way of programming this? :slight_smile:

Instead of "gotolabel loop use a second

Do…

RepeatIf (imageNumer <10)

1 Like

Or, if you want to exit the loop, use break.

1 Like

I fixed it by doing a while, visual search found X, then add a counter to deduct per loop till it reaches zero and exit the while. ^^