Waiting for ShowMenu

I wanted to present a list of options to the player to choose from during character creation, I used the ShowMenu function for that purpose, but as I found out it doesn't wait for the result to run the rest of the code. I've read some topics on the forum related to that subject and the page about blocks and script (http://docs.textadventures.co.uk/quest/blocks_and_scripts.html), but didn't figured out yet how to make the game do what I want:
Show the menu with the list of choices, wait for the player to pick one of the options, then run the rest of the code after that.
I would appreciate any help.


for what you want, it can be done with a 'wait' Script/Function nested within the 'show menu / ShowMenu' Script/Function, and then nested within the 'wait' Script/Function is the code you want to wait (for a key press or mouse click) before it is done/run:

an example:

show menu ("Race?", split ("human;dwarf;elf;gnome;halfling;giant", ";"), false) {
  player.race = result
  wait {
    msg ("Race: " + player.race)
  }
}

Tried this before, It works for the blocks and scripts nested within the wait function script, but the real problem I'm having is that when I run the game and get to that step of the character creation where I used the ShowMenu the description of the starting room leaks in showing along with the list of choices.


ah... you're probably going have to turn off the 'auto room description', and manually put in the 'show room description' into the 'wait' Script/Function, I have the same problem with it too, and I think this is the only way to do it, aside from tracking down where this is within the underlying quest engine code and fixing/editing/adjusting it... way beyond my ability... lol


J_J

I might be misunderstanding the issue, but could you move the player in an empty character creation room, and then transport them to the starting room once they are done?


Show the menu with the list of choices, wait for the player to pick one of the options, then run the rest of the code after that.

Easy. Put the rest of the code inside the menu block.

the description of the starting room leaks in

There are a few ways to deal with this. (as other people have suggested while I was writing this)

I believe the simplest is to make a room just for character creation. Give it an alias like "Character Creation", and no description. Then move the player to the actual starting room after they answered all the questions. This has the advantage that the first room's alias doesn't show up in the title bar until character creation is done.

Alternatively, you could untick the option "Show room description when entering a room" on the game object, and then after your last menu has been answered do:

  game.showdescriptiononenter = true
  ShowRoomDescription()

I found that for me, the easiest way to arrange a character creation script is to put the options in a turnscript. That way, you don't end up with a dozen menus inside each other, crushed up at the right hand side of the editor window. Something like this:

if (not HasAttribute (player, "gender")) {
  ShowMenu ("Gender?", Split ("boy;girl;other;undecided"), true) {
    player.gender = result
    msg ("OK, you're "+result)
  }
}
else if (not HasAttribute (player, "sex")) {
  ShowMenu ("Sex?", Split ("XX,XY,XXY,X0,YY"), true) {
    player.sex = result
    msg ("OK, you're "+result)
  }
}
else if (not HasAttribute (player, "race")) {
  ShowMenu ("Race?", Split ("human;orc;Greek;elf;green;yellow;300m;marathon"), true) {
    player.race = result
    msg ("OK, you're "+result)
  }
}
else {
  DisableTurnScript (this)
  game.showdescriptiononenter = true
  ShowRoomDescription()
}

(note that this wouldn't run on the first turn unless you put RunTurnScripts in your start script)


You could play/put a function in the game's start script, and use ShowMenu or show menu. I've done that before.


I was hoping for an elegant solution, but the ones suggested will work. Thanks to everyone that replied. (:

@jmnevil54 that's what I was doing, but I had the problem with the room description anyway.


Oh. Have you tried putting the Show Menu in the room description?


I have a blank template for a character creation with Show Menu/Function if you would like to use it. Here it is.

ClearScreen
msg ("")
ShowMenu ("", game.nameofmenuhere, false) {
  switch (result) {
    case ("Question 1") {
      list remove (game.nameofmenuhere, "Question 1")
      list add (game.nameofmenuhere, "Question 2")
      NameofFunctionHere
    }
    case ("Question 2") {
      msg ("")
        ShowMenu ("", menulist, false) {
          if (result = "Choice 1") {
            list remove (game.nameofmenuhere, "Question 2")
            list add (game.nameofmenuhere, "Question 3")
            ClearScreen
            NameofFunctionHere
          }
          else if (result = "Choice 2") {
            list remove (game.nameofmenuhere, "Question 2")
            list add (game.nameofmenuhere, "Question 3")
            ClearScreen
            NameofFunctionHere
          }
       }
	   }
    case ("Question 3") {
      msg ("")
      menulist = Split("Choice 1;Choice 2;Random", ";")
      ShowMenu ("", menulist, false) {
        if (result = "Choice 1") {
          ClearScreen
          list remove (game.nameofmenuhere, "Question 3")
          list add (game.nameofmenuhere, "Question 4")
          NameofFunctionHere
        }
        else if (result= "Choice 2") {
          ClearScreen
          list remove (game.nameofmenuhere, "Question 3")
          list add (game.nameofmenuhere, "Question 4")
          NameofFunctionHere
        }
        else if (result= "Random") {
		}
 }
 }
    case ("Question 4") {
      msg ("")
      get input {
        player.alias = result
        msg ("<br/>Pleased to meet you, <font color=\"dedede\">{player.alias}</font color>! ")
        wait {
          ClearScreen
          list remove (game.nameofmenuhere, "Question 4")
          list add (game.nameofmenuhere, "Question 5")
          NameofFunctionHere
        }
      }
    }
    case ("Question 5") {
      msg ("")
                ClearScreen
                MoveObject (player, NameofRoomHere)
              }
            }
	}

Anonynn.


K.V.

Isn't Waiting for ShowMenu the name of that Tom Hanks / Meg Ryan movie about how two people fall in love while discussing interactive fiction over the internet?

CLICK HERE FOR A SPOILER!

They never get together. The movie's run-time exceeds 2 hours. Don't watch it.


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

Support

Forums