-
Notifications
You must be signed in to change notification settings - Fork 162
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 to make the scene say something different each time? #68
Comments
You could create the whole scenario once by adding each offers in a random order, something like: // offers = list of strings
// random = function that returns a random int between min and max
while (offers.length) {
var randomIndex = random(0, offers.length);
var randomOffer = offers.splice(randomIndex, 1);
theater.addScene('jjbot:' + randomOffer);
}
// Add a replay scene to loop over the scenario
// when all ofers have been written
theater.addScene(theater.replay); And then, you could stop the scenario after each scene and wait for the user to click the element to play the next scene. Let me know if that works for you. |
@zhouzi thanks for your help on this! I'm stuck on the |
I made a jsfiddle with comments: jsfiddle.net/2bu4h9v5. It should clear things up 👍 |
This definitely helps. |
Here is my code (using JavaScript and Jinja templating):
Basically every time an element is clicked, it runs
theater.play()
. The problem is, I would like it, if clicked again, to say something different (i.e. a different string inrand
). I've tried doingtheater.replay()
but it only keeps displaying the same text. Is there a way to do this? Thanks!The text was updated successfully, but these errors were encountered: