co_mmands.c

skylib_mudos_v1/mudlib/cmds/player/co_mmands.c · 1.2 KB

From the archive skylib_mudos_v1.tar.gz

Download the archive   « Back to the archive contents

/**
 * A command which shows what commands the player has.
 * Added 'commands playtester' which shows the commands
 * currently in playtesting - Sandoz, 13th September 2001.
 */
#include <command.h>
inherit COMMAND_BASE;

int cmd( int pt ) {
    string *cmds;
    int i;

    if( pt && playtesterp(TP) ) {
        if( !sizeof( cmds = CMD_D->GetCommands( DIR_PLAYTESTER_CMDS ) ) ) {
            add_failed_mess("There are no commands currently in "
                "playtesting.\n");
            return 0;
        }
        for( i = 0; i < sizeof(cmds); i++ )
          cmds[i] = replace( cmds[i], ({ "_", "" }) );

        write( "The commands currently in playtesting are:\n"+
               sprintf( "%-#*s\n", (int)TP->query_cols(),
               implode( sort_array( cmds, 1 ), "\n" ) ) );
        return 1;
    }
    write( "Your current commands are:\n"+ sprintf( "%-#*s\n",
         (int)TP->query_cols(), implode( sort_array(
         (string *)TP->query_known_commands(), 1 ), "\n" ) ) );
    return 1;
} /* cmd() */

mixed *query_patterns() {
  mixed pat = ({ "", (: cmd(0) :) });
  if( !playtesterp(TP) )
      return pat;
  else
      return pat + ({ "playtester", (: cmd(1) :) });
} /* query_patterns() */

Site Stats

Snippets: 1791
Codebases: 571