generic note (#9)

(an instance of generic thing made by The_Mayor)

     There appears to be some writing on the note ...





VERB SOURCE CODE:

r*ead:
if (!this:is_readable_by(valid(caller_perms()) ? caller_perms() | player))
    player:tell("Sorry, but it seems to be written in some code that you can't read.");
else
    this:look_self();
    player:tell();
    player:tell_lines(this:text());
    player:tell();
    player:tell("(You finish reading.)");
endif
.


er*ase:
if (this:is_writable_by(valid(caller_perms()) ? caller_perms() | player))
    this:set_text({});
    player:tell("Note erased.");
else
    player:tell("You can't erase this note.");
endif
.


wr*ite:
if (this:is_writable_by(valid(caller_perms()) ? caller_perms() | player))
    this:set_text({@this.text, dobjstr});
    player:tell("Line added to note.");
else
    player:tell("You can't write on this note.");
endif
.


del*ete rem*ove:
if (!this:is_writable_by(player))
    player:tell("You can't modify this note.");
elseif (!dobjstr)
    player:tell("You must tell me which line to delete.");
else
    line = tonum(dobjstr);
    if (line < 0)
        line = (line + length(this.text)) + 1;
    endif
    if ((line <= 0) || (line > length(this.text)))
        player:tell("Line out of range.");
    else
        this:set_text(listdelete(this.text, line));
        player:tell("Line deleted.");
    endif
endif
.


encrypt:
set_task_perms(player);
key = $lock_utils:parse_keyexp(iobjstr, player);
if (typeof(key) == STR)
    player:tell("That key expression is malformed:");
    player:tell("  ", key);
else
    res = this.encryption_key = key;
    if (typeof(res) == ERR)
        player:tell(res, ".");
    else
        player:tell("Encrypted ", this.name, " with this key:");
        player:tell("  ", $lock_utils:unparse_key(key));
    endif
endif
.


decrypt:
set_task_perms(player);
res = dobj.encryption_key = 0;
if (typeof(res) == ERR)
    player:tell(res, ".");
else
    player:tell("Decrypted ", dobj.name, ".");
endif
.


text:
cp = caller_perms();
if ($perm_utils:controls(cp, this) || this:is_readable_by(cp))
    return this.text;
else
    return E_PERM;
endif
.


is_readable_by:
"Modified to change !key to key==0. Silly !### returns true so fails for single object 
locks., 2/17/94 Dredful";
key = this.encryption_key;
return (key == 0) || $lock_utils:eval_key(key, args[1]);
.


set_text:
cp = caller_perms();
newtext = args[1];
if ($perm_utils:controls(cp, this) || this:is_writable_by(cp))
    if (typeof(newtext) == LIST)
        this.text = newtext;
    else
        return E_TYPE;
    endif
else
    return E_PERM;
endif
.


is_writable_by:
who = args[1];
wr = this.writers;
if ($perm_utils:controls(who, this))
    return 1;
elseif (typeof(wr) == LIST)
    return who in wr;
else
    return wr;
endif
.


mailme @mailme:
"Usage:  mailme ";
"  uses $network to sends the text of this note to your REAL internet email address.";
if (!this:is_readable_by(player))
    return player:tell("Sorry, but it seems to be written in some code that you can't 
read.");
elseif (!player.email_address)
    return player:tell("Sorry, you don't have a registered email address.");
elseif (!$network.active)
    return player:tell("Sorry, internet mail is disabled.");
elseif (!(text = this:text()))
    return player:tell($string_utils:pronoun_sub("%T is empty--there wouldn't be 
any point to mailing it."));
endif
player:tell("Mailing ", this:title(), " to ", player.email_address, ".");
player:tell("... ", length(text), " lines ...");
suspend(0);
$network:sendmail(player.email_address, this:titlec(), @text);
.



PROPERTY DATA:
      writers
      encryption_key
      text

CHILDREN:
a newspaper generic letter Switching sign sign sign sign sign sign2 sign2 sign sign sign2 map sign2 sign2 sign3 WhoIsWho Generic Litter Pennyroyal Tea a garage door Project Proposal Johnathon's notebook page ripped out of a book page ripped from a poetry journal For_legba beer_token Advertisement For Neschek Redlance's Syllabus Danish Lexicon very little else scribblings sign sign sign scratchpad copy of Been Down So Long It Looks Like Up to Me Destination sign birthday card