Jump to content

Error: Subscript used with non-array variable


Recommended Posts

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
Link to comment
Share on other sites

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

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...