Add secret option to showmenu

Hi! Hi! I want to add a secret option, which will only appear by typing something, such as secret, in the input bar. Is it possible to do that? I want to create a ShowMenu list for my game.
Any advice? Thanks!

Unfortunately, by default you can't type in a response to a menu unless you type a number.

However, you can add an option to a menu that doesn't get displayed. For example:

ShowMenu ("Pick a colour", Split("red;green;blue"), true) {
  msg ("You picked " + result + "!")
list add (game.menuoptionskeys, "yellow")

Can generate the result:

Pick a colour
1. red
2. green
3. blue

==> 4

You picked yellow!

Alternatively, you could create a command to handle the secret input.
If you pass true to the menu's "allow cancel" option, they can still type in commands. So then you make a secret command that's only valid when the menu is running.

You can use AddToInventory (mycommand) to disable a command, and MoveObjectHere (mycommand) to enable it.

If you don't want the player to be able to enter other commands, you could make a command with the pattern #text#, so that it catches anything the player types, and then give it a body like:

if (text = "secret") {
  msg ("You do the secret thing.")
  AddToInventory (this)
else {
  msg ("Please choose an option from the menu.")
  // code here to display the same menu again

Remember to disable that command after the menu is done.

Log in to post a reply.