Jump to content

Why it doesn't work ?


Recommended Posts

Hi guys, sorry if I ask a dumb question but i'm pretty new to autoIt ...

So, what i'm doing is a bot for a game you probably know, world of warcraft. What i want with my func is that see if the monster is alive (that's work) and then, when he is dead the attack loop stop(problem). I wish i well explain my problem. There is my script.

Func _Deadchecker()
    Local $Monsterdead
    
    PixelSearch( 195, 30, 200, 35, 0x00A800, 50 )
    If Not @error = 1 Then
     $Monsterdead=0;vie
    EndIf
    If Not $Monsterdead=0 Then
     $Monsterdead=1
    EndIf
 Return $Monsterdead
EndFunc   ;==>_Deadchecker

; ----------------------------------------------------------------------------
Func _Attack()
    Sleep(250)
    Send("1")
    Sleep(250)
    Send("2")
    Sleep(2300)
    If _Deadchecker() = 0 Then
        Do
        Sleep(250)
        Send("3")
        Sleep(6500)
    Until _Deadchecker() = Not 0
    EndIf
EndFunc   ;==> _Attack
; ----------------------------------------------------------------------------
Edited by newb_powa'
Link to comment
Share on other sites

  • Moderators

Func _Deadchecker()
    PixelSearch(195, 30, 200, 35, 0x00A800, 50)
    If Not @error Then Return 0
    Return 1
EndFunc   ;==>_Deadchecker

; ----------------------------------------------------------------------------
Func _Attack()
    Sleep(250)
    Send("1")
    Sleep(250)
    Send("2")
    Sleep(2300)
    If Not _Deadchecker() Then
        Do
            Sleep(250)
            Send("3")
            Sleep(6500)
        Until _Deadchecker()
    EndIf
EndFunc   ;==> _Attack

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

[autoit]Func _Deadchecker()

PixelSearch(195, 30, 200, 35, 0x00A800, 50)

If Not @error Then Return 0

Return 1

EndFunc ;==>_Deadchecker

I've been struggling with conceptualizing the actual usage of the "return" function, even after going through the manual, and I figure this is a simple enough example to learn from.

In this situation, "Return 1" is after the "If Not @error Then Return 0" - So how can return ever be viewed as zero? Is return like a variable, that should only have 1 value at any given time? Furthermore, when "_Deadchecker" is referenced later on in the script, what value does it have? Is it the last value 'returned'?

/hijack /sorry

Edited by Choch
Link to comment
Share on other sites

  • Moderators

I've been struggling with conceptualizing the actual usage of the "return" function, even after going through the manual, and I figure this is a simple enough example to learn from.

In this situation, "Return 1" is after the "If Not @error Then Return 0" - So how can return ever be viewed as zero? Is return like a variable, that should only have 1 value at any given time? Furthermore, when "_Deadchecker" is referenced later on in the script, what value does it have? Is it the last value 'returned'?

/hijack /sorry

Return 0 is only returned if the If/Then (Conditional) statement is "True" in this situation. Return 1 returns if it is "False" because the conditional statement never made it past the "Then". Now in actuallity, it should be Return 1 if True and Return 0 if False, but I was following his original Code style. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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