Sign in to follow this  
Followers 0
kanethekiller

Help with Variable arrays...

3 posts in this topic

#1 ·  Posted (edited)

I keep getting the error that all my $pix variables aren't a array variables... but it happens randomly and to all of them at random times... any advice?

Specific Error " MouseClick ("Left", $pix1[0], $Pix1[1],1,1) $pix1[0] Subscript used with a non array variable"

Here is the script

HotKeySet("^!q", "MyExit")

Hotkeyset("^m", "Mine")

HotkeySet("^p", "Pause")

$Gem=0

While 1;

Wend

Func Mine()

While 1;

$pix1 = PixelSearch (143,156,418,480,0x101C31,5,5)

MouseClick ("Left", $pix1[0], $Pix1[1],1,1)

Sleep(6000)

$random1 = Random (500,1500)

Sleep($random1)

$pix2 = PixelSearch (143,156,418,480,0x101C31,5,5)

MouseClick ("Left", $pix2[0], $Pix2[1],1,1)

Sleep(6000)

$random1 = Random (500,1500)

Sleep($random1)

$pix3 = PixelSearch (143,156,418,480,0x101C31,5,5)

MouseClick ("Left", $pix3[0], $Pix3[1],1,1)

Sleep(6000)

$random1 = Random (500,1500)

Sleep($random1)

$pix4 = PixelSearch (143,156,418,480,0x101C31,5,5)

MouseClick ("Left", $pix4[0], $Pix4[1],1,1)

Sleep(6000)

$random1 = Random (500,1500)

Sleep($random1)

$pix5 = PixelSearch (475,270,643,491,0x101C31,5,5)

MouseClick ("Left", $pix5[0], $Pix5[1],1,1)

Sleep(6000)

$random1 = Random (500,1500)

Sleep($random1)

If $Gem=0 Then

$drop1 = PixelGetColor (707,379)

If $drop1 = 0x101c31 Then

MouseClick ("Right",708,379,1,1)

Sleep(500)

Mouseclick ("Left",670,420,1,1)

Sleep(600)

Mouseclick("Right", 753, 384, 1, 3)

Sleep(600)

Mouseclick("Left", 709, 425, 1, 2)

Sleep(600)

Mouseclick("Right", 796, 382, 1, 3)

Sleep(600)

Mouseclick("Left", 765, 421, 1, 2)

Sleep(600)

Mouseclick("Right", 836, 383, 1, 3)

Sleep(600)

Mouseclick("Left", 796, 424, 1, 2)

Sleep(600)

Mouseclick("Right", 710, 418, 1, 3)

Sleep(600)

Mouseclick("Left", 673, 462, 1, 2)

Sleep(750)

ElseIf $drop1 <> 0x101c31 Then

MouseClick ("Right",752,374,1,1)

Sleep(500)

Mouseclick ("Left",712,419,1,1)

Sleep(600)

Mouseclick("Right", 796, 382, 1, 3)

Sleep(600)

Mouseclick("Left", 765, 421, 1, 2)

Sleep(600)

Mouseclick("Right", 836, 383, 1, 3)

Sleep(600)

Mouseclick("Left", 796, 424, 1, 2)

Sleep(600)

Mouseclick("Right", 710, 418, 1, 3)

Sleep(600)

Mouseclick("Left", 673, 462, 1, 2)

Sleep(600)

Mouseclick("Right", 752, 418, 1, 3)

Sleep(600)

Mouseclick("Left", 717, 459, 1, 2)

Sleep(750)

$Gem=$Gem+1

Endif

Elseif $Gem=1 Then

$drop1 = PixelGetColor (748,378)

If $drop1 = 0x101c31 Then

Mouseclick("Right", 753, 384, 1, 3)

Sleep(500)

Mouseclick("Left", 709, 425, 1, 2)

Sleep(600)

Mouseclick("Right", 796, 382, 1, 3)

Sleep(600)

Mouseclick("Left", 765, 421, 1, 2)

Sleep(600)

Mouseclick("Right", 836, 383, 1, 3)

Sleep(600)

Mouseclick("Left", 796, 424, 1, 2)

Sleep(600)

Mouseclick("Right", 710, 418, 1, 3)

Sleep(600)

Mouseclick("Left", 673, 462, 1, 2)

Sleep(600)

Mouseclick("Right", 752, 418, 1, 3)

Sleep(600)

Mouseclick("Left", 717, 459, 1, 2)

Sleep(750)

Elseif $drop1 <> 0x101c31 Then

Mouseclick("Right", 796, 382, 1, 3)

Sleep(600)

Mouseclick("Left", 765, 421, 1, 2)

Sleep(750)

Mouseclick("Right", 836, 383, 1, 3)

Sleep(600)

Mouseclick("Left", 796, 424, 1, 2)

Sleep(600)

Mouseclick("Right", 710, 418, 1, 3)

Sleep(600)

Mouseclick("Left", 673, 462, 1, 2)

Sleep(600)

Mouseclick("Right", 752, 418, 1, 3)

Sleep(600)

Mouseclick("Left", 717, 459, 1, 2)

Sleep(600)

Mouseclick("Right", 792, 417, 1, 3)

Sleep(600)

Mouseclick("Left", 756, 457, 1, 2)

Sleep(750)

$Gem=$Gem+1

Endif

Endif

wend

EndFunc

Func MyExit()

Exit

EndFunc

Func Pause()

While 1;

Sleep(600000)

wend

Endfunc

Edited by kanethekiller

Share this post


Link to post
Share on other sites



PixelSearch() will only return an array if it found anything, you can get around that by doing something like:

If IsArray($pix1) then MouseClick ("Left", $pix1[0], $Pix1[1],1,1)

Or you could look at the returned error, see the section "Return Value" in the helpfile for PixelSearch().

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

try this:

HotKeySet("^!q", "MyExit")
HotKeySet("^m", "Mine")
HotKeySet("^p", "Pause")
Local $vPaused = False

While 1;
    Sleep(100)
WEnd

Func Mine()
    Local $iGem = 0

    While 1
        For $i = 1 To 5
            $aiCoord = PixelSearch(143, 156, 418, 480, 0x101C31, 5, 5)
            If Not @error Then
                MouseClick("Left", $aiCoord[0], $aiCoord[1], 1, 1)
                Sleep(6000 + Random(500, 1500))
            EndIf
        Next

        If Not $iGem Then
            $iDrop = PixelGetColor(707, 379)
            If $iDrop = 0x101c31 Then
                MouseClick("Right", 708, 379, 1, 1)
                Sleep(500)
                MouseClick("Left", 670, 420, 1, 1)
                Sleep(600)
                MouseClick("Right", 753, 384, 1, 3)
                Sleep(600)
                MouseClick("Left", 709, 425, 1, 2)
                Sleep(600)
                MouseClick("Right", 796, 382, 1, 3)
                Sleep(600)
                MouseClick("Left", 765, 421, 1, 2)
                Sleep(600)
                MouseClick("Right", 836, 383, 1, 3)
                Sleep(600)
                MouseClick("Left", 796, 424, 1, 2)
                Sleep(600)
                MouseClick("Right", 710, 418, 1, 3)
                Sleep(600)
                MouseClick("Left", 673, 462, 1, 2)
                Sleep(750)
            Else
                MouseClick("Right", 752, 374, 1, 1)
                Sleep(500)
                MouseClick("Left", 712, 419, 1, 1)
                Sleep(600)
                MouseClick("Right", 796, 382, 1, 3)
                Sleep(600)
                MouseClick("Left", 765, 421, 1, 2)
                Sleep(600)
                MouseClick("Right", 836, 383, 1, 3)
                Sleep(600)
                MouseClick("Left", 796, 424, 1, 2)
                Sleep(600)
                MouseClick("Right", 710, 418, 1, 3)
                Sleep(600)
                MouseClick("Left", 673, 462, 1, 2)
                Sleep(600)
                MouseClick("Right", 752, 418, 1, 3)
                Sleep(600)
                MouseClick("Left", 717, 459, 1, 2)
                Sleep(750)
                $iGem = $iGem + 1
            EndIf
        Else
            $iDrop = PixelGetColor(748, 378)
            If $iDrop = 0x101c31 Then
                MouseClick("Right", 753, 384, 1, 3)
                Sleep(500)
                MouseClick("Left", 709, 425, 1, 2)
                Sleep(600)
                MouseClick("Right", 796, 382, 1, 3)
                Sleep(600)
                MouseClick("Left", 765, 421, 1, 2)
                Sleep(600)
                MouseClick("Right", 836, 383, 1, 3)
                Sleep(600)
                MouseClick("Left", 796, 424, 1, 2)
                Sleep(600)
                MouseClick("Right", 710, 418, 1, 3)
                Sleep(600)
                MouseClick("Left", 673, 462, 1, 2)
                Sleep(600)
                MouseClick("Right", 752, 418, 1, 3)
                Sleep(600)
                MouseClick("Left", 717, 459, 1, 2)
                Sleep(750)
            Else
                MouseClick("Right", 796, 382, 1, 3)
                Sleep(600)
                MouseClick("Left", 765, 421, 1, 2)
                Sleep(750)
                MouseClick("Right", 836, 383, 1, 3)
                Sleep(600)
                MouseClick("Left", 796, 424, 1, 2)
                Sleep(600)
                MouseClick("Right", 710, 418, 1, 3)
                Sleep(600)
                MouseClick("Left", 673, 462, 1, 2)
                Sleep(600)
                MouseClick("Right", 752, 418, 1, 3)
                Sleep(600)
                MouseClick("Left", 717, 459, 1, 2)
                Sleep(600)
                MouseClick("Right", 792, 417, 1, 3)
                Sleep(600)
                MouseClick("Left", 756, 457, 1, 2)
                Sleep(750)
                $iGem = $iGem + 1
            EndIf
        EndIf
    WEnd
EndFunc   ;==>Mine

Func MyExit()
    Exit
EndFunc   ;==>MyExit

Func Pause()
    $vPaused = Not $vPaused
    While $vPaused
        Sleep(250)
    WEnd
EndFunc   ;==>Pause
Edited by TerarinK

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

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