Physical
Active Members-
Posts
28 -
Joined
-
Last visited
Physical's Achievements
Seeker (1/7)
0
Reputation
-
Script randomly skipping lines
Physical replied to Physical's topic in AutoIt General Help and Support
Thanks for your help. Last night when i got home from work i worked on the script some more and found the problem. It was a combination of the method i was using to target and check the hp of mobs and the delays i had set. The reason the script was skipping lines randomly is because it was basicly getting ahead of itself and kept exiting the loops sooner then i wanted it to and continuing on in the script. Since it left the loop early it made the other conditional statements false and would skip them entirely which meant it was trying to collect drops when no drops were present due to the mob still being alive. Thanks for all the help tho, u guys have given me some good ideas. Writing these little scripts for a game like this helps me learn a lot because i have to think about things i wouldnt normally think about like it exiting the loops. Thanks for all the help. Here is the new script which a change i just made. BogQ in your example u used While loops instead of Do loops which seems like a good idea and possibly a more efficent way of doing it. (i am not sure which loop is more efficent but in this case i like the while one) So i replaced my Do loops which the while loops. Here is the new script: HotKeySet("{HOME}", "Automate") HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{END}", "Terminate") Global $Paused, $MobHP, $BuffCount, $Drop $BuffCount = 3 $Drop = 0 While 1 Sleep (100) WEnd Func Automate() Do If $BuffCount = 3 Then Send ("{4}") Sleep (1000) $BuffCount = 0 ElseIf $BuffCount < 3 Then $BuffCount = $BuffCount + 1 EndIf $MobHP = PixelGetColor (412, 25) ;Check target hp If $MobHP <> 0xD63839 Then ;If no target or target dead While $MobHP <> 0xD63839 ;Continue selecting new target until live target is found Send ("{TAB}") ;Select target Sleep (1500) $MobHP = PixelGetColor (412, 25) ;Check target hp WEnd EndIf $MobHP = PixelGetColor (412, 25) ;Check target hp If $MobHP = 0xD63839 Then ;Placed actions in If statment to protect against accidental out of loop situations While $MobHP <> 0x81714A ;Continue attack until target is dead Send ("{3}") ;Attack Sleep (250) $MobHP = PixelGetColor (412, 25) ;Check target hp WEnd Send ("{0}") ;Use Skill Sleep (7000) While $Drop < 4 ;Collect Drops Send ("{SPACE}") Sleep (500) $Drop = $Drop + 1 WEnd EndIf $Drop = 0 Until 0 > 1 EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) WEnd EndFunc Func Terminate() Exit 0 EndFunc -
Script randomly skipping lines
Physical replied to Physical's topic in AutoIt General Help and Support
yes i only want it to pickup 4 times, usually there are only 2 things to pickup. The problem is its completely skipping the pickup part altogether and going directly to the using skill on corpse part. I will read up on the onguievent thing because i dont know how to use the function. I will look and see if that helps. Thankyou for the help and any further help from anyone would be appreciated. Edit - I read about the GUIOnEvent function and i am not sure how it could be used in this situation. It seems to me this is for gui buttons being pushed or clicked or an action taken on the window itself like minimize or close. In the situation of this script there are no buttons to push in the actual window, everything is controled with keyboard commands. -
HotKeySet("{HOME}", "Automate") HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{END}", "Terminate") Global $Paused, $MobHP, $Count, $BuffCount, $Drop $Count = 0 $BuffCount = 3 $Drop = 0 While 1 Sleep (100) WEnd Func Automate() Do If $BuffCount = 3 Then Send ("{4}") Sleep (1000) $BuffCount = 0 ElseIf $BuffCount < 3 Then $BuffCount = $BuffCount + 1 EndIf $MobHP = PixelGetColor (415, 25) ;Checks target hp If $MobHP <> 0xD63839 Then ;If no target or target dead then Send ("{TAB}") ;Select target EndIf Sleep (100) Send ("{3}") ;Attack Sleep (1000) $MobHP = PixelGetColor (415, 25) ;Check target hp While $MobHP = 0xD63839 ;If target is alive then continue to attack $MobHP = PixelGetColor (415, 25) Send ("{3}") Sleep (500) WEnd Sleep (1500) While $Drop < 4 ;Collect Drops <---- TROUBLE IS HERE Send ("{SPACE 2}") Sleep (1000) $Drop = $Drop + 1 WEnd $Drop = 0 Send ("{0}") Sleep (7000) Until $Count = 10000 EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) WEnd EndFunc Func Terminate() Exit 0 EndFunc This is a script to act as a simple macro for a game, kill, loot, use skill on corpse, repeat. Very simple. The problem is in the collecting the drops. I have tried to seperate the code in every way i can think of. I put it in loops, i put it in functions, i put it in IF statements. It will work just fine for a while and then randomly it will completely skip the drop collection after killing the monster and go straight to using the skill on the corpse. I can't for the life of me figure out why. If anyone could please explain to me what i need to do/ direct me to helpfile section i would greatly appreciate it. Also if anyone happens to notice something i can do differently that would improve my coding methods i would appreciate any advice. I recoded this script about 3 or 4 different ways redoing the entire script trying to figure out this problem. Thankyou for any help.
-
I didn' t even think of trying that. Thanks for the help.
-
I am trying to use adlibenable to execute something every 10 seconds so i did AdlibEnable ("Function", 10000) and i placed this at the very top of my script. It made me think of something tho when i was deciding where to put it. If i put it inside a function that gets called frequently, for example: Func TestFunc() AdlibEnable ("Function", 10000) $X = $X + 1 EndFunc OR if i put it inside a loop that is constantly repeating: While 1 AdlibEnable ("Function", 10000) Sleep (100) WEnd Will the timer inside AdlibEnable get reset every time that it gets called again, or will it just ignore it since its already been enabled once? Thanks for any help.
-
Thankyou all of you for your help. I really appreciate it. I guess i am not the only one who didn't completely understand Dim.
-
Ok thankyou all very much for the help. I am sorry i am not trying to be difficult but i have tried everything all of you have said and i still either get syntax error, or an error when i try to print it to a msg box to test it out. Global $Colors[4] $Colors = [0x5C2517, 0x553826, 0x46332B, 0x7D5A45]oÝ÷ Ú¯zƬÊ{ZÅê뢸î²ÛazX§y«¢+ØÀÌØí ½±½ÉÌôlÁàÕÈÔÄܰÁàÔÔÌàÈØ°ÁàÐØÌÌɰÁàÝÕÐÕtoÝ÷ Ú¯zËazƦz̧µ¬^®º+jëh×6$Colors[4] = [0x5C2517, 0x553826, 0x46332B, 0x7D5A45]oÝ÷ ÚÆ¦yê뢼V¬ç$Â¥v¯z+p)^¬·*baƧvÚòx½êò¦,¹^rvâ~§vÊ&zØbajÜ(®Gjëh×6Global $Colors[4] = [0x5C2517, 0x553826, 0x46332B, 0x7D5A45] MsgBox (0, "test", $Colors[1])oÝ÷ Ú[m«lr¸©· +Â0®^¶¬)â±Êâ¦Ûhµë-ØÂ)e®(!µÉbrJ'¶¬r·'âµø§vÆ¢Z+«)uè-,!×¢·¥¸ ×%É(ØZ¶±zV§vØ^)º¦²èÅ«¢+Ù±½°ÀÌØí ½±½ÉÍlÑtôlÁá°ÁáÀ°ÁáÀÀ°ÁáÀÀÁt°ÀÌØíQ ½½É)!½Ñ-åMÐ ÅÕ½Ðíí!=5ôÅÕ½Ðì°ÅÕ½ÐíQÍÐÅÕ½Ðì¤()]¡¥±Ä(%M±À ÄÀÀ¤)]¹()Õ¹QÍÐ ¤(%½ÈÀÌØí`ôÀѼU½Õ¹ ÀÌØí ½±½É̤´Ä($$ÀÌØíQ ½½ÉôA¥á±MÉ ÌÀܰÈÈÀ°ÜÈÀ°ÔÄÀ°ÀÌØí ½±½ÉÍlÀÌØíat°ÄÔ¤($%%9=PÉɽÈQ¡¸($$%Ñ¥½¸ ¤($$%á¥Ñ1½½À($%¹%(%9áÐ)¹Õ¹()չѥ½¸ ¤(%5½ÕÍ ±¥¬ ÅÕ½ÐíÉ¥¡ÐÅÕ½Ðì°ÀÌØíQ ½½ÉlÁt°ÀÌØíQ ½½ÉlÅt°Ä¤(%5Í ½à À°ÅÕ½ÐíÑÍÐÅÕ½Ðì°ÀÌØí ½±½ÉÍlÀÌØíat¤)¹Õ¹ I think i understand now. Thanks very much all of you for your help Edit: i typed this before i saw PSaltyDS's reply. Thankyou very much for explaining it.
-
Thx for the help. I tried what u said, i even remade a whole new script with only the 2 lines of code you just wrote. It still gives me the exact same syntax error as it did before i put the Dim in front of it. I still don't understand why. ERROR: syntax error $Colors[4] = [ ~~~~~~~~^
-
I read the online documentation about it and i understand that its used for declaring things. However what i do not understand is why i have to use it to declare an array instead of being able to declare that array globaly. This is what i tried to do: Global $Paused, $TCoord, $Colors, $X $Colors[4] = [0x5C2517, 0x553826, 0x46332B, 0x7D5A45] For $X = 0 to Ubound($Colors) - 1 $TCoord = PixelSearch ( 75, 150, 950, 600, $Colors[$X], 10) If NOT @error Then Action() ExitLoop EndIf NextoÝ÷ Ù©Ý -j̧µ¬^®º+N¬ÈhÂ'âÅçbµ«¢+Ù±½°ÀÌØíAÕͰÀÌØíQ ½½É°ÀÌØí`()¥´ÀÌØí ½±½ÉÍlÑtôlÁàÕÈÔÄܰÁàÔÔÌàÈØ°ÁàÐØÌÌɰÁàÝÕÐÕt(%½ÈÀÌØí`ôÀѼU½Õ¹ ÀÌØí ½±½É̤´Ä($$ÀÌØíQ ½½ÉôA¥á±MÉ ÜÔ°ÄÔÀ°äÔÀ°ØÀÀ°ÀÌØí ½±½ÉÍlÀÌØíat°ÄÀ¤($%%9=PÉɽÈQ¡¸($$%Ñ¥½¸ ¤($$%á¥Ñ1½½À($%¹%(%9áÐ If you notice the Dim before the $Colors array. I did this because i saw someone else do it in a forum post. My question is why did i have to do it that way? Why can't i declare it with the rest of the globals? Thx for any help
-
Thanks i didn't think about that. I will adjust it so it doesnt find the wrong thing.
-
Ok yes this is helping a lot, thankyou very much. I have one more question. Would it be better to use the method of $Count = $Count + 1 to incriment the array or is the UBound function a better method? thx very much for your help
-
Thanks for the help. Right as you were posting i was doing more searching and found a thread with a little info but not much. So i rewrote it and it suggested the For Next thing as well. This is what i have now: $Colors[4] = [0x15100A, 0x553826, 0x46332B, 0x7D5A45] For $X = 0 to Ubound($Colors) - 1 $TCoord = PixelSearch ( 75, 150, 950, 600, $Colors[$X], 10) Next The more i look at it tho i am wondering, will this pick 1 of the 4 colors and move on or will this wait till it finds all 4 then move on? thx for any help
-
I am trying to use the pixel search function to search for any 1 of 4 colors. It doesnt matter which one it comes across first. I am not sure what the best way to go about it is. If i use 4 lines of PixelSearch then it will just hop from one to the next before it does an action. I considered doing the folowing. $Array[0] = xxxxxxxx ;store the 4 values in an array $Array[1] = xxxxxxxx $Array[2] = xxxxxxxx $Array[3] = xxxxxxxx While 1 $TCoord = PixelSearch (75, 150, 950, 600, $Array[$Count]) If @error Then If $Count = 3 Then $Count = 0 EndIf $Count + 1 Return ElseIf Not @error Then $Count = 0 Call ("Function") EndIf WEnd I am not sure this will even work. I am still learning this so i may even have done some code wrong i am still working on it. Hopefully you can get an idea of what i am trying to do. Any help and suggestions would be greatly appreciated.
-
Unless i dont know how to use it correctly i dont think adlib will work in this case. It worked for my other problem but this time i need it to take an action if the value stored in the variable changes. Basicaly i need the script to monitor a certin thing and if that thing changes then i need it to take an action immediately, not wait for the loop to end then do something. From what i understand (which might be wrong i am still learning) adlib only executes based on time. Is there another way of using it or does anyone have another suggestion? thanks for any help.