I was wondering if anyone could tell me why I am getting an error that states
line 146 (File "C......)
if $synthtabxy[0]=0 or $synthtabxy[1]=0 Then
$synthtabxy=^Error
Error: subscript used with non-array variable
and clearly I am using an array variable on line 56
$synthtabxy[2]
any help would be appreciated.
P.S. please dont say i should use images, the whole point of this bot is to use nothing but user defined coordinates. here is the script( and yes i know i have extra variables and arrays. i copied this script from another script i have and i just havent finished it yet. )
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Find\Images\gui\splash.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=EgoFeeder
#AutoIt3Wrapper_Res_Description=EgoFeeder
#AutoIt3Wrapper_Res_Fileversion=2.9.0.84
#AutoIt3Wrapper_Res_LegalCopyright=ShaggyZE
#AutoIt3Wrapper_Res_requestedExecutionLevel=requir eAdministrator
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Region Header
#include-once
#include <ImageSearch.au3>
#include <WinAPI.au3>
#include <TestArea.au3>
#include <Misc.au3>
HotKeySet("{DELETE}", "_Exit")
HotKeySet("{q}", "_Exit")
HotKeySet("{Esc}","_Exit")
If Not WinActive("[CLASS:Mabinogi]") Then WinActivate("[CLASS:Mabinogi]")
; coordinates of "is " not sure why I'm storing this
Global $hcoordx, $hcoordy ; coordinates for "is hungry"
Global $shopx, $shopy ; coordinates for shop button
Global $tabx, $taby ; coordinates for shop tab
Global $tabxy[2] ; coordinates for shop tab
Global $itemxy[2]; coordinates of the feed item
Global $buyx, $buyy ; coordinates of the buy button
Global $spacex, $spacey ; coordinates of the space to put feeding item into
Global $endconvox, $endconvoy ; location of "end conversation"
Global $givex, $givey ; location of "give item"
Global $continuey,$continuex ; location of "continue"
Global $feedx, $feedy ; location of #1 slot item to be fed
Global $okayx, $okayy ; location of "okay"
Global $equipxy[2] ;location of the equipslot 1 button
Global $topleftcorner[2]
Global $bottomrightcorner[2]
Global $center[2]
Global $windowSize[4]
Global $found
Global $steamxy[2]
Global $crystalonexy[2]
Global $okbuttononexy[2]
Global $crystaltwoxy[2]
Global $okbuttontwoxy[2]
Global $crystalthreexy[2]
Global $okbuttonthreexy[2]
Global $okbuttonfourxy[2]
Global $slotonexy[2]
Global $placementslottwoxy[2]
Global $placementslotthreexy[2]
Global $synthtabxy[2]
Global $result
Global $feedcount
Global $count
Global $scan
Global $result
Global $mustcontinue, $mustcontinuex, $mustcontinuey
Global $hFunc,$pFunc,$hHook,$hMod
Global Const $VK_DELETE = 0x2E, $VK_END = 0x23
If ProcessExists ("Client.exe") = False Then
ToolTip ("Error: Mabinogi Not Detected." & @CRLF & "Closing...", 0, @DesktopHeight - 70, $Title1)
Sleep (3000)
Exit 1
EndIf
$hFunc = DllCallbackRegister('_KeyboardHook', 'lresult', 'int;uint;uint')
$pFunc = DllCallbackGetPtr($hFunc)
$hMod = _WinAPI_GetModuleHandle(0)
$hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, $pFunc, $hMod)
If Not WinActive (WinGetTitle("[CLASS:Mabinogi]")) Then Winactivate (WinGetTitle("[CLASS:Mabinogi]"))
WinWaitActive (WinGetTitle("[CLASS:Mabinogi]"))
Sleep (2000)
$count = 0
GetWindowSize()
;================================================= ==================================
Func GetWindowSize()
; gets info of Mabinogi and stores them into a 4 element array
$windowSize=WinGetPos(WinGetTitle("[CLASS:Mabinogi]"))
; determines specIfic locations
If IsArray($windowSize) Then
$topleftcorner[0] =$windowSize[0]
$topleftcorner[1] = $windowSize[1]
$bottomrightcorner[0] =$windowSize[2]
$bottomrightcorner[1] = $windowSize[3]
$center[0]=($topleftcorner[0] + $bottomrightcorner[0]) / 2
$center[1]=(($topleftcorner[1] + $bottomrightcorner[1]) / 2) - 50
steam()
Else
$windowSize=WinGetClientSize(WinGetTitle("[CLASS:Mabinogi]"))
$topleftcorner[0] =1
$topleftcorner[1] = 1
$bottomrightcorner[0] =$windowSize[0]
$bottomrightcorner[1] = $windowSize[1]
$center[0]=($topleftcorner[0] + $bottomrightcorner[0]) / 2
$center[1]=(($topleftcorner[1] + $bottomrightcorner[1]) / 2) - 50
steam()
EndIf
EndFunc
While $count <= 100
sleep(1000)
steam()
WEnd
;================================================= ==================================
func steam()
if $steamxy[0]=0 or $steamxy[1]=0 Then
$steamxy=_GETXYSTEAM("hover over the dry oven and press the 'a' key")
synthtab()
Else
sleep(500)
mousemove($steamxy[0],$steamxy[1],0)
sleep(500)
mouseclick("primary",$steamxy[0],$steamxy[1],1)
synthtab()
EndIf
EndFunc
Func _GetXYSTEAM($message)
HotKeySet("a","_DoNothing")
While Not _IsPressed('41')
Local $currCoord = MouseGetPos()
Sleep(10)
ToolTip($message & @CRLF & "Dry Oven coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
While _IsPressed('41')
return MouseGetPos()
$steamxy = $currCoord
synthtab()
WEnd
ExitLoop 1
EndIf
WEnd
EndFunc
;================================================= ==================================
func synthtab()
if $synthtabxy[0]=0 or $synthtabxy[1]=0 Then
$synthtabxy=_SYNTHTABXY("hover over the synthesis tab and press the 'a' key")
crystalone()
Else
sleep(500)
mousemove($synthtabxy[0],$synthtabxy[1],0)
sleep(500)
mouseclick("primary",$synthtabxy[0],$synthtabxy[1],1)
crystalone()
EndIf
EndFunc
func _SYNTHTABXY($message)
hotkeyset("a","_DoNothing")
while Not _IsPressed('41')
local $currCoord = mousegetpos()
sleep(10)
ToolTip($message & @CRLF & "Synthesis Tab coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
While
return mousegetpos()
$synthtabxy = $currCoord
crystalone()
WEnd
ExitLoop 2
EndIf
WEnd
EndFunc
;================================================= ==================================
func crystalone()
if $crystalonexy[0]=0 or $crystalonexy[1]=0 Then
$crystalonexy=CRYSTALONEXY("hover over the first crystal and press the 'a' key")
Else
sleep(500)
mousemove($crystalonexy[0],$crystalonexy[1],0)
sleep(500)
Send("{ShiftDown}")
sleep(500)
mouseclick("primary",$crystalonexy[0],$crystalonexy[1],1)
Send("{ShiftUp}")
okbuttonone()
EndIf
EndFunc
FUNC CRYSTALONEXY($message)
HotKeySet("a","_DoNothing")
While Not _IsPressed('41')
Local $currCoord = MouseGetPos()
Sleep(10)
ToolTip($message & @CRLF & "First Crystal Coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
while _IsPressed('41')
return MouseGetPos()
$crystalonexy = $currCoord
okbuttonone()
WEnd
exitLoop 3
EndIf
WEnd
EndFunc
;================================================= ==================================
Func okbuttonone()
if $okbuttononexy[0]=0 or $okbuttononexy[1]=0 Then
$okbuttononexy=OKBUTTONONEXY("hover over the first ok button and press the 'a' key")
Else
sleep(500)
mousemove($okbuttononexy[0], $okbuttononexy[1],0)
sleep(500)
mouseclick("primary",$okbuttononexy[0],$okbuttononexy[1],1)
placementslotone()
EndIf
EndFunc
Func OKBUTTONONEXY($message)
Hotkeyset("a","_DoNothing")
While Not _IsPressed('41')
Local $currCoord = MouseGetPos()
Sleep(10)
ToolTip($message & @CRLF & "First OK Button Coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
while _IsPressed('41')
return mousegetpos()
$okbuttononexy = $currCoord
placementslotone()
WEnd
exitloop 4
EndIf
WEnd
EndFunc
;================================================= ==================================
func placementslotone()
if $slotonexy[0]=0 or $slotonexy[1]=0 Then
$slotonexy=PLACEMENTSLOTONEXY("hover over the first placement slot and press the 'a' key")
Else
sleep(500)
mousemove($slotonexy[0],$slotonexy[1],0)
sleep(500)
mouseclick("primary",$slotonexy[0],$slotonexy[1],1)
crystaltwo()
EndIf
EndFunc
Func PLACEMENTSLOTONEXY($message)
Hotkeyset("a","_DoNothing")
While Not _IsPressed('41')
Local $currCoord = MouseGetPos()
Sleep(10)
ToolTip($message & @CRLF & "First Placement Slot Coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
while _IsPressed('41')
return mousegetpos()
$slotonexy = $currCoord
crystaltwo()
WEnd
exitloop 5
EndIf
WEnd
EndFunc
;================================================= ==================================
func crystaltwo()
if $crystaltwoxy[0]=0 or $crystaltwoxy[1]=0 Then
$crystaltwoxy=CRYSTALTWOXY("hover over the second crystal and press the 'a' key")
Else
sleep(500)
mousemove($crystaltwoxy[0], $crystaltwoxy[1],0)
Send("{ShiftDown}")
sleep(500)
mouseclick("primary",$crystaltwoxy[0],$crystaltwoxy[1],1)
Send("{ShiftUP}")
okbuttontwo()
EndIf
EndFunc
Func CRYSTALTWOXY($message)
Hotkeyset("a","_DoNothing")
While Not _IsPressed('41')
Local $currCoord = MouseGetPos()
Sleep(10)
ToolTip($message & @CRLF & "Second Crystal Coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
while _IsPressed('41')
return mousegetpos()
$crystaltwoxy = $currCoord
okbuttontwo()
WEnd
exitloop 5
EndIf
WEnd
EndFunc
;================================================= ==================================
func okbuttontwo()
if $okbuttontwoxy[0]=0 or $okbuttontwoxy[1]=0 Then
$okbuttontwoxy=OKBUTTONTWOXY("hover over the second ok button and press the 'a' key")
Else
sleep(500)
mousemove($okbuttontwoxy[0], $okbuttontwoxy[1],0)
sleep(500)
mouseclick("primary",$okbuttontwoxy[0],$okbuttontwoxy[1],1)
placementslottwo()
EndIf
EndFunc
Func OKBUTTONTWOXY($message)
Hotkeyset("a","_DoNothing")
While Not _IsPressed('41')
Local $currCoord = MouseGetPos()
Sleep(10)
ToolTip($message & @CRLF & "Second OK Button Coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
while _IsPressed('41')
return mousegetpos()
$okbuttontwoxy = $currCoord
placementslottwo()
WEnd
exitloop 6
EndIf
WEnd
EndFunc
;================================================= ==================================
func placementslottwo()
if $placementslottwoxy[0]=0 or $placementslottwoxy[1]=0 Then
$placementslottwoxy=PLACEMENTSLOTTWOXY("hover over the second placement slot and press the 'a' key")
Else
sleep(500)
mousemove($placementslottwoxy[0],$placementslottwoxy[1],0)
sleep(500)
mouseclick("primary",$placementslottwoxy[0],$placementslottwoxy[1],1)
crystalthree()
EndIf
EndFunc
Func PLACEMENTSLOTTWOXY($message)
Hotkeyset("a","_DoNothing")
While Not _IsPressed('41')
Local $currCoord = MouseGetPos()
Sleep(10)
ToolTip($message & @CRLF & "Second Placement Slot Coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
while _IsPressed('41')
return mousegetpos()
$placementslottwoxy = $currCoord
crystalthree()
WEnd
exitloop 7
EndIf
WEnd
EndFunc
;================================================= ==================================
func crystalthree()
if $crystalthreexy[0]=0 or $crystalthreexy[1]=0 Then
$crystalthreexy=CRYSTALTHREEXY("hover over the third crystal and press the 'a' key")
Else
sleep(500)
mousemove($crystalthreexy[0], $crystalthreexy[1],0)
Send("{ShiftDown}")
sleep(500)
mouseclick("primary",$crystalthreexy[0],$crystalthreexy[1],1)
Send("{ShiftUP}")
okbuttonthree()
EndIf
EndFunc
Func CRYSTALTHREEXY($message)
Hotkeyset("a","_DoNothing")
While Not _IsPressed('41')
Local $currCoord = MouseGetPos()
Sleep(10)
ToolTip($message & @CRLF & "Third Crystal Coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
while _IsPressed('41')
return mousegetpos()
$crystalthreexy = $currCoord
okbuttonthee()
WEnd
exitloop 8
EndIf
WEnd
EndFunc
;================================================= ==================================
func okbuttonthree()
if $okbuttonthreexy[0]=0 or $okbuttonthreexy[1]=0 Then
$okbuttonthreexy=OKBUTTONTHREEXY("hover over the third ok button and press the 'a' key")
Else
sleep(500)
mousemove($okbuttonthreexy[0], $okbuttonthreexy[1],0)
sleep(500)
mouseclick("primary",$okbuttonthreexy[0],$okbuttonthreexy[1],1)
placementslotthree()
EndIf
EndFunc
Func OKBUTTONTHREEXY($message)
Hotkeyset("a","_DoNothing")
While Not _IsPressed('41')
Local $currCoord = MouseGetPos()
Sleep(10)
ToolTip($message & @CRLF & "Third OK Button Coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
while _IsPressed('41')
return mousegetpos()
$okbuttonthreexy = $currCoord
placementslotthree()
WEnd
exitloop 9
EndIf
WEnd
EndFunc
;================================================= ==================================
func placementslotthree()
if $placementslotthreexy[0]=0 or $placementslotthreexy[1]=0 Then
$placementslotthreexy=PLACEMENTSLOTTHREEXY("hover over the third placement slot and press the 'a' key")
Else
sleep(500)
mousemove($placementslotthreexy[0],$placementslotthreexy[1],0)
sleep(500)
mouseclick("primary",$placementslotthreexy[0],$placementslotthreexy[1],1)
okbuttonfour()
EndIf
EndFunc
Func PLACEMENTSLOTTHREEXY($message)
Hotkeyset("a","_DoNothing")
While Not _IsPressed('41')
Local $currCoord = MouseGetPos()
Sleep(10)
ToolTip($message & @CRLF & "Third Placement Slot Coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
while _IsPressed('41')
return mousegetpos()
$placementslotthreexy = $currCoord
okbuttonfour()
WEnd
exitloop 10
EndIf
WEnd
EndFunc
;================================================= ==================================
func okbuttonfour()
if $okbuttonfourxy[0]=0 or $okbuttonfourxy[1]=0 Then
$okbuttonfourxy=OKBUTTONFOURXY("hover over the fourth ok button and press the 'a' key")
Else
sleep(500)
mousemove($okbuttonfourxy[0], $okbuttonfourxy[1],0)
sleep(500)
mouseclick("primary",$okbuttonfourxy[0],$okbuttonfourxy[1],1)
EndIf
EndFunc
Func OKBUTTONFOURXY($message)
Hotkeyset("a","_DoNothing")
While Not _IsPressed('41')
Local $currCoord = MouseGetPos()
Sleep(10)
ToolTip($message & @CRLF & "Fourth OK Button Coord: " & $currCoord[0] & "," & $currCoord[1])
If _IsPressed('41') Then
while _IsPressed('41')
return mousegetpos()
$okbuttonfourxy = $currCoord
WEnd
exitloop 11
EndIf
WEnd
sleep(5000)
$count = $count + 1
EndFunc
;================================================= ==================================
Func _DoNothing()
EndFunc
;================================================= ==================================
Func _KeyboardHook($iCode, $iwParam, $ilParam)
Local $tKBDLLHS = DllStructCreate($tagKBDLLHOOKSTRUCT, $ilParam)
Local $iVkCode
If $iCode > -1 Then
$iVkCode = DllStructGetData($tKBDLLHS, 'vkCode')
If $iwParam = $WM_KEYUP Then
Switch $iVkCode
Case $VK_DELETE
Exit 0
Case $VK_END
Exit 0
EndSwitch
EndIf
EndIf
Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
EndFunc
;================================================= ==================================
Func _Exit()
Exit 0
EndFunc
;================================================= ==================================






