Inventory, equip, etc

Posted by Xinphinity on Tue 20 May 2003 03:03 PM — 8 posts, 30,549 views.

USA #0
Hi there folks, I'm back after an extended hiatus.

Question one:

I am trying to change the way LOOK target, LOOK self, and equip work. Here is how.

Currently, there is a list that gets returned that has a

send_to_char( format_obj_to_char( obj, ch, TRUE ), ch );
send_to_char( "\n\r", ch );

So you would see something like:

You are wearing:
gloves
hat
armor

What I am looking for is more of a:

You are wearing some gloves, a hat, some armor.

I realise that part of this has to do with the 'short' name construction of objects, which I am addressing, and I have managed to get the output sort of how I want with:

send_to_char( format_obj_to_char( obj, ch, TRUE ), ch );
send_to_char( ",", ch );

The problem is the end of the list. I am trying to figure out how to determine the last item so I can put a
send_to_char( ".", ch ); there instead of the comma.

Any thoughts?

Xin
--
Oh and Nick, I cant figure out how to change my profile here, my new email address is edward@itguy.com
USA #1
Add the comma BEFORE the object, if it's not the first object. Then add a period outside of your loop. Something like this:


first = FALSE;
found = FALSE;
    for ( iWear = 0; iWear < MAX_WEAR; iWear++ )
    {
        if ( ( obj = get_eq_char( victim, iWear ) ) != NULL && can_see_obj( ch, obj ) )
        {
            if ( !found )
            {
                send_to_char( "\n\r", ch );
                if ( victim != ch )
                  act( AT_PLAIN, "$N is using:", ch, NULL, victim, TO_CHAR );
                else
                  act( AT_PLAIN, "You are using:", ch, NULL, NULL, TO_CHAR );
                found = TRUE;
            }
            set_char_color( AT_OBJECT, ch );
            send_to_char( where_name[iWear], ch );
            if (first)
              send_to_char( ", ", ch );
            send_to_char( format_obj_to_char( obj, ch, TRUE ), ch );
            first = TRUE;
        }
    }
if (first)
    send_to_char( ".", ch );



On the first loop it would display:

Hat

Then on the second:

Hat, Coat

Third and last:

Hat, Coat, Boots

When it left the loop it would add the period (but only if it found an object:

Hat, Coat, Boots.

If there was only one object it would display:

Hat.

Is that what you're trying to do? Hope this helps. I never actually tested this, so maybe I'm, overlooking something. But it should work ;-)
Australia Forum Administrator #2
Quote:

Oh and Nick, I cant figure out how to change my profile here, my new email address is edward@itguy.com


When you are logged into the forum there is a link on the top right-hand side of the page (next to your name) "Edit profile" - click on that to change your email address etc.
USA #3
As always, you can't beat this forum for help and support.

This is why I chose this version of Smaug. You people are wonderful, and thanks Nick.


I'll try that code now.

Xin
USA #4
Hmm not quite working.

Here is the original code.

void do_equipment( CHAR_DATA *ch, char *argument )
{
OBJ_DATA *obj;
int iWear;
bool found;

set_char_color( AT_RED, ch );
send_to_char( "You are using:\n\r", ch );
int first;
first = FALSE;
found = FALSE;
set_char_color( AT_OBJECT, ch );
for ( iWear = 0; iWear < MAX_WEAR; iWear++ )
{
for ( obj = ch->first_carrying; obj; obj = obj->next_content )
if ( obj->wear_loc == iWear )
{
if( (!IS_NPC(ch)) && (ch->race>0) && (ch->race<MAX_PC_RACE))
send_to_char(race_table[ch->race]->where_name[iWear], ch);
else
send_to_char( where_name[iWear], ch );

if ( can_see_obj( ch, obj ) )
{
send_to_char( ", ", ch );
send_to_char( format_obj_to_char( obj, ch, TRUE ), ch );

}
else
send_to_char( "something.\n\r", ch );
found = TRUE;
}
}

if ( !found )
send_to_char( "Nothing.\n\r", ch );

return;
}


I'm having a hard time determining what the `end` of the loop is, thats when I need a send_to_char( ".", ch );


What do you think?

~Xin
USA #5
End of loop with necessary placement of final period.


}
else
send_to_char( "something.\n\r", ch );
found = TRUE;
}
send_to_char( ".", ch);
}
USA #6
Hmm...


Using this code...

void do_equipment( CHAR_DATA *ch, char *argument )
{
OBJ_DATA *obj;
int iWear;
bool found;

set_char_color( AT_RED, ch );
send_to_char( "You are using:\n\r", ch );
int first;
first = FALSE;
found = FALSE;
set_char_color( AT_OBJECT, ch );
for ( iWear = 0; iWear < MAX_WEAR; iWear++ )
{
for ( obj = ch->first_carrying; obj; obj = obj->next_content )
if ( obj->wear_loc == iWear )
{
if( (!IS_NPC(ch)) && (ch->race>0) && (ch->race<MAX_PC_RACE))
send_to_char(race_table[ch->race]->where_name[iWear], ch);
else
send_to_char( where_name[iWear], ch );

if ( can_see_obj( ch, obj ) )
{
send_to_char( ", ", ch );
send_to_char( format_obj_to_char( obj, ch, TRUE ), ch );

}
else
send_to_char( "something.\n\r", ch );
found = TRUE;
}
send_to_char( ".", ch);
}
return;
}


I get this result...

..., a strong metal collar...., mail leggings., a pair of black combat boots., kid gloves....., a charm bracelet.., a menacing granitic blade., The Adventurer's Guide.........

I think I missed something.

~Xin
USA #7
Duh never mind, got it.

Thanks Meerc!

~Xin