Sign in to follow this  
Followers 0
FifteenFifty

Help with recursion error

3 posts in this topic

#1 ·  Posted (edited)

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template AutoIt script.
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here

$answer = MsgBox(4, "ls bot Beta", "ls bot. Run?")


; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(0, "ls bot beta", "OK.  Bye!")
    Exit
EndIf

HotKeySet ("{HOME}","_exit")

Sleep (5000)
_clicky ()

Func _clicky ()
    While 1
        Sleep (200)
        PixelSearch (374,254,376,256,6525654)
            If Not @error Then
                MouseClick ("left",473,274,1,3)
            Else
                ExitLoop
            EndIf
    WEnd 
        _checkitem ()
EndFunc

Func _checkitem ()
    MouseClick ("left",473,274,1,3)
    Sleep (500)
    MouseClick ("left",473,274,1,3)
    _item ()
    EndFunc
    






Func _item ()
    PixelSearch (344,353,373,367,11387879)
    If Not @error Then
        Mouseclick("left",402,362,1,3)
        Sleep (100)
        Mouseclick("left",412,362,1,3)
        Sleep (100)
        Mouseclick("left",417,362,1,3)
        Sleep (100)
        Mouseclick("left",427,362,1,3)
        Sleep (100)
        Mouseclick("left",437,362,1,3)
        Sleep (100)
        Mouseclick("left",447,362,1,3)
        Sleep (100)
        Mouseclick("left",457,362,1,3)
        Sleep (100)
        Mouseclick("left",467,362,1,3)
        Sleep (100)
        Mouseclick("left",477,362,1,3)
        Sleep (100)
        Mouseclick("left",487,362,1,3)
        Sleep (100)
        Mouseclick("left",497,362,1,3)
        Sleep (100)
        Mouseclick("left",507,362,1,3)
        Sleep (100)
        Mouseclick("left",517,362,1,3)
        Sleep (100)
        Mouseclick("left",527,362,1,3)
        Sleep (100)
        Mouseclick("left",537,362,1,3)
        Sleep (100)
        Mouseclick("left",547,362,1,3)
        Sleep (100)
        Mouseclick("left",557,362,1,3)
        Sleep (100)
        Mouseclick("left",567,362,1,3)
        Sleep (100)
        _lifecheck ()
        
    EndIf
    If @error Then
        _lifecheck ()
    EndIf
EndFunc


Func _lifecheck ()
    While 1
        pixelsearch (248,255,250,257,6525654)
            If @error Then
            Sleep (2000)
            Else
                ExitLoop
            EndIf
    WEnd
        Sleep (2000)
        Mouseclick ("left",368,304,1,3)
        Sleep (2000)
        _clicky ()
EndFunc
        
        
        

Func _exit ()
    Exit
EndFunc

how do i fix the recursion error with lifecheck?

Edited by FifteenFifty

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You start by calling _clicky() which again calls checkitem(), which then calls _item(),

which then calls _lifecheck(), which then calls _clicky(), which then calls _checkitem(),

which then calls _item(), which then calls _clicky(), which then calls _checkitem(),

which then calls _item(), which then calls _lifecheck() and so on and so on and so on.

You obviously didn't understood what we meant in the last topic of yours. You remember

that snake I mentioned ? Well, now you have several snakes that is biting each-others

tails in a neverending circle, which is gonna end up with a bunch of dead snakes and a

bloody mess. Dead snakes ain't good but your coding-style is even worse. Try something

like this instead :

While 1
    Sleep(10)
    
    If check1() Then
        something1()
    Else
        something2()
    EndIf
WEnd

Func check1()
    If PixelSearch() Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc
Edited by Helge

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Remove the call to _clicky() in the _lifecheck() function.

Func _lifecheck ()
    While 1
        pixelsearch (248,255,250,257,6525654)
            If @error Then
            Sleep (2000)
            Else
                ExitLoop
            EndIf
    WEnd
        Sleep (2000)
        Mouseclick ("left",368,304,1,3)
        Sleep (2000)
EndFunc
Edited by Don N

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0