Change restart options to 'yes' and 'no' (rather than 1 or 2)

Nathaniel.Spence
02 May 2020, 22:09

Hello

Another question from me: how do I change the restart command to accept 'yes' or 'no' rather than 1 or 2? I've disabled the hyperlinks, so having to type 1 to restart doesn't look right.

Thanks!


mrangel
02 May 2020, 22:27

By default, the player needs to type the number for all uses of ShowMenu. I did post a script a long time ago overriding the built-in functions ShowMenu and HandleMenuTextResponse so that a player could type the text of a menu option to select it, but it was a little awkward.

I could try to come up with that again, if it would be helpful.

Alternatively, you could modify the "restart" command directly. Something like:

      msg (Template("WantRestartGame"))
      msg ("(Enter Y or N)")
      get input {
        if (StartsWith (Trim (UCase (result)), "Y")){
          JS.eval("if(webPlayer){window.location.reload();}else if (typeof(RestartGame) != 'undefined'){RestartGame();}else{addTextAndScroll('Try pressing CTRL+R.')};")
        }
        else {
          game.suppressturnscripts = true
        }
      }

(Just from looking at the existing function)


DarkLizerd
03 May 2020, 00:52

You could just ask the player...
IE:
msg "Well, that sucks, would you like to try again?"
GetInput{
if (ucase(left(result,1))="Y"){
restart
}
else {
end game
}


Nathaniel.Spence
03 May 2020, 08:46

Thanks both - I overrode the command as suggested. I just wasn't familiar with 'get input'...now I get it.