MasonMill Posted December 21, 2009 Share Posted December 21, 2009 Ok maybe its something bigger than whet I'm seeing in my do until loop. I'm posting the whole script that I'm using. Its for a little game that my wife and I play at home against each other. When it gets to the Do...Until loop it just hangs for some reason. Any suggestions?$FullStamina = PixelSearch(185, 287, 195, 295, 0x86671A, 20);stamina bar is fullWhile 1 Requip();re equips weapon after it breaks send("u") sleep(200) LowHealth();life bar gets low WepCheck();makes sure weapon is un shiethedWEndFunc LowHealth() $coord = Pixelsearch(1728, 43, 1738, 52, 0x741A1A, 1) ; If @error Then sleep(1000) send("o");shieth sleep(3000) send("b");toggle rest sleep(1000) send("u");trigger rest Do sleep(1000) Until $FullStamina = 1 send("{SPACE}");stand up sleep(4000) send("{F9}");sends a command to my other computer sleep(2000) send("o");unshieth sleep(1000) EndIf EndFuncFunc Requip() $coord = PixelSearch(1519, 773, 1537, 798, 0x89635F, 20) ; If @error Then; Sleep(1000) Send("g");my 0 slot on my hotbar where i have my polearm Sleep(3000) Send("o");unshieth Sleep(1000) EndIfEndFunc ;==>_WeaponCheckFunc WepCheck() $green = PixelSearch(15, 433, 39, 458, 0x137800, 20) If @error Then send("o") sleep(500) EndIfEndFunc Link to comment Share on other sites More sharing options...
ajag Posted December 21, 2009 Share Posted December 21, 2009 (edited) Do sleep(1000) Until $FullStamina = 1This will call sleep(1000) until $FullStamina is '1'. But where between Do and Until $FullStamina is changing? Right: nowhere! So when you go into the loop with $FullStamina is '1', it still will be '1' for the rest of the programs life. That is, why you never will leave the Loop (at your prog hangs). You have to set $FullStamina within your loop to see if it is '1' or not:Do sleep(1000) $FullStamina = PixelSearch(185, 287, 195, 295, 0x86671A, 20) Until $FullStamina = 1A-Jay Edited December 21, 2009 by ajag Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1) Link to comment Share on other sites More sharing options...
jebus495 Posted December 21, 2009 Share Posted December 21, 2009 (edited) Sooo... Do $FullStamina = PixelSearch(185, 287, 195, 295, 0xCCA028, 1) If IsArray($FullStamina) Then $FullStamina[2] = 1 Sleep(1000) Until $FullStamina[2] = 1 Didn't work? (http://www.autoitscript.com/forum/index.php?showtopic=107175) You can also write it like: While 1 Sleep(1000) $FullStamina = PixelSearch(185, 287, 195, 295, 0xCCA028, 1) If Not @error Then ExitLoop WEnd Edited December 21, 2009 by jebus495 Link to comment Share on other sites More sharing options...
MasonMill Posted December 21, 2009 Author Share Posted December 21, 2009 Awesome! thanks. Im going to try in now. Link to comment Share on other sites More sharing options...
MasonMill Posted December 21, 2009 Author Share Posted December 21, 2009 Im trying the first suggestion becasue as you said ive never seen it that way so im trying to learn something new here. It gives me an error for line 41 saying Until $FullStamina[2] = 1 Until $FullStamina^ ERROR Error Subscript used with non-Array variable While 1 Requip();re equips weapon after it breaks send("u") sleep(200) LowHealth();life bar gets low WepCheck();makes sure weapon is un shiethed WEnd Func LowHealth() $coord = Pixelsearch(1728, 43, 1738, 52, 0x741A1A, 1) ; If @error Then sleep(1000) send("o");shieth sleep(3000) send("b");toggle rest sleep(1000) send("u");trigger rest Do $FullStamina = PixelSearch(185, 287, 195, 295, 0x86671A, 20);stamina bar is full If IsArray($FullStamina) Then $FullStamina[2] = 1 sleep(1000) Until $FullStamina[2] = 1 send("{SPACE}");stand up sleep(4000) send("{F9}");sends a command to my other computer sleep(2000) send("o");unshieth sleep(1000) EndIf EndFunc Func Requip() $coord = PixelSearch(1519, 773, 1537, 798, 0x89635F, 20) ; If @error Then; Sleep(1000) Send("g");my 0 slot on my hotbar where i have my polearm Sleep(3000) Send("o");unshieth Sleep(1000) EndIf EndFunc ;==>_WeaponCheck Func WepCheck() $green = PixelSearch(15, 433, 39, 458, 0x137800, 20) If @error Then send("o") sleep(500) EndIf EndFunc Link to comment Share on other sites More sharing options...
MasonMill Posted December 21, 2009 Author Share Posted December 21, 2009 I used your second option and it did work! Thank you very much for your help. I am still interested in the first option just becasue i love learning new tricks. Im going to read up on IsArray and the rest of it. Any ideas on why the error came about though? Link to comment Share on other sites More sharing options...
jebus495 Posted December 21, 2009 Share Posted December 21, 2009 (edited) Ah yes. I just made that kind of randomly. AutoIt tags have no error checking. XD Declare: $IsFull somewhere in your script. Preferably at the top. Do $FullStamina = PixelSearch(185, 287, 195, 295, 0x86671A, 20);stamina bar is full If IsArray($FullStamina) Then $IsFull = 1 sleep(1000) Until $IsFull = 1 $IsFull = 0 ;reset the value so that it doesn't just skip past the loop the second time around. The error occurred because $FullStamina isn't an array until the PixelSearch finds the color. So the loop reaches the end and looks at $FullStamina[2] and goes HEY! that's not an array at all and proceeds to fail. Edited December 21, 2009 by jebus495 Link to comment Share on other sites More sharing options...
MasonMill Posted December 21, 2009 Author Share Posted December 21, 2009 Awesome, it works! And even better i understand why lol. You have been very helpful! Thank you for the time you devoted, i have learned something new to add to my SMALL arsenal hehe. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now