Arkanys Posted March 31, 2009 Share Posted March 31, 2009 (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 March 31, 2009 by Arkanys Link to comment Share on other sites More sharing options...
Authenticity Posted March 31, 2009 Share Posted March 31, 2009 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. Link to comment Share on other sites More sharing options...
Arkanys Posted April 1, 2009 Author Share Posted April 1, 2009 I checked all three variables using IsArray, but they all return true, so now im very confused -.- Link to comment Share on other sites More sharing options...
stampy Posted April 1, 2009 Share Posted April 1, 2009 Show us the code with the IsArray. Link to comment Share on other sites More sharing options...
LiveOnTheFly Posted April 1, 2009 Share Posted April 1, 2009 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 More sharing options...
Arkanys Posted April 1, 2009 Author Share Posted April 1, 2009 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now