Jump to content

Exit a function?


Recommended Posts

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
Link to comment
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
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...