Jump to content

Recommended Posts

Posted (edited)

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
Posted

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.

Posted

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

Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...