Jump to content
Sign in to follow this  
Arkanys

Error: Subscript used with non-array variable

Recommended Posts

Arkanys

So, I know this topic has been posted a lot, and im sure it's fairly simple, so I'll try to keep this short.

I'm making bots for small flash games on mindjolt (Facebook) and so far most of them have worked with few flaws.

But there is this one error that keeps coming up that is forcing me to take alternate routes to make these bots: Error at line -1 | Error: Subscript used in non-array variable.

I think I understand what this means, but I don't know how to make these variables arrays... anyway, here's my script for Warp Speed (it's unfinished, due to my not being able to test it, also, any ideas to make it better are appreciated)

sleep (10000)
HotKeySet("{ESC}", "Terminate")
Dim $shipCoordinates[2]
Dim $mouseCoordinates[2]

While 1
    $Pos = PixelSearch( 480, 665, 480, 670, 0xFFFFFF, 0, 15)
    $shipCoordinates = PixelSearch (470, 650, 490, 680, 0x717171, 10)
    MouseMove ($shipCoordinates[0], $shipCoordinates[1], 0)
    $mouseCoordinates = MouseGetPos ( )
    If $mouseCoordinates[0] < $Pos [0] Then
        Send ("{Right}")
    ElseIf $mouseCoordinates[0] > $Pos [0] Then
        Send ("{Left}")
    Endif
    If Not @error Then
        MouseMove ($Pos[0], $Pos[1], 3)
    EndIf
wend

Func Terminate()
    Exit 0
EndFunc
Edited by Arkanys

Share this post


Link to post
Share on other sites
Authenticity

You need to read again the help file. If the color could not be found then neither $Pos nor $shipCoordinates contain array, so trying to access subscripts that aren't exist is causing this run-time error. In short, check if the return value is array using IsArray.

Share this post


Link to post
Share on other sites
Arkanys

I checked all three variables using IsArray, but they all return true, so now im very confused -.-

Share this post


Link to post
Share on other sites
stampy

Show us the code with the IsArray.

Share this post


Link to post
Share on other sites
LiveOnTheFly

So, I know this topic has been posted a lot, and im sure it's fairly simple, so I'll try to keep this short.

I'm making bots for small flash games on mindjolt (Facebook) and so far most of them have worked with few flaws.

But there is this one error that keeps coming up that is forcing me to take alternate routes to make these bots: Error at line -1 | Error: Subscript used in non-array variable.

I think I understand what this means, but I don't know how to make these variables arrays... anyway, here's my script for Warp Speed (it's unfinished, due to my not being able to test it, also, any ideas to make it better are appreciated)

sleep (10000)

HotKeySet("{ESC}", "Terminate")

Dim $shipCoordinates[2]

Dim $mouseCoordinates[2]

While 1

$Pos = PixelSearch( 480, 665, 480, 670, 0xFFFFFF, 0, 15)

$shipCoordinates = PixelSearch (470, 650, 490, 680, 0x717171, 10)

MouseMove ($shipCoordinates[0], $shipCoordinates[1], 0)

$mouseCoordinates = MouseGetPos ( )

If $mouseCoordinates[0] < $Pos [0] Then

Send ("{Right}")

ElseIf $mouseCoordinates[0] > $Pos [0] Then

Send ("{Left}")

Endif

If Not @error Then

MouseMove ($Pos[0], $Pos[1], 3)

EndIf

wend

Func Terminate()

Exit 0

EndFunc

The bolded area is where your problem is.

compare the [] you have on those vars to the []s you have on other vars

Share this post


Link to post
Share on other sites
Arkanys

The bolded area is where your problem is.

compare the [] you have on those vars to the []s you have on other vars

So the problem is just the extra space? Alright, I'll try that out. thx

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  

×