creator.c

foundation2_fluffos_v1/lib/lib/creator.c · 2.5 KB

From the archive foundation2_fluffos_v1.zip

Download the archive   « Back to the archive contents

/*    /lib/creator.c
 *    from the Foundation II LPC Library
 *    a very simple creator object
 *    created by Descartes of Borg 950321
 */

#include <lib.h>
#include "creator.h"

inherit LIB_INTERACTIVE;

private int CreatorAge, CreatorBirth;
private string Gender;
private static int LastCreatorAge;

/* *****************  /lib/creator.c driver applies  ***************** */

static void create() {
    interactive::create();
    CreatorAge = 0;
    LastCreatorAge = time();
    CreatorBirth = time();
}

static void net_dead() {
    interactive::net_dead();
    CreatorAge += time() - LastCreatorAge;
    LastCreatorAge = time();
}

void restart_heart() {
    string tmp;

    interactive::restart_heart();
    LastCreatorAge = time();
    if( file_size(tmp = user_path(GetKeyName()) + "dead.edit") >0 )
      message("system", "\nYour edit file was saved as: "+tmp, this_object());
}

/* *****************  /lib/creator.c events  ***************** */

void eventDescribeEnvironment(int verbose) {
    object env;

    if( !(env = environment()) ) {
	message("room_description", "No environment.", this_object());
	return;
    }
    message("system", file_name(env), this_object());
    interactive::eventDescribeEnvironment(verbose);
}

/* *****************  /lib/creator.c  local functions ***************** */

int Setup() {
    string tmp;

    if( !interactive::Setup() ) return 0;
    AddChannel( ({ "cre", "intercre", "intergossip", "interchat", "foundation" }) );
    if( archp() ) AddChannel("admin");
    AddSearchPath( ({ DIR_CREATOR_CMDS, DIR_SECURE_CREATOR_CMDS }) );
    if( file_size(tmp = user_path(GetKeyName()) + "cmds") == -2 )
      AddSearchPath( ({ tmp }) );
    if( archp() ) AddSearchPath( ({ DIR_ADMIN_CMDS, DIR_SECURE_ADMIN_CMDS }) );
    return 1;
}

int eventForce(string cmd) {
    if( !((int)master()->valid_apply( ({ GetKeyName() }) )) ) return 0;
    else return interactive::eventForce(cmd);
}

/*  ***************  /lib/creator.c modal functions  *************** */

int CanCarry(int amount) { return 1; }

/* ************  /lib/creator.c data manipulation functions  ************ */  

int GetCreatorAge() { 
    int x;

    if( !interactive(this_object()) ) return CreatorAge;
    x = time() - LastCreatorAge;
    CreatorAge += x;
    LastCreatorAge = time();
    return CreatorAge; 
}

string SetGender(string gender) {
    if( !((int)master()->valid_apply( ({ GetKeyName() }) )) ) return Gender;
    else return (Gender = gender);
}

string GetGender() { return Gender; }

int GetCreatorBirth() { return CreatorBirth; }

Site Stats

Snippets: 1791
Codebases: 571