Show Menu Disappearing

Hi, so I tried to make a dialogue tree of options using the show menu, but when you run it, the game will glitch and make the show menu disappear when clicking on certain options. Basically when I click on an option on the show menu the entire menu will disappear instead of leading to the next show menu. Here is the code.

topics = split ("Fight with Aphrodite;Bake Sale;Yellow Envelope;Never mind...", ";")
ShowMenu ("Talk to Tiffany about...", topics, false) {
  switch (result) {
    case ("Fight with Aphrodite") {
      topics2 = split ("You were a bitch! (Mean);What was that about? (Neutral);Why would you refuse her like that? (Nice);Never mind...", ";")
      switch (result) {
        case ("You were a bitch! (Mean)") {
          msg ("\"Um...excuse me?\"")
          NpcScore (npc, obj)
          npc.score = npc.score - 1
          msg ("Your relationship with tiffany has gone done by one.")
        }
        case ("What was that about? (Neutral)") {
          msg ("\"Aphrodite is an attention seeking whore and I couldn't care less about what lies she wants to tell me about the contest.\"")
        }
        case ("Why would you refuse her like that? (Nice)") {
          msg ("\"Because I know she is a lying sniveling little bitch! And people like her who come from poor families and bitch about their life don't deserve to be a part of my group! You seem like okay though.\" ")
        }
        case ("Never mind...") {
          msg ("Tiffany rolls her eyes. \"Whatever\"")
        }
      }
    }
    case ("Bake Sale") {
      topics3 = split ("What is this bake sale for?;I want to buy something;Never mind...", ";")
      ShowMenu ("Bake Sale", topics3, false) {
        switch (result) {
          case ("What is this bake sale for?") {
            msg ("\"I'm raising money for the dance team so we can go to LA and compete in a national dance competition.\" ")
          }
          case ("I want to buy something") {
            msg ("\"What do you want?\" ")
            MoveObject (player, Bake Sale)
            msg ("You are now at the bake sale! To leave, just click out or type go out.")
          }
          case ("Never mind...") {
            msg ("Tiffany rolls her eyes. \"Whatever\"")
          }
        }
      }
    }
    case ("Yellow Envelope") {
      msg ("\"Like what do you think it is? It has everything you need to compete for that school. It's so elite that they hold competitions every year. My sister won, but she can't even talk about it because it is that elite, like she signed an NDA or something. That's why I know Aphrodite there is lying, nobody can get information about the contest until it starts.\"")
      topics4 = split ("What is this about teams?;Would you team up with me?;Nevermind...", ";")
    }
    case ("Never Mind...") {
      msg ("Tiffany rolls her eyes. \"Whatever\"")
    }
  }
}

In the first case, "Fight with Aphrodite", you set the variable "topics" to a new list, but don't do ShowMenu again. This means that you're going into the second switch block, comparing result to "You were a bitch! (Mean)", "What was that about? (Neutral)", etc… when result is still set to "Fight with Aphrodite".

The second case, "Bake Sale", does this correctly – using ShowMenu again to display a new menu.

If you're doing lots of switch statements like this, I would also recommend including a default block which displays an error message. default should go inside the switch block, after all the cases. That way, if there's a typo in one of the options, it will tell you what the problem is and make it easier to debug.


Oh… just saw that someone already answered this in another thread :p

Hope you don't mind the repetition.

You've got a good method for handling the conversation, but I thought you might be interested to see an alternative way to handle conversations, which I sometimes find easier to keep track of. (Especially because if your conversation gets several levels deep, the text gets more bunched up at the right side of the screen)

Assuming that this is the "speak to" verb of a character called npc, you could frame it like this:

if (not IsDefined ("result")) {
  result = "Talk to Tiffany about…"
}
switch (result) {
  case ("Talk to Tiffany about…") {
    topics = Split ("Fight with Aphrodite;Bake Sale;Yellow Envelope;Never mind…")
  }
  case ("Fight with Aphrodite") {
    topics = Split ("You were a bitch! (Mean);What was that about? (Neutral);Why would you refuse her like that? (Nice);Never mind…")
  }
  case ("You were a bitch! (Mean)") {
    msg ("“Um… excuse me?”")
    // I'm not sure where the variable obj comes from - this might need fixing
    NpcScore (npc, obj)
    npc.score = npc.score - 1
    msg ("Your relationship with Tiffany has gone done by one.")
  }
  case ("What was that about? (Neutral)") {
    msg ("“Aphrodite is an attention seeking whore and I couldn't care less about what lies she wants to tell me about the contest.”")
  }
  case ("Why would you refuse her like that? (Nice)") {
    msg ("“Because I know she is a lying sniveling little bitch! And people like her who come from poor families and bitch about their life don't deserve to be a part of my group! You seem like okay though.”")
  }
  case ("Bake Sale") {
    topics = Split ("What is this bake sale for?;I want to buy something;Never mind…")
  }
  case ("What is this bake sale for?") {
    msg ("“I'm raising money for the dance team so we can go to LA and compete in a national dance competition.”")
  }
  case ("I want to buy something") {
    msg ("“What do you want?”")
    MoveObject (player, Bake Sale)
    msg ("You are now at the bake sale! To leave, just click out or type go out.")
  }
  case ("Yellow Envelope") {
    msg ("“Like what do you think it is? It has everything you need to compete for that school. It's so elite that they hold competitions every year. My sister won, but she can't even talk about it because it is that elite, like she signed an NDA or something. That's why I know Aphrodite there is lying, nobody can get information about the contest until it starts.”")
    topics = Split ("What is this about teams?;Would you team up with me?;Nevermind…")
    }
  case ("What is this about teams?") {
    // TODO: Add response
  }
  case ("Would you team up with me?") {
    // TODO: Add response
  }
  case ("Never Mind…", "Nevermind…") {
    msg ("Tiffany rolls her eyes. “Whatever”")
  }
  default {
    error ("It looks like the script is missing a response for: '"+result+"'. Please let the game designer know so they can find the typo.")
  }
}
if (IsDefined ("topics")) {
  // Use the name of the object/script here, so that it runs the script again
  ShowMenu (result, topics, false, npc.speakto)
}

Different people have different preferences; but if you end up with a long conversation that starts making it hard to navigate, something like this might be worth trying. (It also allows multiple options, from different parts of the conversation tree, to point to the same place


This topic is now closed. Topics are closed after 14 days of inactivity.

Support

Forums