← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #223397]: sikuli help for a computer illiterate father

 

Question #223397 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/223397

    Status: Open => Answered

RaiMan proposed the following answer:
not so bad for being computer illiterate (father does not matter here,
might only increase pressure and despair ;-)

based on what I understand, the following snippet should loop until the
shop reveals (I know computing, but not the game ;-):

while True:
    if exist(<dice img>,0): click(<dice img>)
    wait(1) # guess we should wait a little for dicing to complete
    if exist(<random building 1 img>,0): click(<close button>)
    elif exist(<random building 2 img>,0): click(<close button>)
    elif exist(<random building 3 img>,0): click(<close button>)
    elif exist(<random building 4 img>,0): click(<close button>)
    elif exist(<random building 5 img>,0): click(<close button>)
    elif exist(<random building 6 img>,0): click(<close button>)
    elif exist(<random building 7 img>,0): click(<close button>)
    # i want the script to just wait or stop if it happens to find it 
    if not exist(<shop img>,0): 
        wait(3) # adjust time until loop again
    else:
        break # leave the loop

--- a little Python basics

if ... elif ...
since I guess, that only one of the random buildings reveals after dicing, using elif in this case will stop the search for the irrelevant buildings if the first is found

mind the spaces ...
at the beginning of the lines. leading spaces in Python tell, that the statement belongs to a block of statements to be processed together (your loop content in this case and the if ... else at the end). The count of the leading spaces must be the same in a block (Sikuli supports this so called indenting/dedenting with TAB (indent 1 level) and SHIFT-TAB (dedent 1 level) and inserts 4 spaces per level)
a next statement outside/after the loop must have no spaces in front (level 0)

--- to get a little bit less illiterate ...
it might be a good idea to scan the faqs (https://answers.launchpad.net/sikuli/+faqs) for some basic tips especially for newcomers.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.