Jump to content

Error: Recursion level has been exceeded.


Recommended Posts

Can anyone tell me what's causing the recursion error / how to fix it?

Func startFishing()
    GUIDelete()
    If WinExists('World of Warcraft') Then
        WinActivate('World of Warcraft')
                
                $bobbercolor = iniRead($pagle_conf_file, 'settings', 'bobber', '')
                
                Send('1')
                Global $timerstart = TimerInit();
                
                tt('Casting Fishing Rod!')
        $pos = MouseGetPos()
                sleep(3000)
                
                tt('Looking for bobber!')
                $pos = PixelSearch($areal, $areat, $arear, $areab, $bobbercolor, $pagle_tolerance, 3)
                
                If Not @Error Then
                        tt('Bobber successfully located!')
                        MouseMove($pos[0], $pos[1], 0)
                        Global $bobx = $pos[0]
                        Global $boby = $pos[1]
                        waitForBite()
                Else
                    startFishing()
                EndIf
        Else
            MsgBox(0, 'Error', 'World of Warcraft MUST be running.')
        Exit
        EndIf
EndFunc

Func waitForBite()
    $splashl = $bobx - 30
    $splasht = $boby - 30
    $splashr = $bobx + 30
    $splashb = $boby + 30
    tt('Waiting for fish to bite!')
    While TimerDiff($timerstart) < 30000
        $pos = PixelSearch($splashl, $splasht, $splashr, $splashb, '0xffffff', $splsh_tolerance, 2)
        If Not @Error Then
                        tt('Line has been bitten!')
                        getLoot()
                        $timerstart = 30000
                EndIf
        WEnd
        startFishing()
EndFunc

Func getLoot()
    Send('{shiftdown}')
    MouseMove($bobx, $boby, 0)
    MouseClick('right')
    Send('{shiftup}')
    tt('Fish has been caught & looted succesfully!')
    sleep(1500)
    startFishing()
EndFunc

Put your link in my signature for just $1,000,000.00 USD! PM me for arrangements!

Link to comment
Share on other sites

Func StartFishing()
;.....
                Else
                    startFishing()
                EndIf
;....
EndFunc

Link to comment
Share on other sites

thanks, i didn't even noticed that! i fixed it by making a separate function for getting the bobber colour and did it that way, here's my fixed code:

Func startFishing()
    GUIDelete()
    If WinExists('World of Warcraft') Then
        WinActivate('World of Warcraft')
                
                $bobbercolor = iniRead($pagle_conf_file, 'settings', 'bobber', '')
                
                Send('1')
                Global $timerstart = TimerInit();
                
                tt('Casting Fishing Rod!')
        $pos = MouseGetPos()
                sleep(3000)
                
                getBobber()
        Else
            MsgBox(0, 'Error', 'World of Warcraft MUST be running.')
        Exit
        EndIf
EndFunc

Func getBobber()
    tt('Looking for bobber!')
        $pos = PixelSearch($areal, $areat, $arear, $areab, $bobbercolor, $pagle_tolerance, 3)

        If Not @Error Then
                tt('Bobber successfully located!')
            MouseMove($pos[0], $pos[1], 0)
                Global $bobx = $pos[0]
                Global $boby = $pos[1]
                waitForBite()
        Else
        startFishing()
    EndIf
EndFunc

Func waitForBite()
    $splashl = $bobx - 30
    $splasht = $boby - 30
    $splashr = $bobx + 30
    $splashb = $boby + 30
    tt('Waiting for fish to bite!')
    While TimerDiff($timerstart) < 30000
        $pos = PixelSearch($splashl, $splasht, $splashr, $splashb, '0xffffff', $splsh_tolerance, 2)
        If Not @Error Then
                        tt('Line has been bitten!')
                        getLoot()
                        $timerstart = 30000
                EndIf
        WEnd
        startFishing()
EndFunc

Func getLoot()
    Send('{shiftdown}')
    MouseMove($bobx, $boby, 0)
    MouseClick('right')
    Send('{shiftup}')
    tt('Fish has been caught & looted succesfully!')
    sleep(1500)
    startFishing()
EndFunc

Put your link in my signature for just $1,000,000.00 USD! PM me for arrangements!

Link to comment
Share on other sites

thanks, i didn't even noticed that! i fixed it by making a separate function for getting the bobber colour and did it that way, here's my fixed code:

Do you not still have problems with this?

You have just added a new function but that function still calls the first function and the functions don't return.

Link to comment
Share on other sites

gnollwood,

You find a solution but your code is bug risky as you're doing what I call 'Moebius bandage' coding

>>>startFishing()
startFishing() >>> getBobber()>>>waitForBite()>>>getLoot()>>> startFishing()
                              >>>startFishing()
oÝ÷ Ù8^-Á¬­¡«èÛaȬ¶n¶Ú¥ª^®Ø^jX(¯+a*.Á©í¶hN(*.­û§rب­¬nÞv¬ßÙírW®ÆZx­z¨»
.ØZ½ëayùhÂX¤y«­¢+Ø)Ý¡¥±]½É±]½ÉÉÑ%ÍIÕ¹¹¥¹ ¤)¥ÑÍÐ:ÀÄÑ¡¸½Ñ¥½¸:ÀÄ줼Ìäí¹Ð­¹½Üݽɱ½]½ÉÉÐÌÌì)¥ÑÍÐ:ÀÈÑ¡¸½Ñ¥½¸:ÀÈ(¸¸¸¸¸)ͱÀ ÄÀ¤)ݹ(

then after this you code placing the tests and doAction as functions

Edited by tresa
Link to comment
Share on other sites

This isn't tested at all but I'm thinking you need something like this.

;Return 1 to startfishing
;Return 2 to getBobber
;return 3 to waitforbite
;return 4 to getloot

$job = StartFishing()

While 1
    
    Switch $job
    Case 1
        $job = StartFishing()
    Case 2
        $job = GetBobber()
    Case 3
        $job = WaitForBite()
    Case 4
        $job = getLoot()
    EndSwitch
        
WEnd


Func startFishing()
    GUIDelete()
    If WinExists('World of Warcraft') Then
        WinActivate('World of Warcraft')
                
                $bobbercolor = iniRead($pagle_conf_file, 'settings', 'bobber', '')
                
                Send('1')
                Global $timerstart = TimerInit();
                
                tt('Casting Fishing Rod!')
        $pos = MouseGetPos()
                sleep(3000)
                
                Return 2
               ;getBobber()
        Else
            MsgBox(0, 'Error', 'World of Warcraft MUST be running.')
        Exit
        EndIf
EndFunc

Func getBobber()
    tt('Looking for bobber!')
        $pos = PixelSearch($areal, $areat, $arear, $areab, $bobbercolor, $pagle_tolerance, 3)

        If Not @Error Then
                tt('Bobber successfully located!')
            MouseMove($pos[0], $pos[1], 0)
                Global $bobx = $pos[0]
                Global $boby = $pos[1]
                
                Return 3
               ;waitForBite()
            Else
                
            Return 1
        ;startFishing()
    EndIf
EndFunc

Func waitForBite()
    $splashl = $bobx - 30
    $splasht = $boby - 30
    $splashr = $bobx + 30
    $splashb = $boby + 30
    tt('Waiting for fish to bite!')
    While TimerDiff($timerstart) < 30000
        $pos = PixelSearch($splashl, $splasht, $splashr, $splashb, '0xffffff', $splsh_tolerance, 2)
        If Not @Error Then
                        tt('Line has been bitten!')
                        Return 4
                       ;getLoot()
                        $timerstart = 30000
                EndIf
            WEnd
            
        Return 1
       ;startFishing()
EndFunc

Func getLoot()
    Send('{shiftdown}')
    MouseMove($bobx, $boby, 0)
    MouseClick('right')
    Send('{shiftup}')
    tt('Fish has been caught & looted succesfully!')
    sleep(1500)
    
    Return 1
   ;startFishing()
EndFunc
Link to comment
Share on other sites

ChrisL,

your code is better.

I would have auto documented it like this

$doStartFishing=1
$doGetBobber=2
$doWaitForBite=3
$doGetLoot=4

GUIDelete()

$followingJob = StartFishing()

While WinExists('World of Warcraft')
    WinActivate('World of Warcraft')
    Switch $followingJob 
    Case $doStartFishing
        $followingJob = StartFishing()
    Case $doGetBobber
        $followingJob = GetBobber()
    Case $doWaitForBite
        $followingJob = WaitForBite()
    Case $doGetLoot
        $followingJob = getLoot()
    EndSwitch
WEnd

Func startFishing()
      $bobbercolor = iniRead($pagle_conf_file, 'settings', 'bobber', '')
      Send('1')
      Global $timerstart = TimerInit();
      tt('Casting Fishing Rod!')
      $pos = MouseGetPos()
      sleep(3000)
      Return $doGetBobber
EndFunc

Func getBobber()
    tt('Looking for bobber!')
        $pos = PixelSearch($areal, $areat, $arear, $areab, $bobbercolor, $pagle_tolerance, 3)

        If Not @Error Then
                tt('Bobber successfully located!')
            MouseMove($pos[0], $pos[1], 0)
            Global $bobx = $pos[0]
            Global $boby = $pos[1]
            Return $doWaitForBite
        Else
            Return $doStartFishing
    EndIf
EndFunc

Func waitForBite()
    $splashl = $bobx - 30
    $splasht = $boby - 30
    $splashr = $bobx + 30
    $splashb = $boby + 30
    tt('Waiting for fish to bite!')
    While TimerDiff($timerstart) < 30000
        $pos = PixelSearch($splashl, $splasht, $splashr, $splashb, '0xffffff', $splsh_tolerance, 2)
        If Not @Error Then
                        tt('Line has been bitten!')
                        Return $dogetLoot
                        $timerstart = 30000
                EndIf
            WEnd
            
        Return $dostartFishing
EndFunc

Func getLoot()
    Send('{shiftdown}')
    MouseMove($bobx, $boby, 0)
    MouseClick('right')
    Send('{shiftup}')
    tt('Fish has been caught & looted succesfully!')
    sleep(1500)
    
    Return $dostartFishing
EndFunc
Link to comment
Share on other sites

Put some traces in your code and I predict you will soon be able to spot the problem :whistle: (hmm, I don't know what it is so I'm not pulling your leg) Traces is your friend. ConsoleWrite or search for +dbg +assert.

Link to comment
Share on other sites

I made modifications in the code (untested I have not world of wordcraft!)

- the timer is done in the general loop to improve clarity

- when actions are done in a row I change the functions to look for a success with an if test

- I put a sleep(10) in the timer loop so as Autoit do'nt overcharge the processor

Global $bobx, $boby
GUIDelete()

While WinExists('World of Warcraft')
    WinActivate('World of Warcraft')
    StartFishing()
    sleep(3000)
    if GetBobber()=false then continueLoop
    tt('Waiting for fish to bite!')
    $timerstart = TimerInit();
    $looted=false
    While TimerDiff($timerstart) < 30000 and $looted=false
         if IHaveBite=true then 
              getLoot()
              $looted=true
          endif
          sleep(10)
     Wend
WEnd

Func startFishing()
      $bobbercolor = iniRead($pagle_conf_file, 'settings', 'bobber', '')
      Send('1')
      tt('Casting Fishing Rod!')
EndFunc

Func getBobber()
    tt('Looking for bobber!')
        $pos = PixelSearch($areal, $areat, $arear, $areab, $bobbercolor, $pagle_tolerance, 3)

        If Not @Error Then
                tt('Bobber successfully located!')
            MouseMove($pos[0], $pos[1], 0)
            $bobx = $pos[0]
            $boby = $pos[1]
            Return true
        Else
            Return false
    EndIf
EndFunc

Func IHaveBite()
     $splashl = $bobx - 30
     $splasht = $boby - 30
     $splashr = $bobx + 30
     $splashb = $boby + 30
     $pos = PixelSearch($splashl, $splasht, $splashr, $splashb, '0xffffff', $splsh_tolerance, 2)
     If Not @Error Then
            tt('Line has been bitten!')
            return true
      EndIf
      Return false
EndFunc

Func getLoot()
    Send('{shiftdown}')
    MouseMove($bobx, $boby, 0)
    MouseClick('right')
    Send('{shiftup}')
    tt('Fish has been caught & looted succesfully!')
    sleep(1500)
    EndFunc
Edited by tresa
Link to comment
Share on other sites

I tried your way, and when I Return 2 to go to the next action, nothing happens (

It must be something your doing but only having a small part of the code it's not very easy to see what.

The basics of what I wrote earlier works, in the simple version of the code below works fine if you run it in scite you can see it returning and calling the next function, I've put a bit of randomness in to it too so that different functions are called.

;Return 1 to startfishing
;Return 2 to getBobber
;return 3 to waitforbite
;return 4 to getloot

$job = StartFishing()

While 1
    
    Switch $job
    Case 1
        $job = StartFishing()
    Case 2
        $job = GetBobber()
    Case 3
        $job = WaitForBite()
    Case 4
        $job = getLoot()
    EndSwitch
        
        Sleep (Random (1000, 2000))
WEnd


Func startFishing()
    ConsoleWrite ("Start Fishing" & @crlf)
                
                Return 2
EndFunc

Func getBobber()
ConsoleWrite ("getBlobber" & @crlf)   
$sec = StringRight (@Sec, 1)
         If $sec = 1 or $sec = 3   or $sec = 5 then 
             Return 3
             Else
             Return 1   
         EndIf
         
EndFunc

Func waitForBite()
ConsoleWrite ("WaitforBite" & @crlf)
$sec = StringRight (@Sec, 1)
         If $sec = 1 or $sec = 3   or $sec = 5 then 
             Return 4
             Else
             Return 1
         EndIf
     
EndFunc

Func getLoot()
Consolewrite ("Getloop" & @crlf)
    Return 1
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

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