[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Room Display

Room Display

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Neves   USA  (78 posts)  [Biography] bio
Date Tue 16 Jul 2002 06:44 PM (UTC)

Amended on Mon 22 Jul 2002 05:29 PM (UTC) by Neves

Message
Basically I didn't like the way the standard SMAUG room display and exits were set up, so I rewrote the part of do_look involved in it and also the do_exits function. The main difference is the way it displays room exits. It now says the amount of exits, and also displays closed doors in parantethis (eg. There are three visible exits: north (east) northeast.) and if the player is on brief it will display the abbreviation for the exit in brackets (with closed doors) after the rooms short desc (eg. The acadamy training grounds.[n,(e),ne]). If anyone likes this style, feel free to use it, and if anyone finds an error, please tell me.

Here it is:
/* Here is the modified part of 'do_look' (only the part for displaying the room */

/* add this to the beginning of the function */
bool brief;


if ( !IS_NPC(ch) )
{
if ( !str_cmp( arg1, "auto" ) && xIS_SET(ch->act, PLR_BRIEF) )
ch_printf( ch, "&w%s", ch->in_room->name );
else
{
ch_printf( ch, "&w[&G%s&w]\n\r", ch->in_room->name );
ch_printf( ch, "&w%s", ch->in_room->description );
if ( !IS_NPC(ch) && xIS_SET(ch->act, PLR_AUTOMAP)
&& ch->in_room->map != NULL ) /* maps */
do_lookmap(ch, NULL);
}

if ( xIS_SET(ch->act, PLR_AUTOEXIT) )
{
will get the full exits
even if he is set on brief */
if ( str_cmp( arg1, "auto" ) )
{
if ( xIS_SET(ch->act, PLR_BRIEF) )
brief = TRUE;
else
brief = FALSE;
xREMOVE_BIT( ch->act, PLR_BRIEF );
do_exits( ch, "auto" );
if ( brief == TRUE )
xSET_BIT(ch->act, PLR_BRIEF);
}
else
do_exits ( ch, "auto" );
}

show_list_to_char( ch->in_room->first_content, ch, FALSE, FALSE );
show_char_to_char( ch->in_room->first_person, ch );
return;
}

/* Here is the modified 'do_exits' */

void do_exits( CHAR_DATA *ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char cExit[6];
EXIT_DATA *pexit;
bool found;
bool fAuto;
int nExit;
int door;

buf[0] = '\0';
cExit[0] = '\0';
nExit = 0;
fAuto = !str_cmp( argument, "auto" );

if ( !check_blind(ch) )
return;


found = FALSE;
for ( pexit = ch->in_room->first_exit; pexit; pexit = pexit->next )
{
if ( pexit->to_room
&& (!IS_SET(pexit->exit_info, EX_WINDOW )
|| IS_SET(pexit->exit_info, EX_ISDOOR))
&& !IS_SET(pexit->exit_info, EX_HIDDEN) )
{
nExit++;
door = get_door(dir_name[pexit->vdir]);

if ( IS_SET( pexit->exit_info, EX_ISDOOR )
&& IS_SET( pexit->exit_info, EX_CLOSED )
&& !IS_SET( pexit->exit_info, EX_SECRET ) )
{
if ( !xIS_SET(ch->act, PLR_BRIEF) && fAuto == TRUE )
sprintf( buf + strlen(buf), " (%s)", dir_name[pexit->vdir] );
else if ( xIS_SET(ch->act, PLR_BRIEF) && fAuto == TRUE )
{
if ( found == TRUE )
strcat( buf, "," );
if ( door <= 5 )
sprintf( buf + strlen(buf), "(%c)", dir_name[pexit->vdir][0] );
else
sprintf( buf + strlen(buf), "(%c%c)",
dir_name[pexit->vdir][0],
dir_name[pexit->vdir][5] );
}
else
sprintf( buf + strlen(buf), "\n\r&G%-9s&w - The %s is closed.",
capitalize( dir_name[pexit->vdir] ),
pexit->keyword );
found = TRUE;
}
else if ( !IS_SET( pexit->exit_info, EX_CLOSED ) )
{
if ( !xIS_SET(ch->act, PLR_BRIEF) && fAuto == TRUE )
sprintf( buf + strlen(buf), " %s", dir_name[pexit->vdir] );
else if ( xIS_SET(ch->act, PLR_BRIEF) && fAuto == TRUE )
{
if ( found == TRUE )
strcat( buf, "," );
if ( door <= 5 )
sprintf( buf + strlen(buf), "%c", dir_name[pexit->vdir][0] );
else
sprintf( buf + strlen(buf), "%c%c",
dir_name[pexit->vdir][0],
dir_name[pexit->vdir][5] );
}
else
sprintf( buf + strlen(buf), "\n\r&G%-9s&w - %s",
capitalize( dir_name[pexit->vdir] ),
room_is_dark( pexit->to_room )
? "Too dark to tell"
: pexit->to_room->name );
found = TRUE;
}
}
}

if ( nExit > 1 )
{
switch(nExit)
{
default: strcpy( cExit, "many" ); break;
case 2: strcpy( cExit, "two" ); break;
case 3: strcpy( cExit, "three" ); break;
case 4: strcpy( cExit, "four" ); break;
case 5: strcpy( cExit, "five" ); break;
case 6: strcpy( cExit, "six" ); break;
case 7: strcpy( cExit, "seven" ); break;
case 8: strcpy( cExit, "eight" ); break;
case 9: strcpy( cExit, "nine" ); break;
}
}

if ( !found && xIS_SET(ch->act, PLR_BRIEF) && fAuto == TRUE )
strcat( buf, "none" );

if ( !xIS_SET(ch->act, PLR_BRIEF) && fAuto == TRUE )
{
if ( nExit == 1 )
ch_printf( ch, "&gThere is one visible exit:%s.", buf );
if ( nExit > 1 )
ch_printf( ch, "&gThere are %s visible exits:%s.", cExit, buf );
if ( nExit < 1 )
ch_printf( ch, "&gThere are no visible exits." );
}
else if ( fAuto == FALSE )
{
if ( nExit == 1 )
ch_printf( ch, "&wYou see one exit:%s", buf );
if ( nExit > 1 )
ch_printf( ch, "&wYou see %s exits:%s", cExit, buf );
if ( nExit < 1 )
ch_printf( ch, "&wYou do not see any visible exits." );
}
else
ch_printf( ch, "&w.[&g%s&w]", buf );

ch_printf( ch, "\n\r" );

return;
}

-Mark Calloway
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


7,733 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]