Adding questions to a list

So I'm trying to set up a list of questions where asking the first question reveals the second one, but I'm not sure how to hide the questions until the right time.

This is just an example I threw together. Basically, I want "ask about cat" to be the only question at the start. And only by asking about the cat do you get the option to ask about the dog. And so on.

msg ("
What would you like to know?")
ShowMenu ("What will you ask him?", Man.Man_ask, false) {
switch (result) {
case ("Ask about cat") {
msg ("Dog")
}
case ("Ask about dog") {
msg ("Bird")
}
case ("Ask about bird") {
msg ("Fish")
}
}
}


Gng

You have to nest them.

Man.Man_ask = "Ask about cat"
ShowMenu ("What will you ask him?", Man.Man_ask, false) {
  switch (result) {
    case ("Ask about cat") {
      msg("What a beautiful cat")
      options = Split("Ask about dog;Ask about bird", ";")
      ShowMenu ("What will you ask him?", Man.Man_ask, false) {
        switch (result) {
          case ("Ask about dog") {
            msg ("Bird")
          }
          case ("Ask about bird") {
            msg ("Fish")
          }
        }
      }
    }
  }
}

to make it more elegant you can use script attributes and call them with function: do (object, "attribute_name")
first, add a script-type attribute named "second question" to Man object:

options = Split("Ask about dog;Ask about fish", ";")
ShowMenu ("What will you ask him?", options, false) {
  switch (result) {
    case ("Ask about dog") {
      msg ("what a loyal dog")
    }
    case ("Ask about fish") {
      msg ("The fish is swimming about.")
    }
  }
}
ShowMenu ("What will you ask him?", Man.Man_ask, false) {
  switch (result) {
    case ("Ask about cat") {
      msg ("What a beautiful cat")
      do (Man, "second question")
    }
  }
}

Just to make less messy


Hmmm... Nope. I can't figure it out. I tried what you suggested a few different ways, but I keep getting errors. I have no idea what I'm doing so I have no idea how to fix them. I'll just go back to my old method of using the Ask/Tell system. Not as polished, but it gets the job done. Thank you anyway.


Gng

What errors do you get? Let's try to get through them together


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

Support

Forums