Jump to content
Sign in to follow this  
Nico401

Script error

Recommended Posts

Nico401

Hello,

I am French so I will tray to have a good English :

When I execute :

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.4.9
 Author: Lassaux Nicolas

 Script Function:
    
#ce ----------------------------------------------------------------------------

AutoItSetOption("RunErrorsFatal", 0)
AutoItSetOption("MouseCoordMode", 0)
AutoItSetOption("PixelCoordMode", 0)

; ------------------------------------------------------------------------------
;                               Ouvre Dofus
;-------------------------------------------------------------------------------

WinActivate("Dofus"); ouvre dofus.

;-------------------------------------------------------------------------------
;                            S'occupe de faucher
;-------------------------------------------------------------------------------

Func Fauchage()
    $ble = PixelSearch ( 0,0,1279,1023, 0xE7C72C, 4 );cherche couleur du blé.
    MouseClick( "", $ble[0], $ble[1], 1, 0 );clique sur la couleur du blé.
    Sleep (500)
    MouseClick( "left", $ble[0]+44, $ble[1]+50, 1, 0);clique sur faucher.
    Sleep (14000)
EndFunc
;-------------------------------------------------------------------------------
;                    S'occupe de refuser un défi/échange
;-------------------------------------------------------------------------------

Func Defi()                 
    MouseClick("", 803, 471, 1, 0);si il y a un defi ,le refuser.
EndFunc

;-------------------------------------------------------------------------------
;                     S'occupe du passage au niveau sup.
;-------------------------------------------------------------------------------

Func Niveau()
    MouseClick("", 675, 456, 1, 0); si il y a le passage a niveau cliquer dessus.
EndFunc

;-------------------------------------------------------------------------------
;                              S'occupe du BIP
;-------------------------------------------------------------------------------

func Bip()
    SoundPlay("blip.wav")
endfunc

;-------------------------------------------------------------------------------
;                              S'occupe du combat
;-------------------------------------------------------------------------------


Func Combat()
    MouseClick("", 1179, 732, 1, 0);clique sur passer.
    Sleep (1000);a enlever
EndFunc

;-------------------------------------------------------------------------------

$loop = True
while $loop == True
    
$combat = PixelGetColor( 1200, 943 ); detection du conteur.
$combat = Hex($combat, 6)   

$niveau = PixelGetColor( 635,458 ); detection du bouton passer.
$niveau = Hex($niveau, 6);passage en hexa

$defi = PixelGetColor( 927, 324 ); detection du bouton defi.
$defi = Hex($defi, 6);passage en hexa
    
    If $combat = 'BEB998' Then  Call ("Fauchage")
    If $combat = '312737' Then Call ("Bip")
    If $defi = 'FFFFFF' Then Call ("Defi")
    If $niveau = 'FF6100' Then Call ("Niveau")
    Sleep(100)
WEnd

Autoit shows :

C:\Documents and Settings\utilisateur\Bureau\Mon Macro.au3 (43) : ==> Subscript used with non-Array variable.: 
MouseClick( "", $ble[0], $ble[1], 1, 0 ) 
MouseClick( "", $ble^ ERROR
>Exit code: 1   Time: 140.091

Can I Prevent it without changing the execution ?

Thank you.

Nico401

Edited by Nico401

Share this post


Link to post
Share on other sites
Gif

i think you should this, because pixelsearch searches for pixels of the given color and if it does not find it, it returns an ERROR else it returns the x,y coordinates of the pixel.....(if you want to search for that pixel until it is visible then put it in a loop)

Func Fauchage()
    $ble = PixelSearch ( 0,0,1279,1023, 0xE7C72C, 4 );cherche couleur du blé.
    If Not @ERROR Then
    MouseClick( "", $ble[0], $ble[1], 1, 0 );clique sur la couleur du blé.
    Sleep (500)
    MouseClick( "left", $ble[0]+44, $ble[1]+50, 1, 0);clique sur faucher.
    Sleep (14000)
    EndIf
EndFunc
Edited by Gif

Share this post


Link to post
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
Sign in to follow this  

×