clone.c

foundation2_fluffos_v1/lib/cmds/creator/clone.c · 1.5 KB

From the archive foundation2_fluffos_v1.zip

Download the archive   « Back to the archive contents

/*    /cmds/creator/clone.c
 *    from the Foundation II LPC Library
 *    clones objects for cres
 *    created by Descartes of Borg 950409
 */

#include <lib.h>

inherit LIB_DAEMON;

mixed cmd(string args) {
    object ob;
    string file, res, nom;

    if( args == "" || !args ) return "Clone what?";
    file = absolute_path((string)this_player()->query_cwd(), args);
    if( file[<2..] != ".c" ) file = file + ".c";
    if( file_size(file) < 0 ) return "No such file " + file;
    if( res = catch(ob = new(file)) ) 
      return "Error in cloning object: " + res;
    if( !ob ) return "Failed to clone file: " + file;
    if( !((int)ob->eventMove(this_player())) &&
       !((int)ob->eventMove(environment(this_player()))) ) {
	message("system", "Failed to properly move the object.",
		this_player());
	return 1;
    }
    if( !(nom = (string)ob->GetShort()) ) nom = "something peculiar";
    if( !(res = (string)this_player()->GetMessage("clone", ob)) )
      res = (string)this_player()->GetName() + " clones " + nom + ".";
    message("system", "You clone " + nom + " (" + file + ").",
	    this_player());
    message("other_action", res, environment(this_player()), 
	    ({ this_player() }));
    return 1;
}

void help() {
    message("help", "Syntax: <clone [filename]>\n\n"
	    "Clones the object from the code stored in the file named.  "
	    "If for some reason the object cannot be moved to your "
	    "inventory (it is alive, you cannot carry it, etc.), then "
	    "it will be moved into your environment.\n\n"
	    "See also: dest", this_player());
}

Site Stats

Snippets: 1791
Codebases: 571