Jump to content
Sign in to follow this  
Mega99

Subscript used with non-Array variable

Recommended Posts

Mega99

Ok so I am currently trying to make a bot that will play this game by itself.

The game consists of jumping up with a mouse click, hitting a object that will make you go up higher, and so on.

To move the jumping person, you just move the mouse.

I use PixelSearch to find the the bells (on which you jump on), and then MouseMove to get move the mouse.

Unfortunatly, SciTE is giving me a error: Subscript used with non-Array variable.:

Global $coor[2]
sleep(2000)
$coor=PixelSearch(2298, 400, 2981, 525, 0xC6D6E3, 10, 1 )
MsgBox(0,"try",IsArray($coor))
While @error=0
    if not @error then
    $coor = PixelSearch(2298, 360, 2981, 485, 0xC6D6E3, 10, 1 )
    MouseMove($coor[0], $coor[1], 2)
    Sleep(350)
    EndIf
Wend

The program still works though...

I'd still want to fix this little bug.

Thanks

Share this post


Link to post
Share on other sites
Authenticity

So change the loop logic because you'll need to call IsArray() or check if there is an @error:

$coor=PixelSearch(2298, 400, 2981, 525, 0xC6D6E3, 10, 1 )
If @error = 0 Then
    Do
        MouseMove($coor[0], $coor[1], 2)
        Sleep(350)
        $coor = PixelSearch(2298, 360, 2981, 485, 0xC6D6E3, 10, 1 )
    Until @error
EndIf

Share this post


Link to post
Share on other sites
Mega99

Thanks!

That worked!

Cheers,

Mega99

Share this post


Link to post
Share on other sites
jvanegmond

The only problem with the original script was that you forgot to check for errors on the second PixelSearch.

Global $coor[2]
sleep(2000)
$coor=PixelSearch(2298, 400, 2981, 525, 0xC6D6E3, 10, 1 )
MsgBox(0,"try",IsArray($coor))
While @error=0 ; <== A proper check for errors
    if not @error then
    $coor = PixelSearch(2298, 360, 2981, 485, 0xC6D6E3, 10, 1 )
    MouseMove($coor[0], $coor[1], 2) ; <== No check for error
    Sleep(350)
    EndIf
Wend

Share this post


Link to post
Share on other sites
Tvern

The only problem with the original script was that you forgot to check for errors on the second PixelSearch.

Well that, and the first error check seems to be checking if the MsgBox() returned an error, rather then the PixelSearch(). Edited by Tvern

Share this post


Link to post
Share on other sites
jvanegmond

Well that, and the first error check seems to be checking if the MsgBox() returned an error, rather then the PixelSearch().

True, or IsArray... Maybe. Edited by Manadar

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  

×