Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you make a while loop that does not check the loop condition continuously? #23

Closed
kaphula opened this issue Nov 4, 2023 · 0 comments

Comments

@kaphula
Copy link
Collaborator

kaphula commented Nov 4, 2023

How do you make a while loop that does not check the loop condition continuously? It seems that when you create a loop with While, the condition for the While is checked between each behavior. Sometimes what you want is for the behaviours to run and succeed in sequence order before the condition for the upper While is ran to determine if the While block should continue executing another loop, basically just like it is with any programming language and its while loop.

        let loop1 = While(
            Box::new(Action(Self::LoopCondition)),
            vec![ Action(Self::Task1), Action(Self::Task2) ]
        );

This is what happens:

  1. check loop condition (running)
  2. run Task1 (running)
  3. check loop condition (running)
  4. run Task1 (success)
  5. check loop condition (success)
  6. while is terminated

And this is what I want:

  1. check loop condition (running)
  2. run Task1 (running)
  3. run Task1 (success)
  4. run Task2 (success)
  5. check loop condition (success)
  6. while is terminated

I also tried to throw Sequence as a wrapper, but the While still keeps checking the condition between each behavior.

        let loop2 = While(
            Box::new(Action(Self::LoopCondition)),
            vec![
                Sequence(vec![Action(Self::Task1), Action(Self::Task2)])
            ],
        );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants