← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #252512]: How to use regions properly

 

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

Smizzy posted a new comment:
I also have this kind of a situation and was wondering how to optimize
it

c1="shopkeeper-1.png"     # worker icon
c1i1=0                                      # most desired item to craft 
c1i2=0                                      # second highest priority
c1i3=0                                      #third
c1i4=0                                      #fourth
c2="Tinkerer-1.png"
c2i1="pistol-1.png"
c2i2=0
c2i3=0
c2i4=0
c3="jeweler-2.png"
c3i1="scholarsmark-1.png"
c3i2="ringofwizardry-1.png"
c3i3=0
c3i4=0
c4="Enchanter-2.png"
c4i1="antivenom-2.png"
c4i2=0
c4i3=0
c4i4=0
 
#Those images are run through this function one by one in a loop, its not very fast because the loop checks for each icon individually 

def crafter(worker, item1, item2, item3, item4):
    if item1==0:
        return(0)
    if item1 != 0:
        if icon.exists(worker):
            x=1
            try:
                icon.click(worker)
                if queue.exists(Pattern("emptyqueue.png").similar(0.90)):
                    if clicker(item1)==0:
                        if item2 != 0:
                            if clicker(item2)==0:
                                if item3 != 0:
                                    if clicker(item3)==0:
                                        if item4 != 0:
                                            if clicker(item4)==0:
                                                quit.click("closeitemselect.png")
                                                return(1)
                                        else:
                                            quit.click("closeitemselect.png")
                                            return(1)
                                else:
                                    quit.click("closeitemselect.png")
                                    return(1)
                        else:
                            quit.click("closeitemselect.png")
                            return(1)
                else:
                    if game.exists("another close button.png"):
                        game.click("another close button.png")
                    quit.click("closeitemselect.png")
                    return(1)
            except:
                x=3
                return(0)
        else:
            return(0)


How could I use image lists to scan for any of the 4 worker icons and then send the correct sets of images to the function?

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