DESOLATION

Help manual · Coding

Rooms

For a code example, see Example Room

The Brief Description

The brief description should be a couple of words that tell a person very briefly where he is. The user sees the brief description whenever he enters or otherwise looks at a room. To set a room’s brief description, use set_brief () from the room’s create () function:

   set_brief ("Spooky Copse");

Tips:

Decorative Items

Simple Items

Simple items should be things that were mentioned in your long description that are just there for decoration. You can look at them, but anything else you try to do to them will fail. To make a simple item, call add_item () from your room’s create () function (you can do this multiple times in a row):

   add_item ("dust", "There is a lot of it!");

If more than one down describe the same item, you can do this:

   add_item ("horse", "animal", "mare", "He doesn't look too interesting.")

Other Items

You can make slightly more interesting objects with add_item ().

You can give the object adjectives, and make it give error messages back other than the default, “That doesn’t make any sense!” type of message. For example, to make an old, faded sign that you can’t read, do the following:

   add_item ("sign", ([ "adjs" : ({ "old", "faded" }),
                        "read" : "The sign is too faded to read.",
                        "look" : "The sign is very faded.",
                        "get"  : "It would probably crumble to dust!",
                     ]) ); 

However, if you actually want to be able to read the sign, or get the sign, you need to make an object for it.

Objects

Adding Objects

If there is an object in another file that you’d like to have be in your room, you can use the set_objects () call from your room’s create function to have an object placed there. This function has an odd syntax. Here is an example that will create two torches and a bed:

   set_objects ( ([ "/domains/std/magic_torch" : 2,
                    "/domains/std/bed" : 1,
                  ]) );

Passing Optional Arguments

If you need to pass args to your objects setup() function here is how you do it:

   set_objects ( ([ "/domains/std/large_oak_door" : ({ "west" }) ]) );

This will create a door blocking the west wall of your room.

If you need to pass args and have more than one of the objects in the room, here is an example:

   set_objects ( ([ "/domains/std/foobar" : ({ 3, "west" }) ]) );

this will create 3 foobars passing each one of them west as an argument.

Exits

You need to specify the exits from your room, or else no one will ever leave. The simple way to put exits in a room is by calling set_exits in your room’s create() function like so:

    set_exit ( (["northeast" : "/domains/std/wizroom",
                 "southwest" : "#The mountains block your path.", ]) );

The ([ denotes that you’re going to start a list of exits. The exits have two parts. The part before the colon is the direction, and the part after the colon is the destination. The destination can be a file name, or it could be an error message, if the person can’t go in that direction. Put a # at the front of the error message, if so. For example, if you try to go southwest, you’d get:

The mountains block your path.

The Long Description

The long description should be a detailed description of your room. To set the long description for a room, you use set_long () from your room’s create () function. For example:

   set_long ("Although there is plenty of daylight left, "
             "you wouldn't know it from within this "
             "copse.  The trees stare at you intently.");

Tips:

Room Tips

Tips for making great rooms

default exit

set_default_exit(string str) will cause ‘str’ to be printed whenever the player tries to go a direction that doesn’t exist.

 set_default_exit("You can't go that way!");

The argument may also be a function pointer, in which case it is evaluated, and the return value is printed if it is a string.

(Note: set_default_exit actually just sets the value of the exit “DEFAULT”;

you can do this explicitly)

Adding Sound to your rooms

Add something like the following piece of code to your room, outside of your setup(). This will get called by the parser.

 int sound ()
 {
     write ("This is an example sound.  Only you are getting this msg, so "
        "I guess you're \nhearing voices.\n");
     return 1; // Let the parser know the listen was successfull
 }

The area

Let’s say you have a monster that you want to wander around, but you don’t want him to leave your castle. Well, the castle is a pretty big area. We have to tell Lima when we want a room to be in this area. We do this by picking a name for our area, for example, “my_castle”. Then, we tell the mud that our room is in that area by adding the following code to the room’s create () function:

   set_area ("my_castle");

Tips:

Category:Coding