Jump to content
Sign in to follow this  
furian

While loops and IsPressed function

Recommended Posts

Hey all, I'm looking for a way to make this a little smarter. This while loops works almost like I want, except for one thing.  I would like it to start over from the beginning if F6 is released, then held down again.

While 1
    if _IsPressed(75) then
        DoStuff1()
    EndIf
    if _IsPressed(75) then
        DoStuff2()
    EndIf
    if _IsPressed(75) then
        DoStuff3()
    EndIf
Wend


I tried the following, however, this will cycle through each function even if the F6 key is released midway, which I don't want.

While 1
    if _IsPressed(75) then
        DoStuff1()
        DoStuff2()
        DoStuff3()
    EndIf
Wend

Basically, if F6 is held down, begin cycling through the functions, however, if it is released, stop immediately.  If it is pressed down again, start from the beginning.

Any help is appreciated!

Share this post


Link to post
Share on other sites
While 1
    Sleep (50) ; reduce impact on CPU
    if not _IsPressed(75) then ContinueLoop
    DoStuff1()
    if not _IsPressed(75) then ContinueLoop
    DoStuff2()
    if not _IsPressed(75) then ContinueLoop
    DoStuff3()
Wend

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...