initfix.c

ds2.1.1/lib/verbs/creators/initfix.c · 1.6 KB

From the archive ds2.1.1.zip

Download the archive   « Back to the archive contents

#pragma save_binary

#include <lib.h>
#include <daemons.h>
#include <modules.h>

inherit LIB_VERB;

static void create() {
    verb::create();
    SetVerb("initfix");
    SetRules("OBJ", "here");
    SetErrorMessage("initfix what?");
    SetHelp("Syntax: <initfix OBJ>\n\n"
      "If you have write permissions to the file of the object "
      "specified, this command adds an init(){} function. Lacking "
      "this function makes many objects break or behave unpredictably."
      "\nSee also: copy, create, delete, modify, reload, add");
}

mixed can_initfix_obj(string str) { 
    if(!creatorp(this_player())) 
	return "This command is only available to builders and creators.";
    else return 1;
}

mixed can_initfix_word(string str) { return can_initfix_obj("foo"); }

mixed do_initfix_obj(object ob) {
    object staff;
    staff = present("tanstaafl",this_player());
    if(!staff) {
	write("You must be holding the creator staff in order to use this command.");
	write("If you don't know where you put it, get another one from the chest ");
	write("in your workroom.");
	return 1;
    }

    if(ob->GetDoor()) ob = load_object(ob->GetDoor());

    if(first(base_name(ob),5) == "/lib/") {
	write("This appears to be a lib file. Aborting modification.");
	return 1;
    }

    if(interactive(ob)) {
	write("Players are not initfixable.");
	return 1;
    }

    if(staff->eventAddInit(base_name(ob)+".c") == 2) {
	write("File already has a working init function.");
    }

    else write("Done.");
    reload(ob);
    return 1;
}

mixed do_initfix_word(string wrd) {
    object ob = environment(this_player());
    return do_initfix_obj(ob);
}

Site Stats

Snippets: 1791
Codebases: 571