Jump to content

Error: Subscript used with non-Array variable.


Recommended Posts

I have a bit of script that goes like this:

CODE
AutoItSetOption("ColorMode", 1)

AutoItSetOption("MouseCoordMode", 0)

AutoItSetOption("PixelCoordMode", 0)

HotKeySet("{ESC}", "KillScript")

Const $GenSleep = 450

Const $Blue = 16759444

Const $LGreen = 9240485

Dim $Confirm = 0

Global $Col

Func CheckBlock($BColor)

$Block = PixelSearch(0,35,790,550,$BColor,0,1)

If IsArray($Block) Then

If (PixelGetColor($Block[0] + 10,$Block[1]) = $BColor) And (PixelGetColor($Block[0] + 20,$Block[1]) = $BColor) Then

$Confirm = 1

EndIf

EndIf

EndFunc

$GlobalT = TimerInit()

Sleep(200)

Right()

Func Right()

$Confirm = 0

Do

MouseMove(799,300,0)

Sleep($GenSleep)

MouseClick("Right")

CheckBlock($Blue)

Until ($Confirm = 1) Or (TimerDiff($GlobalT) > 40000)

ToDac()

EndFunc

Func ToDac()

$Confirm = 0

Do

MouseMove(799,466,0)

Sleep($GenSleep)

MouseClick("Right")

Sleep($GenSleep)

$Col = PixelSearch(3,340,790,550,$LGreen,0,1)

If IsArray($Col) Then

If PixelGetColor($Col[0] + 25,$Col[1] - 215) = $Blue Then

ExitLoop

EndIf

EndIf

Until TimerDiff($GlobalT) > 20000

Position()

EndFunc

Func Position()

MouseMove($Col[0] - 100,$Col[1] + 100,0)

Sleep($GenSleep + 100)

MouseClick("Right")

EndFunc

Func KillScript()

Exit(1)

EndFunc

Exit(1)

Now, near the bottom there's a part that goes "MouseMove($Col[0] - 100,$Col[1] + 100,0)", and when the script is used, an AutoIt error message pop-up window that says:

Line 58 (File "C:\Program Files(x86)\mm.bot\scripts\bosses\TeleToDac.a3u"):

MouseMove($Col[0] - 100,$Col[1] + 100,0)

MouseMove($Col^ ERROR

Error: Subscript used with non-Array variable.

Can anyone tell me why this is happening or how to re-write the script to make it work? I've even tried using an older version of autoit (3.2.2.0), but still the same thing happens.
Link to comment
Share on other sites

I have a bit of script that goes like this:

CODE
AutoItSetOption("ColorMode", 1)

AutoItSetOption("MouseCoordMode", 0)

AutoItSetOption("PixelCoordMode", 0)

HotKeySet("{ESC}", "KillScript")

Const $GenSleep = 450

Const $Blue = 16759444

Const $LGreen = 9240485

Dim $Confirm = 0

Global $Col

Func CheckBlock($BColor)

$Block = PixelSearch(0,35,790,550,$BColor,0,1)

If IsArray($Block) Then

If (PixelGetColor($Block[0] + 10,$Block[1]) = $BColor) And (PixelGetColor($Block[0] + 20,$Block[1]) = $BColor) Then

$Confirm = 1

EndIf

EndIf

EndFunc

$GlobalT = TimerInit()

Sleep(200)

Right()

Func Right()

$Confirm = 0

Do

MouseMove(799,300,0)

Sleep($GenSleep)

MouseClick("Right")

CheckBlock($Blue)

Until ($Confirm = 1) Or (TimerDiff($GlobalT) > 40000)

ToDac()

EndFunc

Func ToDac()

$Confirm = 0

Do

MouseMove(799,466,0)

Sleep($GenSleep)

MouseClick("Right")

Sleep($GenSleep)

$Col = PixelSearch(3,340,790,550,$LGreen,0,1)

If IsArray($Col) Then

If PixelGetColor($Col[0] + 25,$Col[1] - 215) = $Blue Then

ExitLoop

EndIf

EndIf

Until TimerDiff($GlobalT) > 20000

Position()

EndFunc

Func Position()

MouseMove($Col[0] - 100,$Col[1] + 100,0)

Sleep($GenSleep + 100)

MouseClick("Right")

EndFunc

Func KillScript()

Exit(1)

EndFunc

Exit(1)

Now, near the bottom there's a part that goes "MouseMove($Col[0] - 100,$Col[1] + 100,0)", and when the script is used, an AutoIt error message pop-up window that says:

Can anyone tell me why this is happening or how to re-write the script to make it work? I've even tried using an older version of autoit (3.2.2.0), but still the same thing happens.

You have already used the solution in your code.

$Col = PixelSearch(3,340,790,550,$LGreen,0,1)
        If IsArray($Col) Then

so in your Position() function you could have

If not IsArray($Col) then return

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...