Published
Edited
Feb 22, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
nextScene = {
let option = 0;
// console.log(scenes[currentScene]); // for debugging
for (let option = 1; option < scenes[currentScene].options.length; option++) {
if (input == scenes[currentScene].options[option]) {
mutable currentScene = `${currentScene}${option}`;
break;
}
}
// the following code does the same thing !
//
// switch (input) {
// case scenes[currentScene].options[0]:
// return "Still waiting";
// case scenes[currentScene].options[1]:
// option = 1;
// break;
// case scenes[currentScene].options[2]:
// option = 2;
// break;
// case scenes[currentScene].options[3]:
// option = 3;
// break;
// default:
// return "Still waiting";
// }
// mutable currentScene = `${currentScene}${option}`;
return option > 0
? `Going to the next scene with option ${option}.`
: awaitInput;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
scenes = ({
scene0: {
scene:
"You walk into a room. A work boot sits on the countertop, seductively. It’s deep mossy green and reeks of vegan leather. How do you proceed?",
options: [
awaitInput,
"Put the boot on, even though it’s too small.",
"Ask the boot how it got there."
]
},
scene01: {
scene:
"You should’ve cut your toenails this morning. Now the boot is crying. Look at it. You’re cutting into the lining. How could you do this?",
options: [
awaitInput,
"I’m sorry.",
"I’m just breaking it in.",
"What’s the boot gonna do about it, huh?"
]
},
scene02: {
scene: "The boot doesn’t reply because it is a boot. How do you proceed?",
options: [
awaitInput,
"Take a picture to send to your roommate. Maybe the boot is hers.",
"Stare at the boot."
]
},
scene011: {
scene:
"The boot sighs and wriggles over to make more room for your toes. At least you were polite about it, the boot thinks.",
options: [awaitInput]
},
scene012: {
scene:
"Just as many cowboys tried and failed to break the spirits of the strongest stallions of colonial north America, you too will fail to tame this admittedly charismatic boot. You lean down to stroke the calm beast’s side, only for its skin to tremble and assume a liquid-like quality. The surface gleams like an oil slick, and molds away from your hand in drowsy, gloopy movements. You feel alienated.",
options: [awaitInput]
},
scene013: {
scene:
"The boot oozes a sickly yellow mucus from its now-visible pores. You try pulling the boot off, but it’s locked onto your ankle like a bear trap. You try leaning over to get a better look at the foot un-cozy, but unfortunately your calves are extremely tight ever since you started skipping your daily morning stretches, so you’re only able to bend far enough to see just past the laces. Even from this vantage point, you can see the boot’s vegan leather rise and fall with every breath it takes.",
options: [awaitInput]
},
scene021: {
scene:
"You take the picture, but upon doing so realize you’ve never seen this room in your entire life. Maybe your roommate had a 5-cornered, starch-white chamber installed across from the bathroom while you were out getting groceries. Coming to think of it, the ornate copper embellishments on the door probably should’ve tipped you off to its strange appearance in your two-bedroom shithole. You turn around to further inspect the door only to realize it has vanished.",
options: [awaitInput]
},
scene022: {
scene:
"The boot starts blushing. It doesn’t like being the center of attention, but damn does it always seem to be.",
options: [awaitInput]
}
})
Insert cell
import { select } from "@jashkenas/inputs"
Insert cell
Insert cell
goNextScene = function(current, option) {
mutable currentScene = `${currentScene}${option}`;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more