Hi Jim,

The command interpreter is actually contained in the Winfrotz program
itself. All the z5, z8, and zip files are is data files that instruct
the interpreter what items are in the game and where to put them as
well as provide text descriptions. I don't recall the Inform syntax
exactly, but below is a basic idea of how it works.

The Bedroom is a Room. The Bedroom is a medium sized room with white
colored walls, brown colored carpet on the floor, a desk and chair are
next to the window, and an air bed is in the center of the room.
Thomas is a Man. Thomas is in the Bedroom.

This would be loaded into Winfrotz and would create a room called
Bedroom, and create a male character  called Thomas. In other
languages these would be class objects since the keywords Man and Room
are special keywords used for creating rooms and characters. There are
other keywords such as Animal, Woman, and Thing as well for creating
other characters and creatures if we wanted to add more to our
interactive fiction adventure.

However, the point I want to make is the person writing the text
adventure doesn't actually write the commands etc they will be using.
They Only declare the characters, rooms, and items in the game and the
interpreter program like Winfrotz does the rest.

Anyway, if you wanted to write your own custom text adventure and
command interpreter getting and studying the Winfrotz source would
really be unnecessary since writing a custom command interpretor for a
game is really quite simple and straight forward. It is simply a
matter of comparing the input string with a list of commands and
acting upon it. In C++ a simple command interpreter might look like
this.

void InputCommand()
{

        std::string command = "";

        while (running)
        {

                std::cout << "Enter a command:\n";
                std::cin >> command;

                if (command == "north")
                {
                        GoNorth();
                }
                elif (command == "east")
                {
                        GoEast();
                }
                elif (command == "south")
                {
                        GoSouth();
                }
                elif (command == "west")
                {
                        GoWest();
                }
                else
                {
                        std::cout << "I don't know what you want me to do.\n";
                }
        }
}

I know you are not a C++ developer, but I think this should
demonstrate the basic concept of how a command interpreter works. You
basically take an input string and compare it with any and all
possible commands, and if it doesn't match you display the typical "I
don't know what to do" type error message. Handling string input and
comparing it varies from language to language, but this is pretty much
how it is done in a nutshell. How good or bad the interpreter is
largely depends on how many commands the developer adds to their input
loop, and weather or not they add common alternatives such as take and
get or include common shortcuts like n for north, s for south, e for
east, w for west, x for examine, and so on. Still, its not rocket
science.

Cheers!



On 7/11/13, Jim Kitchen <[email protected]> wrote:
>
> Hi Thomas,
>
> Yeah, I'm not sure, like maybe I should have a look at the open source
> winfrotz.  But I'm not sure how much of the command interpreter is in that
> or if it is in the file that you write for it.
>
> I do have a couple of text adventure games that were written in Basic, but
> they are small and the command interpreter is not very good.
>
> BFN
>
>      Jim
>
> I like Visual Basic 6.0 because I can not C.
>
> [email protected]
> http://www.kitchensinc.net
> (440) 286-6920
> Chardon Ohio USA

---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to [email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].

Reply via email to