Some direction on command filtering

Dec 19, 2015 at 10:47 PM
Hello!

I am working on a simple telnet game. I understand how to setup supersockets and how it generally works, but I have a couple questions about command filtering (or something like it).

I am currently working on a MUD based game (text based). How I intended on doing it is like old style BBS games once you are logged in, you simply hit a key on your keyboard and it is linked to a command (For example 'c' might be Chat, 'o' would show Online players, 'e' will go to the Options Screen, etc.)

First off, I want to know how I can assign a set of commands to the same keys, for example, in the main game, 'o' can show online users, however, in the options menu, 'o' might be to set a specific value. I know in this situation I could do a 'if (menu == optionsMenu) else' style, but I don't know if that is necessarily the easiest way. I don't think it would be the cleanest, specially if there are several menus besides the option menu. The 'o' key might be for many things. For this, am I correct to assume the 'SwitchRecieveFilter' example could be used in this idea? I cannot 100% tell yet as the example cannot be run directly in the source.

Second off, what's the easiest way to ask for data right after a command, for example, after a client hits 'c' to chat, the next thing that occurs is that the server sends a message asking the client what he wants to write. The player then writes a message and hits enter. Obviously when you want to type a message, it stops taking input from whatever menu you are on (I.E. 'c' wont open up the chat again, 'o' won't display the online users, etc. All the keys are used for the chat until the message has been sent or cancelled.)


I think the two questions might be similar, it's about how to transition though commands at different screens or one specific command like chat.


One last thing. I don't want to have to type 'chat Hello how are you!'. I want the user to hit 'c', then type a message and hit enter. I already understand how to deal with the first part, just not how to deal with creating an actual message as the next thing the user writes.
Dec 20, 2015 at 10:51 AM
I suppose a simplier means would be for example, menus. Navigation through different menus and how it should be 'properly'.