Makalele 0 Posted July 20, 2010 Here's a part of my code:... For $rScan=0 to 3 If $Potions[1][$rScan] = "h" Then ExitLoop Next If $Potions[1][$rScan] = "h" Then ...Here's a declaration of $Potions array:Dim $Potions[4][4]And here's an error:Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If $Potions[1][$rScan] = "h" Then If ^ ERRORWhy??? Share this post Link to post Share on other sites
JohnOne 1,603 Posted July 20, 2010 It means that whatever you are populating "Dim $Potions[4][4]" with, excedes the bounds of it. Without further code, no other info is possible. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
Makalele 0 Posted July 20, 2010 It means that whatever you are populating "Dim $Potions[4][4]" with, excedes the bounds of it. Without further code, no other info is possible. I know what it means, but i don't know why it happens. Here's a loop loop from 0 do 3 so it can't "go out" the array, same with '1'. Ok so here's a whole function: expandcollapse popupFunc Chicken() CheckLife() CheckMana() If $Life < $MinRV_HP And TimerDiff($LastDrinkRvHealth)>1000 Then For $rScan=0 to 3 If $Potions[0][$rScan] = "r" Then ExitLoop Next If $Potions[0][$rScan] = "r" Then Send("1") $LastDrinkRvHealth=TimerInit() $Potions[0][$rScan] = " " Return 1 Else If $Life<=$ChickenHP Then SaveAndExitGame() Return -1 EndIf EndIf EndIf If $Mana < $MinRV_MP And TimerDiff($LastDrinkRvMana)>1000 Then For $rScan=0 to 3 If $Potions[0][$rScan] = "r" Then ExitLoop Next If $Potions[0][$rScan] = "r" Then Send("1") $LastDrinkRvHealth=TimerInit() $Potions[0][$rScan] = " " Return 1 Else If $Mana<=$ChickenMP Then SaveAndExitGame() Return -1 EndIf EndIf Send("1") $LastDrinkRvHealth=TimerInit() Return 1 EndIf If $Life < $MinHP And TimerDiff($LastDrinkHealth)>2000 Then For $rScan=0 to 3 If $Potions[1][$rScan] = "h" Then ExitLoop Next If $Potions[1][$rScan] = "h" Then Send("2") $LastDrinkHealth=TimerInit() $Potions[1][$rScan] = " " Else For $rScan=0 to 3 If $Potions[2][$rScan] = "h" Then ExitLoop Next If $Potions[2][$rScan] = "h" Then Send("3") $LastDrinkHealth=TimerInit() $Potions[2][$rScan] = " " EndIf EndIf EndIf If $Mana < $MinMP And TimerDiff($LastDrinkMana)>2000 Then For $rScan=0 to 3 If $Potions[3][$rScan] = "m" Then ExitLoop Next If $Potions[3][$rScan] = "m" Then Send("4") $LastDrinkMana=TimerInit() $Potions[3][$rScan] = " " EndIf EndIf Return 0 EndFunc Share this post Link to post Share on other sites
JohnOne 1,603 Posted July 20, 2010 I see what you mean. I think $rScan is only valid inside your For..Next loop, so that may be the problem. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
Bowmore 97 Posted July 20, 2010 Look at the commented line.expandcollapse popupFunc Chicken() CheckLife() CheckMana() If $Life < $MinRV_HP And TimerDiff($LastDrinkRvHealth)>1000 Then For $rScan=0 to 3 If $Potions[0][$rScan] = "r" Then ExitLoop Next If $Potions[0][$rScan] = "r" Then ;<<<<<<<< $rScan = 4 at this point because the for loop exits when it is greater than 3 Send("1") $LastDrinkRvHealth=TimerInit() $Potions[0][$rScan] = " " Return 1 Else If $Life<=$ChickenHP Then SaveAndExitGame() Return -1 EndIf EndIf EndIf If $Mana < $MinRV_MP And TimerDiff($LastDrinkRvMana)>1000 Then For $rScan=0 to 3 If $Potions[0][$rScan] = "r" Then ExitLoop Next If $Potions[0][$rScan] = "r" Then Send("1") $LastDrinkRvHealth=TimerInit() $Potions[0][$rScan] = " " Return 1 Else If $Mana<=$ChickenMP Then SaveAndExitGame() Return -1 EndIf EndIf Send("1") $LastDrinkRvHealth=TimerInit() Return 1 EndIf If $Life < $MinHP And TimerDiff($LastDrinkHealth)>2000 Then For $rScan=0 to 3 If $Potions[1][$rScan] = "h" Then ExitLoop Next If $Potions[1][$rScan] = "h" Then Send("2") $LastDrinkHealth=TimerInit() $Potions[1][$rScan] = " " Else For $rScan=0 to 3 If $Potions[2][$rScan] = "h" Then ExitLoop Next If $Potions[2][$rScan] = "h" Then Send("3") $LastDrinkHealth=TimerInit() $Potions[2][$rScan] = " " EndIf EndIf EndIf If $Mana < $MinMP And TimerDiff($LastDrinkMana)>2000 Then For $rScan=0 to 3 If $Potions[3][$rScan] = "m" Then ExitLoop Next If $Potions[3][$rScan] = "m" Then Send("4") $LastDrinkMana=TimerInit() $Potions[3][$rScan] = " " EndIf EndIf Return 0 EndFunc "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Share this post Link to post Share on other sites
czardas 1,269 Posted July 20, 2010 (edited) I know why. Run this code. For $rScan=0 to 3 MsgBox(0, "", $rScan) Next MsgBox(0, "", $rScan) It seems the loop repeats until $rScan = 4 Ah! Bowmore beat me to it. So you need to subtract 1 from $rScan at the appropriate places to get the expected result. I think it had too many portions of chicken. Edited July 20, 2010 by czardas operator64 ArrayWorkshop Share this post Link to post Share on other sites
Makalele 0 Posted July 20, 2010 Hell yeah, it was it ^^ Thanks!! T/C Share this post Link to post Share on other sites