plate.c

skylib_mudos_v1/mudlib/obj/misc/plate.c · 1.4 KB

From the archive skylib_mudos_v1.tar.gz

Download the archive   « Back to the archive contents

/**
 * This is an inheritable for a plate, including cutlery.  You can put things
 * on it.  You can also eat food directly from the plate.  It was designed
 * for the pub_shop.c inheritable, for use with the meals that can be sold
 * there.
 * @author Lemming
 * @started 26/12/1999
 */

inherit "/std/surface";

/** @ignore */
void init() {
   TP->add_command( "eat", TO,
       "<indirect:object:direct-obs> {from|on} <direct:object:me>" );
   TP->add_command( "eat", TO, "from <direct:object:me>" );
} /* init() */

/** @ignore */
int do_eat( object *obs, string dir, string indir, mixed *args ) {
   object ob;
   object *food;

   if( sizeof( obs ) )
       food = copy( obs );
   else
       food = INV(TO);

   if( sizeof( food ) ) {
       food = filter( food, (: $1->query_edible() :) );
   } else {
       TP->add_failed_mess( TO, "There is nothing on $D.\n", ({ }) );
       return 0;
   }

   if( !sizeof( food ) ) {
       if( sizeof( obs ) )
           TP->add_failed_mess( TO, "You can't eat $I on $D!\n", obs );
       else
           TP->add_failed_mess( TO, "There is nothing edible on $D.\n",
               ({ }) );
       return 0;
   }

   add_succeeded_mess("$N $V $I from $D.\n", food );

   foreach( ob in food )
      ob->do_eat();

   return 1;
} /* do_eat() */

mapping query_static_auto_load() {
  if ( explode( file_name( TO ), "#" )[ 0 ] != "/obj/misc/plate" ) {
    return 0;
  }
  return int_query_static_auto_load();
}

Site Stats

Snippets: 1791
Codebases: 571