How to prompt the user for information?

Posted by Azrith on Sat 01 Feb 2003 04:15 AM — 7 posts, 23,077 views.

#0
Hi,

I have been doing some coding and am working on making some new additions and I have run into a problem.
How in the world can I prompt the user to input a value. For instance when the character first joins it asks for their name class race etc. I am looking to do something very similar but can't figure out how they are prompting and waiting for the input. Any help would be greatly appreciated.

Azrith
Australia Forum Administrator #1
Take a look at the "nanny" function in comm.c.

Basically the MUD maintains a "state" flag which is how far it has progressed through the initial questions, and then just "playing". You could add more states to the list, and then modify nanny to ask the appropriate questions. Here is the current list from mud.h ...


/*
 * Connected state for a channel.
 */
typedef enum      
{
  CON_PLAYING,          CON_GET_NAME,           CON_GET_OLD_PASSWORD,
  CON_CONFIRM_NEW_NAME, CON_GET_NEW_PASSWORD,   CON_CONFIRM_NEW_PASSWORD,
  CON_GET_NEW_SEX,      CON_GET_NEW_CLASS,      CON_READ_MOTD,      
  CON_GET_NEW_RACE,     CON_GET_EMULATION,      CON_EDITING,
  CON_GET_WANT_RIPANSI, CON_TITLE,              CON_PRESS_ENTER,
  CON_WAIT_1,           CON_WAIT_2,             CON_WAIT_3,
  CON_ACCEPTED,         CON_GET_PKILL,          CON_READ_IMOTD
} connection_types;     


#2
Ya I did see that in nanny but what I was hoping to do was ask the questions later in the game when the user input a certain command such as buy home. Is this possible or am I going to have to resort to creating many commands?
Thanks!

Azrith
USA #3
For ingame functions of that nature you'll need to write a command specially for that function.
#4
Hmmm. That is what I was afraid of. To me this is a great limitation for smaug. Reason being is it makes playing that much more difficult. Instead of just being able to prompt for information and have then enter I will now have to modify the buy command so that if they choose home it purchases a home. Then I will have to create another command such as design. I will then have to use the second or third argument to determine what they want to design plus they will have to enter their choice after that. Next thing I know Ive got a long command to do 1 thing.
Ex. design home name Azriths Home.
Ex. design home levels 4
Ex. design home desc Azriths newly built home.
vs having it prompt
What would you like the name of your new home to be?
How many levels would you like your home to be?
What would you like your description for your home to be?
The user is going to find themselves having to use help more often and more lengthly input. :) but I guess it will have to work out HEHEHE.
Thanks for all the help guys.

Azrith
USA #5
Actually, I'd recommend not even letting players directly purchase houses from merchants. I've never played or worked on a MUD where that idea was successfully added and the players didn't go absolutely stupid over it. I'd advise requiring the morts that want houses that badly to deal with your builder staff to get the housing done. I advise this for a number of reasons, not the least of which is the sheer insanity of recoding the olc to allow players access to building commands without giving them the ability to edit areas thruout the mud. If you have to have this functionality, I'd advise a codebase other than SMAUG to attempt it with, probably something seriously modified from a MUSH codebase which normally offers players the ability to add such things as their own rooms.
Australia Forum Administrator #6
Quote:

vs having it prompt
What would you like the name of your new home to be?
How many levels would you like your home to be?
What would you like your description for your home to be?
The user is going to find themselves having to use help more often and more lengthly input. :) but I guess it will have to work out HEHEHE.


This is a fundamental problem with implementing interactive client-server systems. It is not a limitation of SMAUG specifically.

For example, what happens if the player is at the prompt:

"What would you like your description for your home to be?"

... when they realise they meant to enter 3 levels rather than 2? How do they go back to re-enter the previous answer? Enter GOBACK? What if they decide to cancel buying the house? Do they enter CANCEL? What if a mob attacks them half-way through? Do they enter KILL? What if someone pages them while they are in the buying process?

In the end, to cater for all these situations the prompting approach isn' t that simple after all. It might look like this ...


What would you like your description for your home to be?
To cancel, enter CANCEL.
To re-enter your previous response, enter GOBACK.
To reply to a page, enter REPLY.
To flee from an attack, enter FLEE.

etc.


This is why most MUDs have one-line commands, and do not get involved in interactive responses, the one exception being when you initially connect, or make a new character, which is before you are officially playing, and thus those considerations do not really apply.