Question #239460 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/239460
Status: Open => Answered
RaiMan proposed the following answer:
Generally in these cases, you should use a never ending loop and move
the decisions into the loop what to do, to skip or when to terminate:
supposing "static-image.png" is something that is always visible, while
the game is active (a logo for example).
isRunning = "static-image.png"
while True:
if not exists(isRunning, 0):
print ("we should stop now")
break # leave the loop
# now we check the top level actions
if exists(go, 0):
processGo()
if exists(battle, 0):
processBattle()
if exists(items, 0):
processItems()
print "main loop has finished"
exit()
# for the doing we use functions, to keep the main workflow clear (should have
max 3 indent levels)
# if needed and makes sense the functions can have parameters and might return
something
def processGo():
# here goes what we want to do in case go is found
def processBattle():
# here goes what we want to do in case battle is found
def processItems():
# here goes what we want to do in case items is found
--- comment on exists(image, 0):
the wait time of 0 makes exists to come back immediately after the first search
wether found or not. otherwise not found would take 3 seconds, which is the
standard waiting time.
- general comments
to speed things up try to search in restricted regions, that you evaluate based
on other already known matches.
If you are sure, that an image will always be found in the same place, store
the match after the first success and use the match instead to act on.
Same goes for visual objects, that always have the same position in relation to
other already matched objects. these should not be searched but evaluated as
region objects to act on.
Be aware: a search on the whole screen costs you 0.5 seconds in average,
searching something in a region slightly larger than the object itself costs
less than 0.1 seconds (used to verify, wether the object exists there or is
still there) and a click on a region costs 0 seconds (a known match is a
region).
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.
_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help : https://help.launchpad.net/ListHelp