Sign in to follow this  
Followers 0
ecstatic

[Fixed]Functions Not Executing

12 posts in this topic

#1 ·  Posted (edited)

Hey guys, semi new to autoit coding a bot in it.

Heres my problemo.

Func Pindle()
    $Message = "OK, lets go kill pindle"
    Chat()
    Sleep(2000)
    Send($TeleportKey)
    Sleep(400)
    MouseMove(463, 88)
    MouseDown("right")
    MouseUp("right")
    Sleep(400)
    MouseMove(732, 156)
    MouseDown("right")
    MouseUp("right")
    Sleep(400)
    MouseMove(700, 186)
    MouseDown("right")
    MouseUp("right")
    Sleep(400)
    MouseMove(571, 173)
    MouseDown("right")
    MouseUp("right")
    Sleep(200)
    MouseMove(490, 250)
    MouseDown("right")
    MouseUp("right")
If $Class = "Light Sorc" Then
    Send($SorcMain)
    Sleep(100)
    Do
    $MonsterFind =  PixelSearch( 148, 34, 800, 291, $monsters )
        If Not @error Then
            MouseClick("right", $monsterfind[0], $Monsterfind[1])
        EndIf
    Until @error <> 0 
    $PindleKilled = $PindleKilled + 1
    EndGame()
EndIf


If $Class = "Hammerdin" Then
       MouseClick("Right", 709, 173)
       Sleep(100)
       Send($ConcentrationKey)
       Send("{ShiftDown}")
    Do
    $MonsterFind =  PixelSearch( 148, 34, 800, 291, $monsters )
        If Not @error Then
            MouseDown("Left")
            Sleep(2500)
            MouseUp("Left")
        EndIf
    Until @error <> 0 
    $PindleKilled = $PindleKilled + 1
    EndGame()
EndIf
EndFunc;==>Pindle

OK, so it teleports to the monster, then starts finding the monsters and kills them

My problem is, once it is done killing them and it is supposed to Function Endgame,

Instead, the script exits and my guy sits there a like a dunce and dies.

Heres some more etc code.

IDK if u cant have 3x functions or something.. Sorry for the semi-bad english.

Func EndGame()
Send("{Esc}")
Sleep(500)
Send("{Up}")
Sleep(500)
Send("{Enter}")
    Sleep(500)
    FileWriteLine($File, " We had a successful run" & @HOUR & ":" & @MIN  & " - " & @MDAY & "/" & @LF)
    $GamesCompleted = $GamesCompleted + 1
    Stats()
    CreateGame()
EndFunc;==>EndGame


Func CreateGame()
        $Message = "were creating a game now!"
    Chat()
    Stats()
;Credits go to Rijn for random string generation.

    MouseClick("left", 640, 485)
    Sleep($ClickDelay)

    $GameLength = Random(10, 15)
    $PassLength = Random(10, 15)

    For $x2 = 0 To $GameLength
        $Random = Random(97, 122)
        Send(Chr($Random))
    Next

    Sleep($KeyDelay)
    Send("{TAB}")
    Sleep($KeyDelay)

    For $x3 = 0 To $PassLength
        $Random = Random(97, 122)
        Send(Chr($Random))
    Next

    Sleep($KeyDelay)
    Send("{ENTER}")
    Sleep($KeyDelay)

    $GamesMade = $GamesMade + 1
    Stats()
    FileWriteLine($File, "Made Game: " & @HOUR & ":" & @MIN & "." & @MDAY & "/" & @MON & "/" & @YEAR & @LF)
    Sleep(3000)
    CheckIngameact1()
EndFunc;==>CreateGame

ESC UP ENTER just gets from the menu to exited.

CreateGame() isnt really an issue due to that it cannot get to EndGame()

So wuts the problem gurus!

Edited by ecstatic

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Your problem could be here:

Do
    $MonsterFind =  PixelSearch( 148, 34, 800, 291, $monsters )
        If Not @error Then
            MouseClick("right", $monsterfind[0], $Monsterfind[1])
        EndIf
    Until @error <> 0

You see, @error's value is set back to 0 when calling a function. MouseClick is the one resetting @error, since it's unlikely it fails. So I suggest you replace that part with:

$error=0
    Do
    $MonsterFind =  PixelSearch( 148, 34, 800, 291, $monsters )
    $error=@error
        If Not $error Then
            MouseClick("right", $monsterfind[0], $Monsterfind[1])
        EndIf
    Until $error <> 0

Try if that works.

Edited by Nahuel

Share this post


Link to post
Share on other sites

or

While 1
    $MonsterFind =  PixelSearch( 148, 34, 800, 291, $monsters )
      If @error Then exitloop
      MouseClick("right", $monsterfind[0], $Monsterfind[1])
      Wend

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Your problem could be here:

Do
    $MonsterFind =  PixelSearch( 148, 34, 800, 291, $monsters )
        If Not @error Then
            MouseClick("right", $monsterfind[0], $Monsterfind[1])
        EndIf
    Until @error <> 0

You see, @error's value is set back to 0 when calling a function. MouseClick is the one resetting @error, since it's unlikely it fails. So I suggest you replace that part with:

$error=0
    Do
    $MonsterFind =  PixelSearch( 148, 34, 800, 291, $monsters )
    $error=@error
        If Not $error Then
            MouseClick("right", $monsterfind[0], $Monsterfind[1])
        EndIf
    Until $error <> 0

Try if that works.

Sorry, it still exited early ^_^((((((

or

While 1
    $MonsterFind =  PixelSearch( 148, 34, 800, 291, $monsters )
      If @error Then exitloop
      MouseClick("right", $monsterfind[0], $Monsterfind[1])
      Wend
Grr that dindt work ethir Edited by ecstatic

Share this post


Link to post
Share on other sites

that was a replacement for his posted code. Is Autoit giving an error? Could i see the section of code where you are calling these functions? Is it completing the first function for sure?

Share this post


Link to post
Share on other sites

put in some console writes and see where the script is crashing.

Share this post


Link to post
Share on other sites

k

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

put in some console writes and see where the script is crashing.

It is failing here

Func EndGame()

FileWriteLine($File, " We are trying to end game" & @HOUR & ":" & @MIN & " - " & @MDAY & "/" & @LF)

Send("{Esc}")

Sleep(500)

Send("{Up}")

Sleep(500)

Send("{Enter}")

Sleep(500)

FileWriteLine($File, " We had a sucessful run" & @HOUR & ":" & @MIN & " - " & @MDAY & "/" & @LF)

$GamesCompleted = $GamesCompleted + 1

Stats()

CreateGame()

EndFunc ;==>EndGame

But that line of code is mandatory

Edited by ecstatic

Share this post


Link to post
Share on other sites

does it fail after the same line of code? Or are u saying it is failing after the file write?

Share this post


Link to post
Share on other sites

does it fail after the same line of code? Or are u saying it is failing after the file write?

Failing after the file write but before the 2nd one.

So inbetween the ESC UP ENTER

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Heres what i did

;Send("{Esc}")

;Sleep(500)

;Send("{Up}")

;Sleep(500)

Send("{Enter}")

That worked! But i need ESC UP ENTER, its manditory

Then i did

Send("{Esc}")

;Sleep(500)

;Send("{Up}")

;Sleep(500)

Send("{Enter}")

And it didnt work.

Is there an alternative to ESC that will still do Escape

Edit: Even if i take it out of the function it doesnt work.

Edited by ecstatic

Share this post


Link to post
Share on other sites

FIXED!

Figured out i had a hotkeyset to ESC

Share this post


Link to post
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
Sign in to follow this  
Followers 0