← Back to team overview

sikuli-driver team mailing list archive

[Question #321908]: help with else

 

New question #321908 on Sikuli:
https://answers.launchpad.net/sikuli/+question/321908

Hello.  I am new to Sikuli and spent the last couple weeks reading questions, watching videos and trying out many commands.  I now have a script (bot) I made for a flash game that I am happy with (I'm sure it looks really crude to an experienced coder).  What I haven't been able to figure out is the "else" part.  This will do everything I want it to except I'd like to set it to click an image and, if that one isn't available, go to a different one.  This is what I have made so far:


setFindFailedResponse(SKIP)

while True:    
    click(Pattern("1470112829847.png").similar(0.90).targetOffset(-207,3))
    click(Pattern("1470112829847.png").similar(0.90).targetOffset(-136,39))
    click(Pattern("1470112829847.png").similar(0.90).targetOffset(-74,81))
    click(Pattern("1470112829847.png").similar(0.90).targetOffset(-10,123))
    click(Pattern("1470112829847.png").similar(0.90).targetOffset(68,150))
    click(Pattern("1470099385638.png").similar(0.50), 1)
    click(Pattern("1470099385638.png").similar(0.50), 1)
    click(Pattern("1470099385638.png").similar(0.50), 1)
    click(Pattern("1470099385638.png").similar(0.50), 1)
    click(Pattern("1470141710780.png").targetOffset(-75,82))
    if exists("1470141893102.png"):
            click("1470141893102.png")
            click(Pattern("1470193668517.png").similar(0.80).targetOffset(-1,37))
            click(Pattern("1470142033137.png").similar(0.90))
    click(Pattern("1470141710780.png").targetOffset(-79,185))
    if exists("1470141893102.png"):
            click("1470141893102.png")
            click(Pattern("1470193668517.png").similar(0.80).targetOffset(-1,37))
            click(Pattern("1470142033137.png").similar(0.90))
    click(Pattern("1470141710780.png").targetOffset(-77,280))
    if exists("1470141893102.png"):
            click("1470141893102.png")
            click(Pattern("1470193668517.png").similar(0.80).targetOffset(-1,37))
            click(Pattern("1470142033137.png").similar(0.90))
    if exists(Pattern("1470113950787.png").similar(0.90).targetOffset(1,87), 0):
        doubleClick(Pattern("1470113950787.png").similar(0.90).targetOffset(1,87), 0)
        click(Pattern("1470114166301.png").similar(0.90), 0)
        click(Pattern("1470114252503.png").similar(0.90), 0)
    if exists(Pattern("1470114320553.png").similar(0.90).targetOffset(4,81), 0):
        doubleClick(Pattern("1470114320553.png").similar(0.90).targetOffset(4,81), 0)
        click(Pattern("1470114166301.png").similar(0.90), 0)
        click(Pattern("1470114418489.png").similar(0.90), 0)

The step I'd like to edit and so far haven't been able to work I'm trying to do like this;

click(Pattern("1470141710780.png").targetOffset(-77,280))
    if exists("1470141893102.png"):
            click("1470141893102.png")
            click(Pattern("1470193668517.png").similar(0.80).targetOffset(-1,37))
            click(Pattern("1470142033137.png").similar(0.90))

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.