Problem with showmenu

So I'm trying to use a showmenu in my interactive game but upon cilciking on the 2nd option, the text doesn't show (the options simply disappears with no text).

I've removed the text so it becomes easier to see but this is the code:

https://docs.google.com/document/d/1t7oMQZVzx4sF-I7yrcIO5KSaZuqTUSPUMTKsBrScres/edit?usp=sharing

The problem is Text5 doesn't appear (the other option works as intended). It's also not the blank wait for a key press, because removing it does not help it.


Hello.

Try this.


msg ("Text1.<br/>")
ShowMenu ("", Split("Approach the fruits;Rest and go back down"), false) {
  switch (result) {
    case ("Approach the fruits") {
      msg ("Text2<br/>")
      wait {
        msg ("Text3<br/>")
        wait {
          msg ("Text4<br/>")
          wait {
            MoveObject (player, Void)
          }
        }
      }
    }
    case ("Rest and go back down") {
      msg ("Text5")
      wait {
      }
    }
  }
}

You had: ShowMenu ("", Split("Approach the fruits; Rest and go back down"), false) {

Should be: ShowMenu ("", Split("Approach the fruits;Rest and go back down"), false) {

The space messed up the second choice.

https://docs.textadventures.co.uk/quest/functions/showmenu.html

EDIT

With the space in there, result would need to match " Rest and go back down" rather than "Rest and go back down". (The first has a space before "Rest".)

You could do switch (Trim (result)) to avoid that issue in the ShowMenu script, but you also want to make a habit of excluding the unnecessary space in that bit of your Split function.

:o)


Also, you had: msg (Text4<br/>")

Should be: msg ("Text4<br/>")

It was missing the first ", probably only in your example code, I imagine.

You also had "Text4" printing twice, and I removed one.

Again, I assume that just ended up in your example code. This is a solid argument against posting example code. :)


Also also, to post your code here (rather than us needing to click a link to leave this site to view your code):

image


If you post your code here, you'll get more help in a more timely fashion. :)


If you need more help, just say the word!

Happy gaming!


PS

You should also add a default to your switch statement. That way, you could code a response when there was an issue such as this one.

https://docs.textadventures.co.uk/quest/multiple_choices___using_a_switch_script.html#default-option


That was it, thank you. I'll keep on the look out for switch statements, it will indeed make things a lot easier for me.


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

Support

Forums