← Back to team overview

sikuli-driver team mailing list archive

[Question #171835]: I need some Variable Help :D

 

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

Below is some code im using at the moment in a game since it seemed a good way to get used to using this code.
The game is Galaxy Online 2 facebook app.
I wanted to make a quick bot to go through a friends list and check for a image. If the image is found do some function with it.
Then find the next page and look again for this image. Continue until there are no more pages of friends to check for.

Im really just having a issue with with the variables. I set up 2 variables. repair and nextpage.
I want to load the friends page - check if there is another page after this friends page and check if any friends need repair.
I used a million popups to sift through the code to see what was happening where.
I found that inside the functions the variables were being set. But after i leave the function the variables returned to the ?global? setting of False.. 

I wonder if im just using wrong syntax. Not tooo much info on the variable translation side is documented. So if i can get a second opinion on how to code this so it makes it through properly. This would be most awesome.

popup("setting vars")
repair = "False"
nextpage = "False"

def findfriendresourcepage():
    click(Pattern("1316552206794.png").targetOffset(47,-5))
    click(Pattern("rA.png").targetOffset(-1,-46))
def clickrepair():
     click(Pattern("1316553812674.png").similar(0.80))
     click("1316553825021.png")
def checkforrepair(repair):
    popup("inside checkforrepair function") 
    if exists("1316553886107.png"):
        repair = "True"
        popup("found a repair btn",repair)
        popup("exit checkforrepair")
    else:
        repair = "False"
        popup("Didnt find a repair btn",repair)
        popup("exit checkforrepair")
def findnextpage(nextpage):
    popup("entering inside findnextpage function") 
    if exists("1316554103938.png"):
        nextpage = "True"
        popup("if exe,nextpage =true",nextpage) 
        popup("exit findnextpage")
    else:
        nextpage = "False"
        popup("else exe,nextpage =false",nextpage)
        popup("exit findnextpage")
def clicknextpage():
    click(Pattern("1316555344764.png").targetOffset(-29,2))
        
######Main Program########
############popup("find the resource page")
findfriendresourcepage()                                                               ######### works fine as is
############popup("display the repair and nextpage vars")
############popup(repair,nextpage)                                          ######### displays False False as it should
############popup("wait 2 seconds")
wait(2)
############popup("call the find next page function)")
findnextpage(nextpage)
############popup("star the while loop")
popup(nextpage, "nextpage var =") ##### this is where nextpage should return True but it returns False(note this are strings 
                                                                 ##### im using and not boolean expressions
while nextpage == "True":
    ##########popup("start of while loop is here") 
    checkforrepair(repair)
    ##########popup("check if there is repair to do")
                    
    if repair == "True":
        clickrepair
    else:
        clicknextpage()
        findnextpage(nextpage)
        

    
    

    

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