Skip to main content
Fix the syntax. Replaced the ; with , in the javascript object.
Source Link
var story = [
  { m: "Hi!" },
  { m: "This is my new game." },
  { question: "Do you like it?";", answers: [
    { m: "yes";"yes", next: "like_yes" },
    { m: "no";"no", next: "like_no" },
  ] },
  { label: "like_yes";"like_yes", m: "I am happy you like my game!";", next: "like_end" },
  { label: "like_no";"like_no", m: "You made me sad!";", next: "like_end" },
  { label: "like_end" },
  { m: "OK, let's change the topic" }
];
var story = [
  { m: "Hi!" },
  { m: "This is my new game." },
  { question: "Do you like it?"; answers: [
    { m: "yes"; next: "like_yes" },
    { m: "no"; next: "like_no" },
  ] },
  { label: "like_yes"; m: "I am happy you like my game!"; next: "like_end" },
  { label: "like_no"; m: "You made me sad!"; next: "like_end" },
  { label: "like_end" },
  { m: "OK, let's change the topic" }
];
var story = [
  { m: "Hi!" },
  { m: "This is my new game." },
  { question: "Do you like it?", answers: [
    { m: "yes", next: "like_yes" },
    { m: "no", next: "like_no" },
  ] },
  { label: "like_yes", m: "I am happy you like my game!", next: "like_end" },
  { label: "like_no", m: "You made me sad!", next: "like_end" },
  { label: "like_end" },
  { m: "OK, let's change the topic" }
];
replaced http://gamedev.stackexchange.com/ with https://gamedev.stackexchange.com/
Source Link

Philipp's answerPhilipp's answer already shows the right direction. I just think the data structure is needlessly verbose. Shorter texts would be easier to write and read.

Philipp's answer already shows the right direction. I just think the data structure is needlessly verbose. Shorter texts would be easier to write and read.

Philipp's answer already shows the right direction. I just think the data structure is needlessly verbose. Shorter texts would be easier to write and read.

added 180 characters in body
Source Link

By the way, these ideas were inspired by Ren'Py, which is not exactly what you want (not JavaScript, not web), but could give you some cool ideas anyway.

By the way, these ideas were inspired by Ren'Py, which is not exactly what you want (not JavaScript, not web), but could give you some cool ideas anyway.

Source Link
Loading