Jump to content
Sign in to follow this  
jebus495

Preventing a recursion error...

Recommended Posts

jebus495

Hi there.

I've been getting "Recursion level has been exceeded - AutoIt will quit to prevent stack overflow." but only sometimes.

It occurs in this part of my script.

Func checkhp ()
$ranphp = random (-8 , 8)
$phpcheck = IniRead("autoslasher.ini","Values","hpcheckYvalue","NONE SET")
$php = PixelGetColor( 309 +$ranphp, $phpcheck )
$ranchecksleep = random (1000 , 2000)

MouseMove ( 309 +$ranphp, $phpcheck )
    
    If $php = 0xFFFFFF Then
        Sleep (2000+$ranchecksleep)
        checkhp ()
    EndIf
lootseq ()
EndFunc

What I want this to do is wait for a certain color ($php) to turn into something that isn't white before it proceeds. This can take up to a couple minutes sometimes but I need it to check very often.

This works perfect if it doesn't need to wait long for that color to change but it is otherwise causing errors. How could I change things to prevent this error?

Share this post


Link to post
Share on other sites
PsaltyDS

Hi there.

I've been getting "Recursion level has been exceeded - AutoIt will quit to prevent stack overflow." but only sometimes.

It occurs in this part of my script.

Func checkhp ()
$ranphp = random (-8 , 8)
$phpcheck = IniRead("autoslasher.ini","Values","hpcheckYvalue","NONE SET")
$php = PixelGetColor( 309 +$ranphp, $phpcheck )
$ranchecksleep = random (1000 , 2000)

MouseMove ( 309 +$ranphp, $phpcheck )
    
    If $php = 0xFFFFFF Then
        Sleep (2000+$ranchecksleep)
        checkhp ()
    EndIf
lootseq ()
EndFunc

What I want this to do is wait for a certain color ($php) to turn into something that isn't white before it proceeds. This can take up to a couple minutes sometimes but I need it to check very often.

This works perfect if it doesn't need to wait long for that color to change but it is otherwise causing errors. How could I change things to prevent this error?

Try more like this:
Func checkhp()
    Local $ranphp, $phpcheck, $php
    
    While 1
        $ranphp = Random(-8, 8)
        $phpcheck = IniRead("autoslasher.ini", "Values", "hpcheckYvalue", "NONE SET")
        $php = PixelGetColor(309 + $ranphp, $phpcheck)
        
        MouseMove(309 + $ranphp, $phpcheck)

        If $php = 0xFFFFFF Then
            Sleep(Random(3000, 4000, 1))
        Else
            ExitLoop
        EndIf
    WEnd
    
    lootseq()
EndFunc  ;==>checkhp

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×