Author Topic: player.c help  (Read 1832 times)

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
player.c help
« on: October 03, 2006, 08:59:09 am »
Hey guys, as discussed on player.c Im almost there but need a little more help.  This is what the func should do when player A looks at player B:



> l test

Test the unaccomplished

Test is nondescript.

The male human is in decent shape.



silver sword (wielded in left hand)

emerald dagger (wielded in right hand)

magical breastplate (worn)

a hand axe

silver sword



Unfortunately this is what it does:



> l test

Test the unaccomplished

Test is nondescript.

The male human is in decent shape.



silver sword (wielded in left hand)

emerald dagger (wielded in right hand)



magical breastplate (worn)



a hand axe

silver sword



This is the code, if you could please help me get rid of the spaces I would be greatful.



code:


varargs string GetLong(string str) {
    mapping counts;
    mapping armors;
    mapping carried;
    string item;

    str = GetShort() + "\n";

    foreach(item in map(all_inventory(),
        (: (string)$1->GetAffectLong(this_object()) :)))
    if( item ) str += item + "\n";
    if(this_object()->GetAffectLong()) str += this_object()->GetAffectLong();

    str += interactive::GetLong() + "\n";
    str += living::GetLong(nominative(this_object()));

    counts = ([]);
    foreach(item in map(
        filter(all_inventory(), (: ((int)$1->GetWielded(this_object())) :)),
        (: (string)$1->GetEquippedShort() :)))
    if( item ) counts[item]++;
    if( sizeof(counts) ) str += "\n";
    foreach(item in keys(counts))
    str += (consolidate(counts[item], item)) + "\n";

    armors = ([]);
    foreach(item in map(
        filter(all_inventory(), (: !((int)$1->GetWielded(this_object())) && ((int)$1->GetWorn(this_object())) :)),
        (: (string)$1->GetEquippedShort() :)))
    if( item ) armors[item]++;
    if( sizeof(armors) ) str += "\n";
    foreach(item in keys(armors))
    str += (consolidate(armors[item], item)) + "\n";

    carried = ([]);
    foreach(item in map(
        filter(all_inventory(), (: !((int)$1->GetWielded(this_object())) && !((int)$1->GetWorn(this_object())) :)),
         (: (string)$1->GetEquippedShort() :)))
    if( item ) carried[item]++;
    if( sizeof(carried) ) str += "\n";
    foreach(item in keys(carried))
    str += (consolidate(carried[item], item)) + "\n";
    return str;


}


Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1022
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
player.c help
« Reply #1 on: October 03, 2006, 09:13:49 am »

My guess is that this is running once too many times:



if( sizeof(counts) ) str += "\n";





how about getting rid of it and doing something like this:



str += "\n"+(consolidate(armors[item], item));





instead of:



str += (consolidate(counts[item], item)) + "\n";





-Crat

http://dead-souls.net">http://dead-souls.net/