meowbits Posted May 6, 2009 Share Posted May 6, 2009 When I assign the following, I get the error. I'm guessing it'll be the same with every occasion. $storeCoords[0] = $coord1[0] $storeCoords[1] = $coord1[1] Do you know what i'm doing wrong? expandcollapse popupOpt("WinWaitDelay",3000) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) #include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; declare variable color (use Eyedropper4.0 to find color, ; keep 0x and add your 6 digit number after it) Global $storeIconColor = 0xB0BD62 ; store icon color Global $hayBailColor = 0xF7A505 ; haybail color Global $grassColor = 0x3A7A02 ; grass color Global $bailsTobuy ; Number of haybails to buy/sell Global $storeCoords ; Coordinates of the store icon Global $otherCoords ; Coordinates of the 'other' tab Global $buyHayBailCoords ; Coordinates to buy haybail Global $placeHayBailCoords ; Coordinates to place haybail Global $sellHayBailCoords = $placeHayBailCoords Global $confirmSellCoords; Coordinates to sell haybail ; declare ON true(on) false(off) Global $ON = False ; set esc and pause HotKeySet("{ESC}", "Terminate") ; Pop-up dialog box to start program MsgBox(0,"IMPORTANT", "Login to facebook prior to clicking 'OK'") MsgBox(1,"Holybails", "'OK' to start, press 'ESC' to stop.") ;If $bailsTobuy != Int Then ; dialog box to prompt for total bails to buy/sell - NEED HELP ; Amount of bails you can afford is ((Total Coins -50)/48)) round down ; if answer != integer stop or run a loop to ask again, not sure how to. ; answer = $baysToBuy Func Terminate() Exit 0 EndFunc ;If ($CmdLine[0] = 2) Then ;Exit 0 ;EndIf ;If ($CmdLine[0] = 1) Then ; Open url to play FarmTown _IECreate ("http://apps.facebook.com/farmtown/play/", 1, 1, 1, 1) $ON = True ; Initial loop Dim $iCounter = 1 While $iCounter Sleep(500) if $ON = True Then ; start pixel search for store icon $coord1 = PixelSearch(480, 120, 1240, 700, $storeIconColor,10) If IsArray($coord1) = 1 Then ; save coords as 'storeCoords' $storeCoords[0] = $coord1[0] $storeCoords[1] = $coord1[1] MouseClick("left", $storeCoords[0], $storeCoords[1]) ; Error msg Else MsgBox(0,"ERROR","Unable to find Store icon edit your '$storeIconColor'") Exit EndIf Sleep(300) ; start somesort of search to find the 'other' tab - NEED HELP $coord2 = 1 If IsArray($coord2) = 1 Then $coord2[0] = 1100 $coord2[1] = 210 ; save coords as 'otherCoords' $otherCoords[0] = $coord2[0] $otherCoords[1] = $coord2[1] MouseClick("left", $otherCoords[0], $otherCoords[1]) ; Error msg Else MsgBox(0,"ERROR","Unable to find '$otherCoords'") Exit EndIf Sleep(300) ; start pixel search for haybail icon $coord3 = PixelSearch(480, 120, 1240, 700, $hayBailColor,10) If IsArray($coord3) = 1 Then ; save coords as 'buyHayBailCoords' $buyHayBailCoords[0] = $coord3[0] $buyHayBailCoords[1] = $coord3[1] MouseClick("left", $buyHayBailCoords[0], $buyHayBailCoords[1]) ; Error msg Else MsgBox(0,"ERROR","Unable to find HayBail edit your '$haybailColor'") Exit EndIf Sleep(300) ; start pixel search for grass color $coord4 = PixelSearch(480, 120, 1240, 700, $grassColor,10) If IsArray($coord4) = 1 Then ; save coords as 'placeHayBailCoords' $placeHayBailCoords[0] = $coord4[0] $placeHayBailCoords[1] = $coord4[1] MouseClick("left", $placeHayBailCoords[0], $placeHayBailCoords[1]) Sleep(300) MouseClick("left", $sellHayBailCoords[0], $sellHayBailCoords[1]) ; Error msg Else MsgBox(0,"ERROR","Unable to find Grass edit your '$grassColor'") Exit EndIf Sleep(300) ; start somesort of search to find the 'sell' tab - NEED HELP $coord5 = 1 If IsArray($coord5) = 1 Then ; save coords as 'confirmSellCoords' $confirmSellCoords[0] = $coord5[0] $confirmSellCoords[1] = $coord5[1] MouseClick("left", $confirmSellCoords[0], $storeCoords[1]) ; Error msg Else MsgBox(0,"ERROR","Unable to find 'confirmSellCoords'") Exit EndIf EndIf $iCounter +=1 WEnd Dim $bCounter = 1 ; Main loop While $bailsTobuy -1 >= $bCounter Sleep(5000) MouseClick("left", $storeCoords[0], $storeCoords[1]) Sleep(300) MouseClick("left", $otherCoords[0], $otherCoords[1]) Sleep(300) MouseClick("left", $buyHayBailCoords[0], $buyHayBailCoords[1]) Sleep(300) MouseClick("left", $placeHayBailCoords[0], $placeHayBailCoords[1]) Sleep(300) MouseClick("left", $sellHayBailCoords[0], $sellHayBailCoords[1]) Sleep(300) MouseClick("left", $confirmSellCoords[0], $storeCoords[1]) $bCounter +=1 WEnd ;EndIf Link to comment Share on other sites More sharing options...
felixli93 Posted May 6, 2009 Share Posted May 6, 2009 always check @error after PixelSearch it may be, that the color is not found, then, the variable $coord is no array but then you use $coord[0], but $coord is not even an array always check @error after PixelSearch If not @error Then ... Link to comment Share on other sites More sharing options...
Valuater Posted May 6, 2009 Share Posted May 6, 2009 try thisGlobal $storeCoords[2] ; Coordinates of the store iconGlobal the "array" not just a variable8) Link to comment Share on other sites More sharing options...
Valuater Posted May 6, 2009 Share Posted May 6, 2009 always check @error after PixelSearch it may be, that the color is not found, then, the variable $coord is no array but then you use $coord[0], but $coord is not even an array always check @error after PixelSearch If not @error Then ... This IS another way to check felix If IsArray($coord5) = 1 Then 8) Link to comment Share on other sites More sharing options...
DrDuKeS Posted September 21, 2013 Share Posted September 21, 2013 always check @error after PixelSearch it may be, that the color is not found, then, the variable $coord is no array but then you use $coord[0], but $coord is not even an array always check @error after PixelSearch If not @error Then ... I know that I'm "necro-ing" an old post, but I found it via Google I couldn't figure out why my array was giving me the ol' "Subscript used with non-array variable", but it WAS an array! Argh! (ie: The Pixelsearch was essentially reverting it to a non-array). All I did was RE-Declare it as an array inside the @error check. I know it's not pretty, but it works Thanks felixli93! 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