contents.gifindex.gif

pueblo00000000.gif Building in LP-MUD

In the LP-MUD reference implementation of Pueblo's HTML extensions, we extended the 2.4.5 mudlib's room.c to automatically output exits as anchors for Pueblo users, so nothing special needs to be done when rooms are created.

Descriptions of 2.4.5 rooms come from these variables:

static string short_desc;

static string long_desc;

Which can be set in your room's reset() function:

/* vill_green.c */

inherit "room/room";

reset(arg)

{

if (arg) return;

set_light(1);

short_desc = "Village green";

no_castle_flag = 1;

long_desc = "You are at an open green place south of the " +

"village church.\n" +

"You can see a road further to the east.\n";

dest_dir = ({"room/church", "north",

"room/hump", "west",

"room/vill_track", "east"});

}

To support HTML descriptions, we added two new variables to room.c:

/* Short HTML description of the room */

static string short_html_desc;

/* Long HTML description of the room */

static string long_html_desc;

These are set just like short_desc and long_desc:

reset(arg)

{

...

short_desc = "Village green";

short_html_desc = "Village <em>green</em>";

long_desc = "You are at an open green place south of the " +

"village church.\n" +

"You can see a road further to the east.\n";

long_desc = "You are at an open green place south of the " +

"village church.\n" +

"You can see a road further to the east.\n";

long_html_desc =

"You are at an open green place south of the " +

"<em>village church<em>. " +

"You can see a road further to the " +

"<a xch_cmd=\"go east\" xch_hint=\"Go east\">east</a>.\n ";

...

}

Note that it is generally a good idea not to embed newlines in HTML strings like long_html_desc (except at the very end), because HTML clients like Pueblo will automatically format the text they receive.

If you want a VRML document to be displayed when users enter the room, you can set this new variable, also from room.c:

/* VRML scene URL */

static string vrml_url;

Like this (replacing the URL with the URL of the VRML file you want displayed when people enter the room):

reset(arg)

{

...

short_desc = "Village green";

short_html_desc = "Village <em>green</em>";

long_desc = "You are at an open green place south of the " +

"village church.\n" +

"You can see a road further to the east.\n";

long_desc = "You are at an open green place south of the " +

"village church.\n" +

"You can see a road further to the east.\n";

long_html_desc =

"You are at an open green place south of the " +

"<em>village church<em>. " +

"You can see a road further to the " +

"<a xch_cmd=\"go east\" xch_hint=\"Go east\">east</a>.\n ";

vrml_url =

"http://www.chaco.com/pueblo/0.6/ChAnim/msw32/pueblo.wrl";

...

}

To send HTML text to users, use write_html() instead of write(). (The write() function escapes some characters when they are sent to Pueblo users so that they can edit programs which include URLs, etc. The escaping turns '<' into '&lt;', etc.)

To determine whether a client is Pueblo-enhanced, use the query_is_html() function. For example, if you wanted to output pre-formatted HTML text for HTML-enabled users, you might do this:

if (this_player()->query_is_html())

{

write_html("<pre>");

}

write("This text is preformatted.\n");

if (this_player()->query_is_html())

{

write_html("</pre>");

}