Sikuli loop statement

Asked by alex on 2017-06-20

why my program not work at all
i want to make a bot for some game..

while exits (IMG1) :
      if exits (IMG2) or exits (IMG3) or exits (IMG4)
           wait (3)
      else :
           click (IMG5)

what i want is..:
(1) when exits (IMG1) i want to wait around 10sec
(2) When exits (IMG2) i want to wait around 30sec
(3) if not exits (IMG1) or (IMG2) i want to click (IMG5)
(4) and repeatable until im stop the execution

how to see a log action while execution"?

thanks in advanced

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
masuo
Solved:
2017-06-22
Last query:
2017-06-22
Last reply:
2017-06-22

First, there should be ":" after if clause.

masuo (masuo-ohara) said : #2

Realy your codes are "exits (IMG1)"?

Did you get error message "[error] NameError ( name 'exits' is not defined )"?

You should Change "exits()" to "exists()".
And try to modify "exits(IMG1)" to "exists(IMG1,0)".

Second parameter zero is needed to not to wait three seconds, if image dose not exist.

alex (alexdniel88) said : #3

@masuo
sry its a typo there..

its should be Exists ()...

i will try ..

alex (alexdniel88) said : #4

while exists (IMG1,10) :
      if exists (IMG2,30) or exists (IMG3,30) or exists (IMG4,30)
           wait (1)
      else :
           click (IMG5)

so this will do :
- when see (img1) it will wait for 10 sec and see (img2 or img3 or img4) it will wait for 30sec?

Best masuo (masuo-ohara) said : #5

exists (IMG1,10)
if IMG1 dose not exist exists(IMG1,10) return after 10 seconds.

exists (IMG2,30) or exists (IMG3,30) or exists (IMG4,30)
exists() is called sequentially.
if all images do not exist this step return after 90 seconds.

http://sikulix-2014.readthedocs.io/en/latest/region.html?highlight=exists

alex (alexdniel88) said : #6

Thanks masuo, that solved my question.