Jump to content

Recursion error


Recommended Posts

im new to autoit coding and i just made a bot for a game, 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.

Heres my code:

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

While 1
    Sleep(100)
WEnd

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


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

Hello dspirit95,

Welcome to the AutoIt Forums!

Unfortunately, I cannot help you. Please read the 'Forum Rules' before posting. Especially Part #1 where discussion of game automation is forbidden.

Sorry... and hope to see you again later under a more legitimate reason :)

Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

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...