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 does 'return' work from conditionals? #48

Closed
dcsan opened this issue Aug 3, 2019 · 5 comments
Closed

how does 'return' work from conditionals? #48

dcsan opened this issue Aug 3, 2019 · 5 comments

Comments

@dcsan
Copy link

dcsan commented Aug 3, 2019

sometimes when a conditional matches a response, the conversation will seem to return and continue.
but other times it does not. I can't quite figure out the logic.

given this example

on bubbles

~ start
< start
  [intro]
~ [colors]
~ [ending]

~ colors
< Whats your favorite color?
---
  > red
  < roses are red
---
  > blue
  < sky is blue
---
> *{color}
< you like $color

= intro
- Let's begin

~ ending
< Thanks and goodnight.

> reset
~ [start]

image

@dcsan
Copy link
Author

dcsan commented Aug 3, 2019

as in the above example,
if the match is in one of the conditions
it will not 'return'

---
  > red
  < roses are red

but if the reply is caught as the default/bottom entry of the logic block, then the code will return and continue, it seems.

---
> *{color}
< you like $color

image

@dcsan
Copy link
Author

dcsan commented Aug 3, 2019

perhaps things would be better if there was a more explicit @ return or some type of keyword like that?

@arnaud
Copy link
Collaborator

arnaud commented Aug 5, 2019

You'll find the reasoning behind conditional, and some examples, in this post:
#42 (comment)

The only way I can think of right now, for addressing your example, would go like this:

~ start
< start
  [intro]
~ [colors]
~ [ending]

~ colors
< Whats your favorite color?
> *{color}
< you like $color
\`\`\`
if ($color === 'blue') {
  context.say('sky is blue')
}
\`\`\`

= intro
- Let's begin

~ ending
< Thanks and goodnight.

> reset
~ [start]

▶ Play this script

@codenametype
Copy link
Contributor

codenametype commented Aug 20, 2019

Hi!
Sorry for the very late response.
According documentation Conditional branching please look on the last example and "jump_to" feature you could jump from a condition to the end of current dialogue.
▶ Play this script

Example:

~ start
< start
  [intro]
~ [colors]
~ [ending]

~ colors
< Whats your favorite color?
> *{color}
---
  ` /red/.test('$color')
  < roses are red
  ~ [end]
---
  ` /blue/.test('$color')
  < sky is blue
  ~ [end]
---
< you like $color
~ end

= intro
- Let's begin

~ ending
< Thanks and goodnight.

> reset
~ [start]

Hope it helps you.

@arnaud
Copy link
Collaborator

arnaud commented Oct 6, 2019

Hi. I'm assuming the latest answer was useful, and this ticket closed.

Do not hesitate to reach again if not,

@arnaud arnaud closed this as completed Oct 6, 2019
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

3 participants