Jump to content

Recursion Error


Recommended Posts

im new to autoit coding and having problem with my coding, it works fine just that i need it to run indefinitely without giving me a recursion error. If possible i hope you could help me solve my problem.

HotKeySet("{F1}", "Start")
HotKeySet("{F2}", "BoxCheck")
HotKeySet("{ESC}", "End")
Local $Repetition = 1
Local $AvoidError = 0

While 1
    Sleep(100)
WEnd

Func End()
    Exit 0
EndFunc   ;==>End

Func BoxCheck()
    While 1
PixelSearch (12,9,12,9, 0x6F2A00)
If @Error Then
    Call ("Check")
    ExitLoop
ContinueLoop
EndIf
PixelSearch (17,9,17,9, 0xC84C00)
If @Error Then
    Call ("Check")
    ExitLoop
ContinueLoop
EndIf
PixelSearch (11,15,11,15, 0xB44400)
If @Error Then
    Call ("Check")
    ExitLoop
ContinueLoop
EndIf
PixelSearch (12,18,12,18, 0xA48A30)
If @Error Then
    Call ("Check")
    ExitLoop
ContinueLoop
EndIf
PixelSearch (18,17,18,17, 0x9C8858)
If @Error Then
    Call ("Check")
    ExitLoop
ContinueLoop
EndIf
MsgBox (0,"NoErrorDetect", "No Error")
ExitLoop
WEND
EndFunc

Func Check()
    MsgBox (0,"","Error Detect")
Endfunc

Func Start()
    $leftspawn = PixelSearch(21, 173, 21, 173, 0xFFFF00)
    If IsArray($leftspawn) = True Then
        Send("{LEFT up}")
        $AvoidError = 0
        Sleep(1000)
        Send("{DOWN down}")
        Send("{SPACE}")
        Sleep(1000)
        Send("{DOWN up}")
        Call("BottomWalkRight")
    ElseIf IsArray($leftspawn) = False Then
        Send("{LEFT down}")
        Call("AvoidErrorStart")
    EndIf
EndFunc   ;==>Start

Func AvoidErrorStart()
    If $AvoidError > 200 Then
        Call("AvoidError")
    Else
        Sleep(100)
        $AvoidError = $AvoidError + 1
        TrayTip($AvoidError, "MAXIMUM VALUE: 200", 1, 1)
        Call("Start")
    EndIf
EndFunc   ;==>AvoidErrorStart

Func Startv2()
    $leftspawn = PixelSearch(21, 173, 21, 173, 0xFFFF00)
    If IsArray($leftspawn) = True Then
        Send("{LEFT up}")
        $AvoidError = 0
        Sleep(1000)
        Call("BottomWalkRight")
    ElseIf IsArray($leftspawn) = False Then
        Send("{LEFT down}")
        Call("AvoidErrorStartv2")
    EndIf
EndFunc   ;==>Startv2

Func AvoidErrorStartv2()
    If $AvoidError > 200 Then
        Call("AvoidError")
    Else
        Sleep(100)
        $AvoidError = $AvoidError + 1
        TrayTip($AvoidError, "MAXIMUM VALUE: 200", 1, 1)
        Call("Startv2")
    EndIf
EndFunc   ;==>AvoidErrorStartv2

Func BottomWalkRight()
    $rightspawnrope = PixelSearch(382, 212, 382, 212, 0x00FFFF)
    If IsArray($rightspawnrope) = True Then
        Send("{RIGHT down}")
        Call("AvoidErrorBottomWalkRight")
    ElseIf IsArray($rightspawnrope) = False Then
        Send("{RIGHT up}")
        $AvoidError = 0
        Sleep(1000)
        Send("{UP down}")
        Send("{SPACE}")
        Sleep(1000)
        Send("{UP up}")
        Call("SecondFloorWalkLeft")
    EndIf
EndFunc   ;==>BottomWalkRight

Func AvoidErrorBottomWalkRight()
    If $AvoidError > 200 Then
        Call("AvoidError")
    Else
        Sleep(100)
        $AvoidError = $AvoidError + 1
        TrayTip($AvoidError, "MAXIMUM VALUE: 200", 1, 1)
        Call("BottomWalkRight")
    EndIf
EndFunc   ;==>AvoidErrorBottomWalkRight

Func SecondFloorWalkLeft()
    $rightspawnsecondspawn = PixelSearch(314, 155, 314, 155, 0x00FFFF)
    If IsArray($rightspawnsecondspawn) = True Then
        Send("{LEFT down}")
        Call("AvoidErrorSecondFloorWalkLeft")
    ElseIf IsArray($rightspawnsecondspawn) = False Then
        Send("{LEFT up}")
        $AvoidError = 0
        Sleep(1000)
        Send("{UP down}")
        Send("{SPACE}")
        Sleep(1000)
        Send("{UP up}")
        Call("Repeat")
    EndIf
EndFunc   ;==>SecondFloorWalkLeft

Func AvoidErrorSecondFloorWalkLeft()
    If $AvoidError > 200 Then
        Call("AvoidError")
    Else
        Sleep(50)
        $AvoidError = $AvoidError + 1
        TrayTip($AvoidError, "MAXIMUM VALUE: 200", 1, 1)
        Call("SecondFloorWalkLeft")
    EndIf
EndFunc   ;==>AvoidErrorSecondFloorWalkLeft

Func Repeat()
    If $Repetition = 0 Then
        $Repetition = $Repetition + 1
        Call("Start")
    ElseIf $Repetition = 1 Then
        $Repetition = $Repetition - 1
        Call("Startv2")
    EndIf
EndFunc   ;==>Repeat

Func AvoidError()
    $AvoidError = 0
    Send("{UP up}")
    Send("{DOWN up}")
    Send("{LEFT up}")
    Send("{RIGHT up}")
    Sleep(100)
    Send("{LEFT down}")
    Sleep(15000)
    Send("{LEFT up}")
    Sleep(1000)
    Send("{DOWN down}")
    Send("{SPACE}")
    Sleep(400)
    Send("{SPACE}")
    Sleep(400)
    Send("{SPACE}")
    Sleep(400)
    Send("{SPACE}")
    Sleep(400)
    Send("{SPACE}")
    Sleep(400)
    Send("{DOWN up}")
    Call("BottomWalkRight")
EndFunc   ;==>AvoidError

this is my error:

E:\Dropbox\AutoIt Project\Unfinished Project\test.au3 (71) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.:
Call("AvoidErrorBottomWalkRight")

->09:01:49 AutoIT3.exe ended.rc:1
>Exit code: 1    Time: 315.946
Link to comment
Share on other sites

  • Developers

Which part of our forum rules that you were pointed to in the previous closed thread did you not understand?

Last warning.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...