forgetoo Posted May 2, 2009 Posted May 2, 2009 So after quite a few hours I've finally got my core functions down. I have a problem and wanted some advice on what to do. The important parts are the second line of the attack function. I want to do the If then statements below ONLY if either are Not @error. I get a error using the And statement and also figured because I was calling two ColorSearches the @error might be compromised and only report the second colorsearch as a error. PixelSearch( 660, 135, 660, 135, 0x404141, 10 ) And PixelSearch( 685, 135, 685, 135, 0x9D0B0E, 10 ) Here is the overall function. Basically as you can see I don't want it to call the "warp" function at the bottom unless both are a error. And I don't want it to do what I have in the middle unless either are true. expandcollapse popupFunc Warp(); Show text ToolTip( "Start Warp",0,40 ) Sleep ( 3000 ) EndFunc Func Attack(); Firing On Targets PixelSearch( 660, 135, 660, 135, 0x404141, 10 ) And PixelSearch( 685, 135, 685, 135, 0x9D0B0E, 10 ) If Not @error Then Send ( "{F1}" ) ToolTip('Starting to Fire"',0,0) Do PixelSearch( 660, 135, 660, 135, 0x404141, 10 ) Until @error Do PixelSearch( 595, 655, 595, 655, 0x323232, 10 ) Until Not @error PixelSearch( 660, 135, 660, 135, 0x404141, 10 ) If Not @error Then ToolTip('Calling Next Attack!"',0,0) Sleep ( 3000 ) Call ( "Attack" ) Else PixelSearch( 685, 135, 685, 135, 0x9D0B0E, 10 ) If Not @error Then ToolTip('Reloaded Starting to Fire"',0,0) Sleep ( 3000 ) Call ( "Attack" ) EndIf EndIf ToolTip('Calling Next Attack!"',0,0) Sleep ( 3000 ) Call ( "Attack" ) Else Call ( "Warp") EndIf EndFunc Call ( "Attack" ) If it finds either 0x404141 or 0x9D0B0E by 10 percent in the search then it needs to proceed to Send F1 and do the rest. Else I want it to call the Warp function as a recap. Do I just need to nest in another if state and copy the middle functions parts in or is there a simple way of doing this?
Richard Robertson Posted May 2, 2009 Posted May 2, 2009 Use something like $haserror = false PixelSearch(first one) If @error Then $haserror = true PixelSearch(second one) If @error Then $haserror = true If Not $haserror Then ; do what you need to when both worked EndIf
John117 Posted May 2, 2009 Posted May 2, 2009 (edited) I don't have autoit on this PC, but . . . try $Search1 = PixelSearch( 660, 135, 660, 135, 0x404141, 10 ) If @error then Return $Search2 = PixelSearch( 685, 135, 685, 135, 0x9D0B0E, 10 ) If not @error then Edited May 2, 2009 by John117
forgetoo Posted May 2, 2009 Author Posted May 2, 2009 I don't have autoit on this PC, but . . . try $Search1 = PixelSearch( 660, 135, 660, 135, 0x404141, 10 ) If @error then Return $Search2 = PixelSearch( 685, 135, 685, 135, 0x9D0B0E, 10 ) If not @error then Neither of those worked.. It skipped right to Warp instead of doing F1 etc when I know the colors were there to find. Also as for the Other, that gets hung in a loop even after the grey is not there and when it should roll back through and run Warp it simply loops over and over.
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