_to.c

tmi2_fluffos_v2/lib/cmds/std/_to.c · 956 B

From the archive tmi2_fluffos_v2.zip

Download the archive   « Back to the archive contents

/*
// File:	_to.c
// Mudlib:	TMI-II
// Author:	Pallando
// Real Name:	Douglas Reay
// Date V1.0:	1992 December 20
*/

#define TMP_FILE "/tmp/" + name + ".to"

#include <mudlib.h>

inherit DAEMON;

mapping strs = ([]);

int cmd_to( string a )
{
  string name;

  name = geteuid( this_player() );
  a = ( a ? (a + " ") : "" );
  strs[name] = a;
  write( "Input rest of command: " + a + "...\n" );
  this_player()-> edit( TMP_FILE, "done", this_object() );
  return 1;
}

mixed done()
{
  string str, name, text;

  name = geteuid( this_player() );
  text = read_file( TMP_FILE );
  if( !text ) text = "";
  else text = text[0..(strlen(text)-2)]; // gets rid of a duplicate \n
  rm( TMP_FILE );
  str = strs[name];
  map_delete( strs, name );
  return this_player()-> force_me( str + text );
}

int help()
{
  write( ""+
    "Syntax: to <string>\n"+
    "Effect: Lets you input text lines then forces you to do \"<string> <text>\"\n"+
    "" );
  return 1;
}

Site Stats

Snippets: 1791
Codebases: 571