Sign in to follow this  
Followers 0
gunnagitcha

Need help simplifying this script

3 posts in this topic

Ok so at first I was fine with the way I had this script running, but now I added a bunch more and it's rather lengthy, so is there a way to simplify this script? Basically it searches an area for a color and clicks it until it doesnt find it anymore, then moves onto the next square.

$bag1x1 = 584
$bag1y1 = 661
$bag1x2 = 626
$bag1y2 = 706

$column1x1 = Pixelsearch($bag1x1,$bag1y1,$bag1x2,$bag1y2,0xAAD0DA, 20)
If Not @error then
                MouseClick( "Right" ,$column1x1[0],$column1x1[1],1,4)
                sleep(175)
            endif
        Until @error
Do
$column1x2 = Pixelsearch($bag1x1,$bag1y1+51,$bag1x2,$bag1y2+51,0xAAD0DA, 20)
If Not @error then
        
                MouseClick( "Right" ,$column1x2[0],$column1x2[1],1,4)
                sleep(175)
            endif
        Until @error
Do
$column2x1 = Pixelsearch($bag1x1+51,$bag1y1,$bag1x2+51,$bag1y2,0xAAD0DA, 20)
If Not @error then
    
                MouseClick( "Right" ,$column2x1[0],$column2x1[1],1,4)
                sleep(175)
            endif
    Until @error 
EndIf
        Until @error

Share this post


Link to post
Share on other sites



You could use arrays and loops to shorten it quite alot, something like this:

(untested)

Global $Pos[3][4]=[ _
[584, 661, 626, 706],  _
[584, 712, 626, 757],  _
[635, 661, 697, 706]]

For $X = 0 To 2
    Do
        $column1x2 = PixelSearch($Pos[$X][0], $Pos[$X][1], $Pos[$X][2], $Pos[$X][3], 0xAAD0DA, 20)
        If Not @error Then
            MouseClick("Right", $column1x2[0], $column1x2[1], 1, 4)
            Sleep(175)
        EndIf
    Until @error
Next

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I thought of that, only there are about 80 different arrays I have to use lol, that was just an excerpt from the script :P

Edit* I guess the thought I had would be, Is there a way to have in it add 51 a set number of times?

Edited by gunnagitcha

Share this post


Link to post
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
Sign in to follow this  
Followers 0