Jump to content

Need help with loop


Recommended Posts

I'm new and tried to make a simple clicker. I want it to wait for certain color to appear on the location then click on location x1 then x2 then x3 and so on... but it fail. Can someone guide me?

Here's my malfunction code:

Global $X1 = 794
Global $X2 = 828
Global $X3 = 865
Global $X4 = 903
Global $X5 = 940
Global $X6 = 978
Global $Y1 = 129
Global $JX = 501
Global $JY = 508

;Main Clicker
if (pixelgetcolor (500,45) <> 0xFF7B7B) then
    sleep (250)
    endif
$r1 = 1
        While $r1 <=6
        MouseClick("right", $X($r1), $Y1, 2)
        Sleep(300)
        ; Click JPot
        MouseClick("left", $JX, $JY, 3)
        Sleep(300)
        MouseClick("left", $JX, $JY, 3)
        Sleep(300)
        MouseClick("left", $JX, $JY, 3)
        Sleep(300)
        $r1 = $r1 + 1
        WEnd

Can someone correct this for me? Thanks.

Link to comment
Share on other sites

I may be way off here, but wouldn't this script currently check for the color and then end?

Looks like it is missing an if else statement.

Global $X1 = 794
Global $X2 = 828
Global $X3 = 865
Global $X4 = 903
Global $X5 = 940
Global $X6 = 978
Global $Y1 = 129
Global $JX = 501
Global $JY = 508

;Main Clicker
Func check()
if (pixelgetcolor (500,45) <> 0xFF7B7B) then
    sleep (250)
    check()
elseif(pixelgetcolor (500,45) == 0xFF7B7B) then
click()
    endif
EndFunc

Func click()
$r1 = 1
        While $r1 <=6
        MouseClick("right", $X($r1), $Y1, 2)
        Sleep(300)
        ; Click JPot
        MouseClick("left", $JX, $JY, 3)
        Sleep(300)
        MouseClick("left", $JX, $JY, 3)
        Sleep(300)
        MouseClick("left", $JX, $JY, 3)
        Sleep(300)
        $r1 = $r1 + 1
        WEnd
EndFunc

I'm sure I have this messed up in here somewhere, but maybe this might help,

or someone can better elaborate or correct my hackjob

Link to comment
Share on other sites

Thanks for the advice but I guess something's wrong with this line or the whole loop:

MouseClick("right", $X($r1), $Y1, 2)

because I get error:

WARNING: $X: possibly used before declaration.

Edited by BitByte
Link to comment
Share on other sites

You're doing it wrong...

Global $X[6] = [ 794, 828, 865, 903, 940, 978 ]
Global $Y1 = 129
Global $JX = 501
Global $JY = 508

;Main Clicker
If (pixelgetcolor (500,45) <> 0xFF7B7B) then
    sleep (250)
EndIf
$r1 = 0
For $r1 = 0 To 5
    MouseClick("right", $X[$r1], $Y1, 2)
    Sleep(300)
    ; Click JPot
    MouseClick("left", $JX, $JY, 3)
    Sleep(300)
    MouseClick("left", $JX, $JY, 3)
    Sleep(300)
    MouseClick("left", $JX, $JY, 3)
    Sleep(300)
Next
Edited by omikron48
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...