Force Quit a Menu

I have a pretty simple menu on intro, but I can’t force quit the menu, the player has to press Q.

How do I force a quit when the user has selected king or queen, so it will go back to my game?

I’ve scoured the API documentation, but I haven’t found a method I can call or a property I can change to do this for me.

[code]gameMain: GameMainDef
initialPlayerChar = me

showIntro() {
    characterSelectMenu.display();
}

;

startRoom: Room ‘Start Room’
“This is the starting room.”
;

  • me: Actor;
  • king: Actor;
  • queen: Actor;

characterSelectMenu: MenuItem ‘Main Menu’;

  • MenuItem
    title = ‘New Game’
    heading = ‘Character Select’
    ;
    ++ MenuLongTopicItem ‘King’
    menuContents() {
    gameMain.initialPlayerChar = king;
    }
    ;
    ++ MenuLongTopicItem ‘Queen’
    menuContents() {
    gameMain.initialPlayerChar = queen;
    }
    ;
  • MenuItem
    title = ‘Load Game’
    ;
  • MenuItem
    title = ‘Credits’
    ;[/code]

You would have to modify the MenuItem class (see file menucon.t) as what’s happening is there’s a loop you’d need to break out of there. Also, the menu system was called up as a banner while at the same time the main command prompt was hidden. So you’d have to undo that and break out of the loop.

Actually why even use menus like that? Simpler way would be create your own pick list menus doing something like this:


startRoom: Room
    description {
            if(!gPlayerChar.hasSeen(self)){
                   startRoom.chooseCharacter();// will run this the first time the player is in this room
            }
            // show room description now....
            "You are in a maze of twisty little passages, all different."
    }

    chooseCharacter(){

              /*
               *  Options Menu
               */
              "<br><b>Character Selection</b>
               <br>0. Back to main menu
               <br>1. King
               <br>2. Queen";
            local iDone = 0;
            local s0 = '';
            local myInt = 0;
            do{
                           "<br> >";
                           s0 = inputManager.getInputLine(nil, nil);
                           // s0 = s0.toLower();
                           myInt = toInteger(s0);
                           if(myInt == 0){
                              iDone++;
                           }else if((myInt>=0) && (myInt <= 2)){
                              iDone++;        
                           }else{
                              "Please select a number from 0 to 2.<br>";
                            } 
                           "\n";
            }while(iDone==0);
            if(myInt == 0){
                // someOtherMethod();// cls(), etc.  
            }
            if(myInt == 1){
                "You chose: King";
                 setPlayer(King);
            }
            if(myInt == 2){
                "You choose: Queen";
                setPlayer(Queen);
                // exit;// should never return from loop but just in case
            }          
           

  }
;