question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Capturing random responses in the "previous" (%) command

See original GitHub issue

I have a question about rivescript syntax in general. Please do point me to a more suitable platform if this is meant to be for discussing issues specific to the js interpeter.

I’d like to use the % command, but my previous trigger has multiple responses. My first hunch was to use a redirect, but this doesn’t work:

+ hello
- Hi!
- Such a nice day
- How are you?

+ *
% {@ hello}
- Feeling great.

The only way I can figure it out is to have a separate trigger-previous block for each of the three random responses to “hello”:

+ *
% hi
- Feeling great.

+ *
% such a nice day
- Feeling great

+ *
% how are you
- Feeling great

Is there a nicer approach to this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kirslecommented, Mar 2, 2017

Use an alternation group in the %Previous like you can with +Trigger:

+ *
% (hi|such a nice day|how are you)
- Feeling great
0reactions
dcsancommented, Mar 12, 2017

maybe you can break into separate topics? I find we don’t use the % operator as much here, as it’s sometimes less clear to read the code later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shell programming: Select random line from command output
srand() seeds the random generator, and rand() returns a random float >= 0 and < 1; ... shuf selects random directory from your...
Read more >
Tutorial - RiveScript.com
Getting random responses is as easy as entering multiple Response commands for the same trigger. To see this in action, open your hello.rive ......
Read more >
Panel Data Analysis Fixed and Random Effects using Stata
The Stata command to run fixed/random effecst is xtreg. Before using xtreg you need to set Stata to handle panel data by using...
Read more >
Lots of Ways to Use Math.random() in JavaScript - CSS-Tricks
Math.random() is an API in JavaScript. It is a function that gives you a random number. The number returned will be between 0...
Read more >
Controlling Random Number Generation - MathWorks
This example shows how to use the rng function, which provides control over random number generation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found