Help with script

Asked by Mike

Hi all, i need help with my script please!

click( )
wait(3)

click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)

click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(800, )
wait(3)
click( )

click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait( )
wait(3)

Below is where the problem is from click (getLastMatch())
# --- this loops as long as img is visible
while exists(img , 0):
   click(getLastMatch())
   if exists(img , 0):
      continue # skip the rest and start next turn
popup("Under ATTACK!")

 click(getLastMatch()) in the script is this the right one to do, i want it to go back to first line of the script and start again. But it is continuing to popup Under ATTACK.

Please help me on what i need to do!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

--- wait(800, )
should give an error???

- sequence of clicks
your thousand clicks is the same as one click looking from syntax.

So guessing again:

while exists(img , 0):
   click(getLastMatch())
   if exists(img , 0):
      continue # skip the rest and start next turn
   click()
   # all your other clicks and waits

when the last action of your click chain is processed, then it will go back to top and look again for img until it vanishes.

Revision history for this message
Mike (mikewebbcp) said :
#2

----wait(800, )

Nope it did not come up with error but now changed it to wait(img, FOREVER) if i got this right, it'll wait untill that img shows then continue..

# This makes sure your in Space Base
click( )
wait(3)

# This refuels your fleet
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)

# This starts your Instances
click( )
wait(3)
click( )
wait(3)
click( )#Instance Lvl
wait(3)
click( )
wait(3)
click( )#Fleet1
wait(3)
click( )#Fleet2
wait(3)
click( )#Fleet3
wait(3)
click( )#Fleet4
wait(3)
click( )#Fleet5
wait(3)
click( )#Fleet6
wait(3)
click( )
wait(3)
click( )
wait( , FOREVER)
click( )

#This will sort Instances mail and box
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait(3)
click( )
wait( )
wait(3)

# --- this loops as long as img is visible
while exists( , 0): # i think this should have been if cos if exists it'll repeat top script
   click(getLastMatch())
   if exists( , 0): #this should be if exists it'll continue and popup message Under ATTACK
      continue # skip the rest and start next turn
       click()
   # all your other clicks and waits - do i have to repeat myself????
popup("Under ATTACK!")

What i would like is something like this:

if exists( ,0)
repeat script from top again!
if exists( ,0)
continue
popup("Under ATTACK!")

Sorry for being a pain

Revision history for this message
Mike (mikewebbcp) said :
#3

Thanks RaiMan, that solved my question.