Jump to content

Looping my script


MasonMill
 Share

Recommended Posts

Hey guys (and gals),

Right now I have a second script double clicking on this script every 25 seconds to start it(yes very "ghetto fabulous") but I don't know how to do it other wise. If I stick a "While 1" around the whole thing it gets confused with the Wends. When I start the script the mouse clicks bring up the game window, I didn't use winwaitactive because I'm lazy and didn't want to click on the window for the winwaitactive. The script attacks my other player and in doing that the guard towers kill me. On another computer the guy revives my character. When the sign pops up asking if I want to resurrect, the getpixelcolor recognizes it and clicks the button saying yes. Then, I want the process to start all over again.

Any suggestions? Thanks! Here is the script.

MouseClick("left", 1060, 350, 1, 1)

sleep(500)

MouseClick("left", 1060, 350, 1, 1)

sleep(1000)

send("{ESCAPE}")

sleep(1000)

send("8")

sleep(1000)

send("0")

sleep(1000)

Send("r")

sleep(1500)

Send("q")

sleep(2000)

send("{ESCAPE}")

while 1

revive()

sleep(1000)

WEnd

Func revive()

$dead = PixelGetColor(603, 450)

If $dead = 0xEBFFAA Then

MouseClick("left", 603, 450, 1, 1)

sleep(500)

Exit

EndIf

EndFunc

Link to comment
Share on other sites

I find it weird that you can't use several whiles, but if that really is the problem, use a Do...Until

EDIT: Also, remember to not loop the function, place that outside the 25sec while

Edited by colafrysen
[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

Well like here is my problem if I put the "While 1" around the first part the "While 1" looping my functions dont work. Like this...

While 1

MouseClick("left", 1060, 350, 1, 1)

sleep(500)

MouseClick("left", 1060, 350, 1, 1)

sleep(1000)

send("{ESCAPE}")

sleep(1000)

send("8")

sleep(1000)

send("0")

sleep(1000)

Send("r")

sleep(1500)

Send("q")

sleep(2000)

send("{ESCAPE}")

sleep(25000)

WEnd

while 1

revive()

dead()

sleep(1000)

WEnd

Func revive()

$dead = PixelGetColor(603, 450)

If $dead = 0xEBFFAA Then

MouseClick("left", 603, 450, 1, 1)

sleep(500)

Exit

EndIf

EndFunc

Func dead()

$respawn = PixelGetColor(603, 450)

If $respawn = 0xFB0202 Then

Exit

EndIf

EndFunc

And if I put the "While 1" around the whole thing (I know its wrong), like this...

It has the error "While statement has no matching "Wend" statement. Same with Do, until

While 1

MouseClick("left", 1060, 350, 1, 1)

sleep(500)

MouseClick("left", 1060, 350, 1, 1)

sleep(1000)

send("{ESCAPE}")

sleep(1000)

send("8")

sleep(1000)

send("0")

sleep(1000)

Send("r")

sleep(1500)

Send("q")

sleep(2000)

send("{ESCAPE}")

sleep(25000)

while 1

revive()

dead()

sleep(1000)

WEnd

Func revive()

$dead = PixelGetColor(603, 450)

If $dead = 0xEBFFAA Then

MouseClick("left", 603, 450, 1, 1)

sleep(500)

Exit

EndIf

EndFunc

Func dead()

$respawn = PixelGetColor(603, 450)

If $respawn = 0xFB0202 Then

Exit

EndIf

EndFunc

WEnd

Link to comment
Share on other sites

Ok, first code-tags, please.

You are still doing it wrong

you do need to have TWO Wends to close TWO Whiles

While 1
    MouseClick("left", 1060, 350, 1, 1)
    Sleep(500)
    MouseClick("left", 1060, 350, 1, 1)
    Sleep(1000)
    Send("{ESCAPE}")
    Sleep(1000)
    Send("8")
    Sleep(1000)
    Send("0")
    Sleep(1000)
    Send("r")
    Sleep(1500)
    Send("q")
    Sleep(2000)
    Send("{ESCAPE}")
    Sleep(25000)

    While 1
        revive()
        dead()
        Sleep(1000)
    WEnd
WEnd

Func revive()
    $dead = PixelGetColor(603, 450)
    If $dead = 0xEBFFAA Then
        MouseClick("left", 603, 450, 1, 1)
        Sleep(500)
        Exit
    EndIf
EndFunc   ;==>revive

Func dead()
    $respawn = PixelGetColor(603, 450)
    If $respawn = 0xFB0202 Then
        Exit
    EndIf
EndFunc   ;==>dead
[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

Hey guys (and gals),

Right now I have a second script double clicking on this script every 25 seconds to start it(yes very "ghetto fabulous") but I don't know how to do it other wise. If I stick a "While 1" around the whole thing it gets confused with the Wends. When I start the script the mouse clicks bring up the game window, I didn't use winwaitactive because I'm lazy and didn't want to click on the window for the winwaitactive. The script attacks my other player and in doing that the guard towers kill me. On another computer the guy revives my character. When the sign pops up asking if I want to resurrect, the getpixelcolor recognizes it and clicks the button saying yes. Then, I want the process to start all over again.

Any suggestions? Thanks! Here is the script.

MouseClick("left", 1060, 350, 1, 1)

sleep(500)

MouseClick("left", 1060, 350, 1, 1)

sleep(1000)

send("{ESCAPE}")

sleep(1000)

send("8")

sleep(1000)

send("0")

sleep(1000)

Send("r")

sleep(1500)

Send("q")

sleep(2000)

send("{ESCAPE}")

while 1

revive()

sleep(1000)

WEnd

Func revive()

$dead = PixelGetColor(603, 450)

If $dead = 0xEBFFAA Then

MouseClick("left", 603, 450, 1, 1)

sleep(500)

Exit

EndIf

EndFunc

In addition to Do Until read up on For Next which is also a conditional looping statement. I notice you have used a While Wend statement. You can also have a loop within a loop for example

If $x = "Short Sleep" then $sSleep = 1000
If $x = "Medium Sleep" then $sSleep = 2000
If $x = "Long Sleep" then $sSleep = 3000

_Test(1, 2, $sSleep)

Func _Test($var1, $var2, $var3)
    ;//The value of the variables passed to the Func is $var1 = 1 $var2 = 2 and $var3 = 3000
    While 1
        ;//If a condition is met then
        If $var1 = $var2 Then
            While 1
                ;Do something
                ;If This equals that Exitloop ;// Takes you out of this loop
                ;If this equals that Exitloop (2) ;//Takes you out of both loops
            WEnd
        EndIf
        Sleep($var3)
        ;//Conditional Exit Otherwise the Looping Continues
        If $var1 = $aCondition Then ExitLoop
    WEnd
EndFunc   ;==>_Test

Another thing you might like to keep in mind is that you can pass variables to the function embedded within calling statement which I have included in the above. You can use this to have your func do more than one task based on the values you send to the function 1 could be to switch a process on 0 to switch it off or the variable could be simply a value which the function requires to perform a particular process. I notice that you have a sleep statment. Well you could have your sleep statement as the variable and depending upon what you want you could increase or decrease the time that the process is required to sleep.

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