Sign in to follow this  
Followers 0
Shanlar

Exit a function?

2 posts in this topic

I need my script to exit the current function if the nested function being called returns 1. How would i got about doing this? The nested function returning 1 is Login_Screen_Detection.

Func Target()
    Call("Login_Screen_Detection")
    WTL("Selecting Target")
    WinActivate("last")
    MouseClick("left", $target1_x, $target1_y)
    Sleep(1000)
    MouseClick("left", $target2_x, $target2_y)
    WTL("Moving to Target")
    Do
        WinActivate("last")
        Call("Login_Screen_Detection")
    Until Warp_Detection($warp_max_x) = 1
    WTL("Moving to Target Successful")
    Sleep(3000)
    WTL("Waiting to Slow Down")
    Do
        WinActivate("last")
        Call("Login_Screen_Detection")
    Until Warp_Detection($warp_min_x) = 0 And Warp_Detection($warp_max_x) = 0
    WTL("Slow Down Successful")
    WTL("Locking onto Target and Activating Lasers")
    MouseClick("left", $target3_x, $target3_y)
    Sleep(500)
    Send("{F1}")
    Send("{F2}")
    Send("{F3}")
EndFunc  ;==>Target

Share this post


Link to post
Share on other sites



Got it working, just put a While loop on it.

Func Target()
    While 1
        If Call("Login_Screen_Detection") = 1 Then
            ExitLoop
        EndIf
        WTL("Selecting Target")
        WinActivate("last")
        MouseClick("left", $target1_x, $target1_y)
        Sleep(1000)
        MouseClick("left", $target2_x, $target2_y)
        WTL("Moving to Target")
        Do
            WinActivate("last")
            If Call("Login_Screen_Detection") = 1 Then
                ExitLoop 2
            EndIf
        Until Warp_Detection($warp_max_x) = 1
        WTL("Moving to Target Successful")
        Sleep(3000)
        WTL("Waiting to Slow Down")
        Do
            WinActivate("last")
            If Call("Login_Screen_Detection") = 1 Then
                ExitLoop 2
            EndIf
        Until Warp_Detection($warp_min_x) = 0 And Warp_Detection($warp_max_x) = 0
        WTL("Slow Down Successful")
        WTL("Locking onto Target and Activating Lasers")
        MouseClick("left", $target3_x, $target3_y)
        Sleep(500)
        Send("{F1}")
        Send("{F2}")
        Send("{F3}")
        ExitLoop
    WEnd
EndFunc  ;==>Target

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  
Followers 0