Jump to content

while and if problems(i think)


Airgiod
 Share

Recommended Posts

I was wondering if anyone with a bit more know-how can figure out what i did wrong?

The issue so far is my error checking section of attack and the assumption (both pixelsearch) part are not firing but it is working its way to the end because it fires the go() function at the end of it. Maybe i have them formated wrong or something but I'm not seeing it.

Func go()
    WinActivate($win_title, "")
    Sleep(1000)
    clearflag()
    attack()
EndFunc

Func attack()
    ;click attack
    MouseClick("left", 60, 145)
    Sleep(1000) 
    ;confirm attack
    MouseClick("left", 175, 285)
    ;error checking on attack
    $t = 0
    While $t <= 5
        PixelSearch(66, 711, 68, 713, 0xFF0000) 
        If @error Then 
            SetError(0)
            $t = $t+1
        Else
            clearflag()
        EndIf
    WEnd
    ;assume no error on attack and wait for successful attack confirmation
    PixelSearch(66, 711, 68, 713, 0xFF0000)
    If @error Then
        SetError(0)
    Else
        deposit()
    EndIf
    Sleep(135000)
    go()
    EndFunc
Link to comment
Share on other sites

Hi.

Perhaps you want to give more details upon what you are looking for exactly, and within what timeframes these pixel changes you are looking for happen?

Regards, Rudi.

this section here is only supposed to look for the pixel color for a few seconds.

;error checking on attack
    $t = 0
    While $t <= 5
        PixelSearch(66, 711, 68, 713, 0xFF0000) 
        If @error Then 
            SetError(0)
            $t = $t+1
        Else
            clearflag()
        EndIf
    WEnd

this section is supposed to watch for the pixel color to confirm the attack was successfull and run the deposit() function and then waiting a time before starting the whole process over.

currently it responds to the first pixelserch but not to the second one and seems to hang there indefinatly

Link to comment
Share on other sites

Hi.

Run your script from SciTe editor and watch out for the console writes (bottom of SciTE Editor):

;error checking on attack
$t = 0
While $t <= 5
    PixelSearch(66, 711, 68, 713, 0xFF0000)
    If @error Then
        SetError(0)
        $t = $t + 1
        ConsoleWrite("Check-Attack-@Error, $t=" & $t & @LF)
    Else
        clearflag()
        ConsoleWrite("Check-Attack-ClearFlag(), $t=" & $t & @LF)
    EndIf
WEnd

... and similar for the other function as well.

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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