Re: [NEWBIE] Menu making...

From: Daniel A. Koepke (
Date: 11/23/02

On Sat, 23 Nov 2002, peter dahlgren wrote:

> i need help with making a menu for my multiclassing, like when you
> choose class at the start, but you can do it whenever you want with a
> special command...

The simplest way to do this is to switch the player's connected state from
CON_PLAYING to your own custom state.

Adding a connected state is a simple three-step affair:

  1) Add the #define with the other CON_xxx definitions in structs.h.
  2) Add the state's name to the connected_types[] array in constants.c.
  3) Add the state handler in interpreter.c:nanny().

See CON_QSEX for a simple example of handling a menu, but note that when
you're done, you want to return the player to the CON_PLAYING state and
not move them into the middle of character creation or logon.

A basic outline of your state handler:

    /* ... do your handling here ... */
    d->has_prompt = 0;

The command to launch the state becomes fairly simple:

     * Prevent crashes from mobiles or other weirdness trying to use
     * this command.
    if (!ch->desc) {
      send_to_char(ch, "You need to have a connection, first!\r\n");

    /* ... code to output menu and prompt, here ... */

    /* Switch the player into the state. */
    STATE(ch->desc) = CON_EXAMPLE_STATE;

Oasis, I believe, uses a similar mechanism that may be worth studying.
Aside from that, there are plenty of examples of states in the existing
CircleMUD code.

Just be careful when fiddling with nanny(): much to do with character
creation, logging in, and other arcana is handled by the stock states.
Do not go about surreptitiously changing things unless you're really
interested in finding out what mysterious bugs you can create.


   | FAQ: |
   | Archives: |
   | Newbie List:   |

This archive was generated by hypermail 2b30 : 06/25/03 PDT