Jump to content

Overstack?


Recommended Posts

I am running Functions for a long period of time... After awhile I will get a Overstack Flow Error because of Sleep... How could I fix this?

WinActivate ("Mythia - Mozilla Firefox", "")
Sleep(2000)

Call ("FindAttack")

Func FindAttack()
    Send("^f")
        Sleep(500)
    Send("Attack")
        Sleep(500)
    Call("Color")
EndFunc

Func FindWait()
    Send("^f")
        Sleep(500)
    Send("Wait here a while.")
        Sleep(500)
    $Wait = PixelSearch(527, 257, 803, 562, 0x38D878)

    If @error Then
        Call("Tab7")
    Else
    MouseClick("left", $Wait[0], $Wait[1])
        Sleep(20000)
    Call ("Tab7")
    EndIf
EndFunc

Func Color()
$coord = PixelSearch(530, 484, 740, 557, 0x38D878)

    If @error Then
        Call ("FindWait")
    Else
        MouseClick("left", $coord[0], $coord[1])
            Sleep(20000)
        Call ("Tab7")
    EndIf

EndFunc

Func Tab7()
$Back = PixelSearch(344, 204, 733, 503, 0xD4D0C8)

    If @error Then
        Call ("FindAttack")
    Else
    MouseClick("left", $Back[0], $Back[1])
        Sleep(20000)
    Call("FindAttack")
    EndIf
EndFunc

Thanks

Link to comment
Share on other sites

Everytime you call a function, inside of another function, that goes to the next one without stopping, it overstacks the program.

This will do the same thing.

StartFlow()
Func StartFlow()
   KeepFlow()
EndFunc
Func KeepFlow()
   StartFlow()
EndFunc

It's a never ending function that overstacks and terminates. Just try to be a bit more clean with the code, and not link to each other.

Link to comment
Share on other sites

What you are doing does not require any function calls. You appear to want something close to this:

WinActivate('Mythia - Mozilla Firefox')
Sleep(2000)

While 1

; Find attack
    Send('^f')
    Sleep(500)
    Send('Attack')
    Sleep(500)

; Colour
    $Coord = PixelSearch(530, 484, 740, 557, 0x38D878)

    If Not @Error Then
        MouseClick('', $Coord[0], $Coord[1])
        Sleep(20000)
    Else
; Find wait
        Send('^f')
        Sleep(500)
        Send('Wait here a while.')
        Sleep(500)
        $Wait = PixelSearch(527, 257, 803, 562, 0x38D878)
        If Not @Error Then
            MouseClick('', $Wait[0], $Wait[1])
            Sleep(20000)
        EndIf
    EndIf

; Tab 7
    $Back = PixelSearch(344, 204, 733, 503, 0xD4D0C8)
    If Not @Error Then
        MouseClick('', $Back[0], $Back[1])
        Sleep(20000)
    EndIf

WEnd

While 1..WEnd gives you an infinite loop. As you are not continually entering functions without exiting them again, you will receive no stack overflow errors.

Edited by LxP
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...