Jump to content

Function "Return" / PixelSearch


Recommended Posts

Hello guys, I explain my little problem

I have a funcion, when an IF statement is true, it writes in console something and then "return" to another script, when IF is false, it goes on in the same script.

Sometimes, I can't understand why, even if the "return" is applied, before going to the other script,  the next instruction (a ConsoleWrite) of the same script is written in the console.

Could it be a bug?

Sometimes, in an unpredictable way, even PixelSearch doesn't work well.

Any advise?

Thanks in advance

 

Link to comment
Share on other sites

  • 2 weeks later...
Local $win = False
    If IsArray($coord1) Then
        ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & " - Ho vinto! Al primo controllo" & @LF)
        $win = True
        _Importo($puntata[0])
        Return
    Else
        $coord = PixelSearch(815, 500, 850, 505, '0xBC4B3B')
        If IsArray($coord) Then
            ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & " - Ho perso!  Al primo controllo " & @LF)
            Switch $tic
                Case 1
                    _Tic2()
                Case 2
                    _Tic3()
                Case 3
                    _Tic4()
                Case 4
                    _Tic5()
                Case 5
                    _Tic1($func)
            EndSwitch

        Else
            ConsoleWrite ("Sono DALTONICO! " & @LF)
            Sleep(200)
        EndIf

    EndIf





    Local $coord2 = PixelSearch(815, 520, 850, 525, '0x35AA47')

    If IsArray($coord2) Then
        ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & " - Ho vinto! Al secondo controllo" & @LF)
        $win = True
        _Importo($puntata[0])
        Return
    Else
        $coord2 = PixelSearch(815, 500, 850, 525, '0xBC4B3B')
        If IsArray($coord2) Then
            ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & " - Ho perso!  Al secondo controllo " & @LF)
            Switch $tic
                Case 1
                    _Tic2()
                Case 2
                    _Tic3()
                Case 3
                    _Tic4()
                Case 4
                    _Tic5()
                Case 5
                    _Tic1($func)
            EndSwitch

        Else
            If $win = False Then ConsoleWrite ("Sono DALTONICO VERAMENTE! " & @LF)
            Sleep(200)
            Return
        EndIf
    EndIf

 

 

That's the code.

Sometimes I found written some statement after call the first "Return", as the code goes on even if should end the function.

Even pixelsearch goes wrong sometimes.

Any advise of how can I code more strict controls?

Thanks in advance

Edited by Melba23
Added code tags and merged posts
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...