Jump to content

Need help (pixel search loop)


EasyCo
 Share

Recommended Posts

Hi!

I've been working on a small project for a game (Diablo II). Need some help with a problem I'm having.

My script loops noon stop.

I would like it to stop at "If Not @error"

A question:

Is there a better way then using "If @error" and "If Not @error"

CODE
Func joingame()

;Channel Join game

ToolTip("Attempting To Join a Game.", 0, 0)

Sleep(5000)

MouseClick("left",711,454,1,2)

Sleep(800)

MouseClick("left",481,226,1,2)

Sleep(900)

$coord = PixelSearch(724, 204, 724, 204, 12624000) ;join game check

If @error Then

joingame2() ; Trying again

EndIf

If Not @error Then

Sleep(100)

MouseClick("left",675,412,1,2) ; join game

EndIf

EndFunc

Func joingame2()

;Channel Join game

ToolTip("Failed To Find Game. Trying again..", 0, 0)

Sleep(4000)

Send("{ESC}")

Sleep(3000)

MouseClick("left",711,454,1,2)

Sleep(800)

MouseClick("left",481,226,1,2)

Sleep(600)

$coord = PixelSearch(724, 204, 724, 204, 12624000) ;join game check

Sleep(200)

If @error Then

joingame3() ;trying again

EndIf

If Not @error Then

Sleep(100)

MouseClick("left",675,412,1,2) ;join game

EndIf

EndFunc

Func joingame3()

;Channel Join game

ToolTip("Failed To Find Game. Trying again...", 0, 0)

Sleep(4000)

Send("{ESC}")

;Send("New Game Now.")

;Sleep(100)

;Send("{ENTER}")

Sleep(3000)

MouseClick("left",711,454,1,2)

Sleep(800)

MouseClick("left",481,226,1,2)

Sleep(600)

$coord = PixelSearch(724, 204, 724, 204, 12624000) ;join game check

Sleep(200)

If @error Then

joingame2()

EndIf

If Not @error Then

Sleep(100)

MouseClick("left",675,412,1,2) ;join game

EndIf

EndFunc

Thanks for any help :D

Edited by EasyCo
Link to comment
Share on other sites

Return Value

Success: Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)

Failure: Sets @error to 1 if color is not found.

I personally don't see what is wrong with using at @error. On Failure $coord is set to 1 as well I believe so if you want. You could do an If IsArray($coord) blah, else do something. I would recommend using an else statement and not having a double if.

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