Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Inventory, equip, etc

Inventory, equip, etc

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


Posted by Xinphinity   USA  (26 posts)  Bio
Date Tue 20 May 2003 03:03 PM (UTC)
Message
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
Top

Posted by Boborak   USA  (228 posts)  Bio
Date Reply #1 on Tue 20 May 2003 09:34 PM (UTC)
Message
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 ;-)
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #2 on Wed 21 May 2003 01:28 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Xinphinity   USA  (26 posts)  Bio
Date Reply #3 on Wed 21 May 2003 12:31 PM (UTC)
Message
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
Top

Posted by Xinphinity   USA  (26 posts)  Bio
Date Reply #4 on Wed 21 May 2003 04:18 PM (UTC)
Message
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
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #5 on Wed 21 May 2003 05:22 PM (UTC)
Message
End of loop with necessary placement of final period.


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

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Xinphinity   USA  (26 posts)  Bio
Date Reply #6 on Wed 21 May 2003 05:41 PM (UTC)
Message
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
Top

Posted by Xinphinity   USA  (26 posts)  Bio
Date Reply #7 on Wed 21 May 2003 06:22 PM (UTC)
Message
Duh never mind, got it.

Thanks Meerc!

~Xin
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.


22,558 views.

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

Go to topic:           Search the forum


[Go to top] top

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