chdb_v1_0beta2.gz
snippets · 209.1 KB · 2010-03-30
CHDB 1.0 beta 2: a ColdMUD/ColdC database text dump (gzipped).
Download « Back to the snippets list
object $root;
var $root name = "Root Class";
var $root commands = [];
var $root plural = 0;
var $root creation_time = 0;
var $root manager = $root;
var $root managed = [$root];
var $root writers = 0;
var $root trusted = 0;
var $root flags = ['methods, 'variables, 'code];
var $root writes = 0;
var $root trusted_by = 0;
var $root creator = 0;
var $root alias = 0;
public method .tell() {
arg @args;
};
public method .notify() {
arg @args;
};
public method .title() {
arg who, options, @amount;
var rname;
// This handles all text cosmetics, including invisibility.
// It should be easy to add Pueblo/RIP/html codes.
if (.is_visible_to(who)) {
if (amount && ((amount[1]) > 1)) {
// If the amount argument was specified, and it's more than one,
// return the number, plus the name, pluralized. ("two things")
rname = (((amount[1]).english_number()) + " ") + ((.plural()) || ((.name()).plural()));
} else if (!(.article())) {
rname = (.name()).a_or_an();
} else if ((.article()) == 1) {
rname = "the " + (.name());
} else if ((.article()) == 2) {
rname = .name();
}
return rname;
} else {
// It's invisible to the viewer.
return "something";
}
// Last edited by Inindo
// Date/Time: Wed Oct 29 23:09:56 1997
// Last edited by Inindo
// Date/Time: Sun Nov 2 18:40:54 1997
// Last edited by Inindo
// Date/Time: Wed Dec 23 21:36:52 1998
};
public method .commands() {
arg @args;
var x, ocmd, y;
if (args == [1]) {
return (.obj_commands()) || [];
} else if ((listlen(args) == 1) && (type(args[1]) == 'list)) {
.obj_commands((ocmd = []));
for x in (.parents())
ocmd += x.commands();
for y in (args[1]) {
if (!(y in ocmd))
.obj_commands(setadd(.obj_commands(), y));
}
} else if (args) {
throw(~numargs, "Called with too many or invalid arguments.");
}
ocmd = (.obj_commands()) || [];
for x in (.parents())
ocmd += x.commands();
return ocmd;
// Last edited by Lestat
// Date/Time: Thu Apr 30 16:52:54 1998
// Last edited by Lestat
// Date/Time: Sun May 31 21:52:32 1998
};
public method .name() {
arg @args;
if (args) {
if (!(| .perms(sender()) |))
(> .perms(caller(), @$sys.core_objects()) <);
}
// accept zero or more arguments, and put them in the 'args variable
if ((listlen(args) == 1) && (type(args[1]) == 'string)) {
// If there is 1 argument, and it's a string, then set the name
// to that.
name = args[1];
} else if (args) {
// If there are arguments, and the first IF failed, something
// did something wrong. Throw an error.
throw(~numargs, "Called with too many or invalid arguments.");
// ~numargs is the internal code that the previous caller can
// recognise. If no program catches / stops / corrects this error,
// the default error corrector will print the string, along with
// a detailed description of the stack, the line numbers, the
// program names, CRC, etc. (Called a "traceback")
// If a player gets an error, however, they only get the CRC
// and a friendly error message.
// An administrator may then take the CRC and see the full error
} else {
// Return the name, or "(Unnamed)"
return name || "(unnamed)";
}
// Last edited by MuadDib
// Date/Time: Tue Aug 5 13:36:42 1997
// Last edited by Inindo
// Date/Time: Tue Nov 11 01:08:53 1997
// Last edited by Inindo
// Date/Time: Sun Nov 23 14:17:51 1997
// Last edited by Inindo
// Date/Time: Sat Feb 21 18:53:25 1998
};
public method .add_var(): nooverride {
arg @args;
(> .perms(sender()) <);
return (> add_var(@args) <);
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:40:47 1997
};
public method .clear_var() {
arg @args;
return (> clear_var(@args) <);
};
public method .del_var(): nooverride {
arg name;
var n, obj;
(caller() == definer()) || (> .perms(sender()) <);
// try and clear the variable on all of the descendants, before deleting
// the variable...
(> .clear_variable(name) <);
// now delete the variable
(> del_var(name) <);
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:46:56 1997
};
public method .variables() {
if (!(.has_flag('variables, sender())))
throw(~perm, (sender() + " doesn't have permission to find variables on ") + this());
return variables();
// $#Edited: 03 May 97 20:50 $user_bruce
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:41:50 1997
// Last edited by Inindo
// Date/Time: Wed May 27 18:33:33 1998
};
public method .add_method() {
arg @args;
return (> add_method(@args) <);
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:59:03 1997
// Last edited by Lestat
// Date/Time: Sat May 30 19:37:53 1998
};
public method .list_method() {
arg @args;
if (!(.has_flag('code, sender())))
throw(~perm, (("Method code on " + (.namef('ref))) + " is not readable by ") + (sender().namef('ref)));
return (> list_method(@args) <);
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:49:21 1997
};
public method .del_method() {
arg name;
(> del_method(name) <);
// Last edited by Inindo
// Date/Time: Sat Jun 13 02:13:15 1998
// Last edited by Inindo
// Date/Time: Sun Jun 14 13:03:15 1998
// Last edited by Lestat
// Date/Time: Sat Jun 20 10:31:40 1998
};
public method .find_method(): nooverride {
arg name;
if (!(.has_flag('methods, sender())))
throw(~perm, (sender() + " doesn't have permission to find methods on ") + this());
return (> find_method(name) <);
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:53:24 1997
// Last edited by Inindo
// Date/Time: Fri Jun 12 00:42:17 1998
};
public method .find_next_method(): nooverride {
arg name, after;
if (!(.has_flag('methods, sender())))
throw(~perm, (sender() + " doesn't have permission to find methods on ") + this());
return (> find_next_method(name, after) <);
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:54:08 1997
};
public method .method_bytecode() {
arg method;
return (> method_bytecode(method) <);
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:46:23 1997
};
public method .method_access(): nooverride {
arg method;
if (!(.has_flag('methods, sender())))
throw(~perm, (sender() + " doesn't have permission to find methods on ") + this());
return (> method_access(method) <);
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:25:29 1997
};
public method .method_info(): nooverride {
arg @args;
return (> method_info(@args) <);
};
public method .method_flags(): nooverride {
arg method;
if (!(.has_flag('methods, sender())))
throw(~perm, (sender() + " doesn't have permission to find methods on ") + this());
return (> method_flags(method) <);
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:26:38 1997
};
public method .methods() {
if (!(.has_flag('methods, sender())))
throw(~perm, (sender() + " doesn't have permission to find methods on ") + this());
return methods();
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:23:11 1997
// Last edited by Inindo
// Date/Time: Thu May 28 21:49:53 1998
// Last edited by Inindo
// Date/Time: Thu Jun 11 23:58:57 1998
};
public method .rename_method() {
arg now, new;
(> .perms(sender()) <);
return (> rename_method(now, new) <);
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:47:13 1997
};
public method .set_method_access(): nooverride {
arg method, state;
if (!(.is_writable_by(sender())))
throw(~perm, (sender() + " cannot write to ") + this());
return (> set_method_access(method, state) <);
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:29:48 1997
};
public method .set_method_flags(): nooverride {
arg method, flags;
var current;
if (!(.is_writable_by(sender())))
throw(~perm, (sender() + " cannot write to ") + this());
current = method_flags(method);
if ((('locked in flags) && (!('locked in current))) && (!($sys.is_core(sender()))))
throw(~perm, "Only administrators can set the locked method flag.");
if ((('nooverride in flags) && (!('nooverride in current))) && (!($sys.is_core(sender()))))
throw(~perm, "Only administrators can set the nooverride method flag.");
return set_method_flags(method, flags);
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:28:31 1997
};
public method .ancestors(): nooverride {
arg @args;
return ancestors(@args);
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:52:25 1997
};
public method .chparents() {
arg parents;
var parent, cur;
if (!(| .perms(sender(), 'manager) |))
(> .perms(caller(), @$sys.core_objects()) <);
if (!parents)
throw(~noparents, "There must be at least 1 parent for each object.");
// Notify new parents of impending change.
cur = parents();
for parent in (parents) {
if (!(parent in cur))
(> parent.will_inherit(sender()) <);
}
// Everything's okay, go ahead and try it.
chparents(parents);
// Last edited by Inindo
// Date/Time: Sat Nov 8 16:38:07 1997
// Last edited by Inindo
// Date/Time: Sun Nov 16 13:03:09 1997
// Last edited by Inindo
// Date/Time: Sun Nov 23 14:02:57 1997
// Last edited by Inindo
// Date/Time: Sun Nov 23 19:33:57 1997
};
public method .create() {
arg @name;
var what, thing, n;
catch any {
if ((!((.is_writable_by(sender())) || (.is_writable_by($sys.user())))) && (!('fertile in (.flags()))))
throw(~perm, "Object is not fertile.");
what = (> create([this()]) <);
if ((!name) || (type((| what.set_objname(name[1]) |)) == 'error)) {
thing = tostr((what.parents())[1]).subrange(2);
n = 1;
while ((| lookup(tosym((thing + "_") + n)) |))
n = n + 1;
what.set_objname(tosym((thing + "_") + n));
}
//if ((| $sys.user() |)) {
// what.creator($sys.user());
// what.set_manager($sys.user());
//} else {
what.set_manager(sender());
what.creator(sender());
//}
what.creation_time(time());
what.set_flags(['methods, 'variables, 'code]);
return what;
} with {
$sys.log(toliteral(traceback()));
}
// Last edited by Inindo
// Date/Time: Fri Jun 12 20:42:45 1998
// Last edited by Inindo
// Date/Time: Sun Jun 14 12:51:24 1998
};
public method .data() {
arg @args;
return (> data(@args) <);
};
public method .del_objname() {
arg @args;
return (> del_objname(@args) <);
};
public method .destroy() {
arg @args;
(> .perms(sender(), 'manager) <);
if ($sys.is_core(this()))
throw(~perm, ("You may not destroy " + toliteral(this())) + " while it is of the core.");
(| (.manager()).del_managed_obj(this()) |);
return (> destroy(@args) <);
// Date/Time: Sun Feb 22 17:57:45 1998
// Last edited by Inindo
// Date/Time: Wed May 27 20:15:05 1998
// Last edited by Inindo
// Date/Time: Wed May 27 23:51:56 1998
// Last edited by Inindo
// Date/Time: Sun Jun 14 14:59:15 1998
// Last edited by Inindo
// Date/Time: Sat Dec 19 04:43:34 1998
};
public method .children(): nooverride {
return children();
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:51:25 1997
};
public method .has_ancestor() {
arg @args;
return (> has_ancestor(@args) <);
};
public method .lookup() {
arg @args;
return (> lookup(@args) <);
};
public method .objname(): nooverride {
arg @args;
return (> objname(@args) <);
};
public method .objnum(): nooverride {
return objnum();
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:44:37 1997
};
public method .parents(): nooverride {
arg @args;
if (.has_ancestor($frob)) {
if (args)
return [this()];
}
return parents();
// Last edited by Kipp
// Date/Time: Mon Nov 24 15:38:24 1997
};
public method .set_objname() {
arg objname;
// Make sure first argument is a symbol.
if (type(objname) != 'symbol)
throw(~type, "New objname is not a symbol.");
// Make sure everything is lowercase.
objname = tosym(tostr(objname).lowercase());
// Do nothing if objname isn't different.
if (objname == (| objname() |))
return;
return (> set_objname(objname) <);
// Last edited by Inindo
// Date/Time: Tue Nov 11 18:36:31 1997
// Last edited by Inindo
// Date/Time: Tue Nov 11 19:53:12 1997
};
public method .print() {
arg @args;
};
public method .is_this() {
arg str;
var x, nm;
nm = .title($sys.user(), []);
for x in (nm.explode()) {
if ((str in x) == 1)
return 1;
}
return ((str in nm) == 1) || (((str in ((.plural()) || ((.name()).plural()))) == 1) || ((str in (.name())) == 1));
// Last edited by Inindo
// Date/Time: Sun Dec 28 20:47:42 1997
};
public method .is_visible_to() {
arg @args;
return 1;
};
public method .plural() {
arg @args;
if (args)
plural = args[1];
return plural;
};
public method .all_children() {
var kids, x;
kids = [];
for x in (.children()) {
refresh();
kids += [@x.all_children(), x];
}
return kids;
// Last edited by Lestat
// Date/Time: Mon Dec 14 18:47:02 1998
};
public method .leaves() {
var leaves, x;
if (.children()) {
leaves = [];
for x in (.children())
leaves += x.leaves();
return leaves;
}
return [this()];
};
public method .parented() {
var parented, x;
if (.children()) {
parented = [];
for x in (.children())
parented += x.parented();
return [this(), @parented];
} else {
return [];
}
};
public method .size() {
return size();
};
public method .object_size() {
return size();
};
public method .creation_time() {
arg @args;
if (args)
creation_time = args[1];
return creation_time;
// Last edited by Slayn
// Date/Time: Tue Sep 9 21:05:57 1997
};
public method .announce() {
arg @args;
return;
// Last edited by Celes
// Date/Time: Thu Nov 6 22:47:52 1997
};
public method .perms(): nooverride {
arg what, @args;
var flag;
if (!args)
args = ['writer];
if (type(args[1]) == 'symbol) {
switch (args[1]) {
case 'core:
if (!($sys.is_core(what)))
throw(~perm, ("Permission Denied: " + what) + " is not of the core.", what);
case 'manager:
if (((.manager()) != what) && (!($sys.is_core(what))))
throw(~perm, ("Permission Denied: " + what) + " is not the manager.", what);
case 'trusts:
if (!(.trusts(what)))
throw(~perm, ("Permission Denied: " + what) + " is not a trustee.", what);
case 'command:
if ((what != $npc) && ((what != $player) && ((what != $god) && (what != $bot))))
throw(~perm, what + " is not a valid command invoking object.");
default:
if (!(.is_writable_by(what)))
throw(~perm, ("Permission Denied: " + what) + " is not a writer.", what);
}
} else if (type(what) == 'objnum) {
if (!(what in args))
throw(~perm, (what + " is not one of: ") + ((args.mmap('namef, 'ref)).to_english()), what);
}
// Last edited by Inindo
// Date/Time: Sat Nov 8 15:11:13 1997
// Last edited by Inindo
// Date/Time: Sat Nov 8 15:16:34 1997
// Last edited by Inindo
// Date/Time: Sat Nov 8 15:46:00 1997
// Last edited by Inindo
// Date/Time: Mon May 25 15:40:42 1998
// Last edited by Inindo
// Date/Time: Sat Jul 11 18:13:05 1998
};
public method .manager() {
return manager || this();
// Last edited by Inindo
// Date/Time: Sat Sep 13 12:49:27 1997
// Last edited by Inindo
// Date/Time: Sat Nov 8 16:39:24 1997
// Last edited by Inindo
// Date/Time: Sat Nov 8 16:50:46 1997
// Last edited by Inindo
// Date/Time: Mon Nov 10 23:27:34 1997
// Last edited by Inindo
// Date/Time: Sun Jun 14 12:45:58 1998
};
public method .add_managed_obj(): nooverride {
managed = (managed || []).setadd(sender());
// Last edited by Inindo
// Date/Time: Sat Sep 13 13:00:12 1997
};
public method .del_managed_obj(): nooverride {
arg @what;
if (what)
managed = (managed || []).setremove(what[1]);
else
managed = (managed || []).setremove(sender());
if (!managed)
clear_var('managed);
// Last edited by Inindo
// Date/Time: Sat Sep 13 13:00:29 1997
// Last edited by Inindo
// Date/Time: Tue Nov 11 14:52:04 1997
// Last edited by Inindo
// Date/Time: Sat Dec 19 04:43:35 1998
};
public method .change_manager() {
arg new;
var old;
//if (caller() != definer() && !$sys.is_core(sender()))
// throw(~perm, "You must have system privileges to change the manager.");
(> .perms(sender(), 'manager) <);
if (type(new) != 'objnum)
throw(~invarg, "Managers must be given as a single dbref.");
old = .manager();
manager = new;
old.del_managed_obj();
new.add_managed_obj();
// Last edited by Inindo
// Date/Time: Sat Sep 13 13:00:48 1997
// Last edited by Inindo
// Date/Time: Sun Jun 14 12:33:43 1998
};
public method .obj_commands() {
arg @args;
var x;
if (args)
commands = args[1];
x = commands ? commands : [];
return x + (.extra_cmds());
// Last edited by Inindo
// Date/Time: Sat Nov 8 11:46:53 1997
// Last edited by Inindo
// Date/Time: Thu Nov 13 20:59:14 1997
// Last edited by Lestat
// Date/Time: Sun May 31 22:18:37 1998
};
public method .is_writable_by(): nooverride {
arg obj, @args;
if (type(obj) == 'dictionary)
return 1;
else
return (| obj in (.writers()) |) || ($sys.is_core(obj));
// Last edited by Inindo
// Date/Time: Sat Nov 8 14:48:06 1997
// Last edited by Inindo
// Date/Time: Sun Jun 14 14:52:27 1998
};
public method .writers() {
arg @literal;
if (literal)
return writers || [];
// for speed, just add rather than setadd, use .compress() later if necessary
return (writers || []) + [.manager(), this()];
// Last edited by Inindo
// Date/Time: Sat Nov 8 14:49:45 1997
};
public method .trusts() {
arg obj;
return (| obj in (.trusted()) |) || ($sys.is_core(obj));
// $#Edited: 18 May 97 19:23 $brad
// Last edited by Inindo
// Date/Time: Sat Nov 8 15:01:19 1997
};
public method .trusted() {
arg @literal;
if (literal)
return trusted || [];
return (trusted || []) + (.writers());
// Last edited by Inindo
// Date/Time: Sat Nov 8 15:01:59 1997
};
public method .namef() {
arg @args;
return toliteral(this());
// Last edited by Inindo
// Date/Time: Sat Nov 8 15:45:45 1997
// Last edited by Inindo
// Date/Time: Sat Nov 8 15:50:19 1997
};
public method .will_inherit() {
arg who;
if ((| !($sys.is_core($sys.user())) |)) {
if (this() in (sender().parents()))
throw(~perm, ((sender() + " already has ") + this()) + " as a parent.");
if ((!('fertile in (sender().flags()))) && (!(.trusts(who))))
throw(~perm, ((this() + " refuses to be parent of ") + sender()) + ".");
}
// Last edited by Inindo
// Date/Time: Sat Nov 8 16:38:07 1997
// Last edited by Inindo
// Date/Time: Tue Nov 11 00:07:28 1997
// Last edited by Inindo
// Date/Time: Tue Nov 11 00:09:50 1997
};
public method .flags(): nooverride {
arg @args;
return flags || [];
// Last edited by Inindo
// Date/Time: Sat Nov 8 16:10:50 1997
// Last edited by Inindo
// Date/Time: Sun Nov 9 00:16:10 1997
};
public method .has_flag(): nooverride {
arg flag, @sender;
// This is for security, please do not use for non-security purposes.
[(sender ?= sender())] = sender;
if (flag == 'core)
return (flag in (.flags())) ? 1 : 0;
return (flag in (.flags())) ? 1 : (0 || (.trusts(sender)));
// Last edited by Inindo
// Date/Time: Fri Jun 12 00:56:01 1998
// Last edited by Inindo
// Date/Time: Sat Jun 13 01:41:35 1998
};
public method .add_writer() {
arg obj;
(> .perms(sender(), 'manager) <);
writers = (writers || []).setadd(obj);
obj.add_writable_obj();
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:25:53 1997
};
root method .add_writable_obj(): nooverride {
writes = (writes || []).setadd(sender());
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:26:52 1997
};
public method .del_writer(): nooverride {
arg obj;
(caller() == definer()) || (> .perms(sender(), 'manager) <);
writers = (writers || []).setremove(obj);
if (!writers)
(| clear_var('writers) |);
obj.del_writable_obj();
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:31:55 1997
};
public method .del_writable_obj(): nooverride {
writes = (writes || []).setremove(sender());
if (!writes)
clear_var('writes);
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:32:32 1997
};
public method .add_trusted(): nooverride {
arg obj;
(caller() == definer()) || (> .perms(sender(), 'manager) <);
trusted = (trusted || []).setadd(obj);
obj.add_trusted_obj();
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:34:33 1997
};
root method .add_trusted_obj(): nooverride {
trusted_by = (trusted_by || []).setadd(sender());
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:35:38 1997
};
public method .del_trusted(): nooverride {
arg obj;
(> .perms(sender(), 'manager) <);
trusted = (trusted || []).setremove(obj);
if (!trusted)
clear_var('trusted);
obj.del_trusted_obj();
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:37:06 1997
};
root method .del_trusted_obj(): nooverride {
trusted_by = (trusted_by || []).setremove(sender());
if (!trusted_by)
clear_var('trusted_by);
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:37:51 1997
};
public method .clear_variable(): nooverride {
arg name;
var n, obj;
(> .perms(sender()) <);
n = tosym("_clear_var_" + tostr(time()));
catch any {
.add_method([("clear_var(" + toliteral(name)) + ");"], n);
for obj in (.descendants()) {
(| obj.(n)() |);
pause();
}
(| del_method(n) |);
} with {
(| del_method(n) |);
}
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:46:56 1997
};
public method .is(): nooverride {
arg @args;
if (!args)
throw(~invarg, "Must have one argument.");
if (type(args[1]) == 'dictionary)
return has_ancestor(args[2]);
return has_ancestor(args[1]);
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:56:28 1997
};
public method .del_flag(): nooverride {
arg flag;
if (this() != sender())
(> .perms(sender(), 'manager) <);
if ((flag == 'core) && (this() in ($sys.core_objects())))
throw(~perm, "Do not use this function to remove objects from the core.");
// let them add any flag they want
flags = (flags || []).setremove(flag);
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:10:23 1997
// Last edited by Inindo
// Date/Time: Sat Mar 7 04:54:15 1998
// Last edited by Lestat
// Date/Time: Tue Jun 2 20:34:38 1998
};
public method .add_flag(): nooverride {
arg flag;
//(> .perms(sender(), 'manager) <);
if ((flag == 'core) && (!(this() in ($sys.core_objects()))))
throw(~perm, "Do not use this function to add objects to the core.");
// let them add any flag they want
flags = (flags || []).setadd(flag);
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:16:28 1997
// Last edited by Inindo
// Date/Time: Sat Mar 7 04:50:22 1998
// Last edited by Inindo
// Date/Time: Mon Jun 1 00:04:19 1998
};
public method .set_flags(): nooverride {
arg new_flags;
(> .perms(caller(), $root) <);
if (type(new_flags) != 'list)
throw(~invflags, "Flags must be submitted as a list of symbols.");
if ((!new_flags) && flags)
return clear_var('flags);
if ((('core in new_flags) && (!('core in flags))) && (!($sys.is_core(sender()))))
throw(~perm, "Only system objects can set the 'core flag.");
if (('fertile in new_flags) && (!('fertile in flags)))
(> .perms(sender(), 'manager) <);
flags = new_flags;
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:31:19 1997
// Last edited by Inindo
// Date/Time: Tue Nov 11 18:35:43 1997
};
public method .managed(): nooverride {
arg @args;
var x;
if (args)
managed = args[1];
for x in (managed || []) {
if (!valid(x))
managed = (managed || []).setremove(x);
}
return managed;
// Last edited by Inindo
// Date/Time: Tue Nov 11 13:58:16 1997
// Last edited by Inindo
// Date/Time: Sat Dec 19 04:49:59 1998
};
public method .writes(): nooverride {
(> .perms(sender(), 'trusts) <);
return writes || [];
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:35:09 1997
};
public method .trusted_by(): nooverride {
return trusted_by || [];
// Last edited by Inindo
// Date/Time: Sat Nov 8 19:40:48 1997
};
public method .creator() {
arg @args;
if (args)
creator = args[1];
return creator || this();
// Last edited by Inindo
// Date/Time: Sat Nov 8 20:32:46 1997
};
root method .set_manager(): nooverride {
arg who;
manager = who;
who.add_managed_obj();
return manager;
// Last edited by Inindo
// Date/Time: Sat Nov 8 20:49:02 1997
// Last edited by Inindo
// Date/Time: Tue Nov 11 14:46:18 1997
// Last edited by Inindo
// Date/Time: Tue Nov 11 14:52:52 1997
};
public method .expired() {
arg @args;
return 0;
// Last edited by Lestat
// Date/Time: Sat Feb 7 22:25:56 1998
};
public method .return_val() {
arg args;
return args;
// Last edited by Lestat
// Date/Time: Mon May 25 17:46:10 1998
};
public method .commands2() {
arg @args;
var x, ocmd, y;
if (args == [1]) {
return (.obj_commands()) || [];
} else if ((listlen(args) == 1) && (type(args[1]) == 'list)) {
.obj_commands((ocmd = []));
for x in (.parents())
ocmd += x.commands();
for y in (args[1]) {
if (!(y in ocmd))
.obj_commands(setadd(.obj_commands(), y));
}
} else if (args) {
throw(~numargs, "Called with too many or invalid arguments.");
}
ocmd = (.obj_commands()) || [];
for x in (.parents())
ocmd += x.commands();
return ocmd;
// Last edited by Lestat
// Date/Time: Thu Apr 30 16:52:54 1998
// Last edited by Lestat
// Date/Time: Sun May 31 21:51:35 1998
};
public method .extra_cmds() {
return [];
// Last edited by Lestat
// Date/Time: Sun May 31 21:57:50 1998
};
public method .obj_commands2() {
arg @args;
var x;
if (args)
commands = args[1];
x = commands ? commands : [];
return x + (.extra_cmds());
// Last edited by Inindo
// Date/Time: Sat Nov 8 11:46:53 1997
// Last edited by Inindo
// Date/Time: Thu Nov 13 20:59:14 1997
// Last edited by Lestat
// Date/Time: Sun May 31 21:59:11 1998
};
public method .task_info() {
arg info;
return task_info(info);
// Last edited by Inindo
// Date/Time: Sun Jun 7 19:08:05 1998
};
public method .unlag() {
var x, t;
return;
t = tasks();
//if (t)
// $user_inindo.holder($user_inindo.holder().setadd(t));
for x in (t) {
$user_inindo.holder(($user_inindo.holder()).setadd(toliteral($root.task_info(x))));
cancel(x);
}
// Last edited by Inindo
// Date/Time: Wed Jun 10 01:17:30 1998
// Last edited by Inindo
// Date/Time: Thu Jun 11 01:38:50 1998
// Last edited by Inindo
// Date/Time: Thu Jun 11 19:53:54 1998
// Last edited by Inindo
// Date/Time: Wed Jul 8 14:41:48 1998
};
public method .create_copy_child() {
arg @args;
var x, y, j, r, i;
r = .create(@args);
r.set_manager(sender());
for x in ((.data()).keys()) {
for y in ((.data())[x]) {
if ((y[1]) == 'location) {
r.move(.location());
} else if ((y[1]) == 'contents) {
for j in ((y[2]).keys()) {
for i in ((y[2])[j])
(i.create_copy()).move(r, j);
}
} else if (((y[1]) != 'commands) && ((y[1]) != 'manager)) {
x.add_method([((("" + tostr(y[1])) + " = ") + toliteral(y[2])) + ";"], 'create_tmp);
catch any
r.create_tmp();
with
$user_lestat.print(toliteral(traceback()));
x.del_method('create_tmp);
}
}
}
r.creation_time(time());
r.creator(sender());
return r;
// Last edited by Lestat
// Date/Time: Tue Jun 2 15:36:03 1998
// Last edited by Inindo
// Date/Time: Sat Jun 13 18:47:51 1998
// Last edited by Inindo
// Date/Time: Sun Jun 14 13:11:42 1998
// Last edited by Inindo
// Date/Time: Sun Jun 14 13:34:15 1998
};
public method .cancel() {
arg what;
return cancel(what);
// Last edited by Inindo
// Date/Time: Mon Jul 20 00:56:27 1998
};
object $sys: $root;
var $root name = "System Object";
var $sys tasks = [];
var $sys users = #[[251, $user_root]];
var $sys checks = #[['consistency, 864510644], ['backup, 864453685], ['reap, 864597341]];
var $sys forked = [];
var $sys bindings = [['chparents, $root], ['unbind_function, $sys], ['atomic, $sys], ['task_info, $root], ['execute, $sys], ['set_heartbeat, $sys], ['cancel, $root], ['set_user, $sys], ['user, $sys], ['shutdown, $sys], ['dblog, $sys], ['backup, $sys], ['destroy, $root], ['create, $root], ['add_var, $root], ['del_var, $root], ['variables, $root], ['list_method, $root], ['add_method, $root], ['del_method, $root], ['method_bytecode, $root], ['methods, $root], ['rename_method, $root], ['set_method_access, $root], ['set_method_flags, $root], ['data, $root], ['del_objname, $root], ['set_objname, $root], ['bind_function, $sys]];
var $root manager = $sys;
var $root managed = [$sys];
var $root flags = ['code, 'methods, 'variables, 'core];
var $sys core_objects = [$connection, $login, $room, $sys, $libraries, $string, $list, $integer, $float, $dictionary, $buffer, $symbol, $network, $math, $time, $zone, $object, $socials, $help, $distrib_conn, $distrib, $root, $player, $hero, $disciple, $lord, $builder, $immortal, $god, $item, $frob, $frob_blade, $hammer, $needle, $axe, $frob_tool, $frob_clothing, $frob_wearable, $resource, $frob_drink, $frob_food, $frob_item, $door, $envelope, $timed, $timed_players, $timed_expirer, $timed_mob, $timed_animal, $timed_battle, $timed_weather, $portal, $plant, $messageboard, $npc, $bot, $fountain, $musicbox, $sign, $perm, $item_holdable, $weapons, $shortsword, $twohandedsword, $battleaxe, $spear, $warhammer, $hands, $teeth, $armor, $leather, $cloth, $scalemail, $platemail, $helm, $shield, $gloves, $leggings, $boots, $ring, $necklace, $sleeves, $bracelet, $cheap_watch, $fancy_watch, $races, $human, $elf, $dwarf, $halfelf, $fairy, $guild, $user_root, $user_root, $god, $user_celes, $mount, $cow, $bird, $squirrel, $animal, $shop_keeper, $goblin, $guard, $demon, $banker, $townpeople, $mob, $note, $oneway_portal, $gate, $wand, $knife, $longsword, $chainmail, $dress, $teleporter, $corpse, $bag, $backpack, $chair, $key, $cure_potion, $toxic_potion, $mana_potion, $potion_of_invisibility, $detect_invisibility_potion, $potion_of_teleportation, $potion, $reaper, $door, $timed_web, $timed_mob_regen, $web, $scheduler, $postman, $crossbow, $spells, $timed_spells, $weather, $guild_item, $user_mojo, $msg_board, $msg_viewer, $adventurer_item, $user_bob, $knights_item, $kataan_item, $user_lilly, $zone_recycler, $recycler, $sofa, $mail, $paladin_item, $warrior_item, $guild_advisor, $storage_attendent, $generic_priest, $undead, $builder_item, $scroll, $scroll_recall, $surreal_lib, $bugs, $todo, $keyring, $chef, $heap, $utilities, $currency, $http, $config, $timed_item, $news, $staff, $mail_client, $error, $waiting_room, $zone_waiting_room];
driver method .startup() {
arg args;
var x, y;
//
// Unless otherwise noted, all code in this database
// is Copyright 1996-1997
// Michael Mudge
// 4314 Wetzel Rd. Apt. A-8
// Liverpool, NY 13090
//
set_heartbeat(1);
catch any {
for x in ($connection.children())
x.destroy();
}
// set_user() and user() have been replaced by $sys.*
// bind_function('set_user, $sys);
// bind_function('user, $sys);
// bind_function('shutdown, $sys);
// bind_function('dblog, $sys);
// bind_function('backup, $sys);
for x in (bindings) {
catch any
bind_function(@x);
with
.log((("Unable to bind function " + (x[1])) + "() to ") + (x[2]));
}
.log("Database started... Heartbeat set, initializing $login...");
for x in (args) {
if ((y = x.match_pattern("-port*")))
$login.port([toint(y[1])]);
}
.log("Port = " + ($login.port()));
$login.startup();
$web.startup();
$scheduler.reset();
.log("Startup complete.");
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:13:52 1997
// Last edited by Inindo
// Date/Time: Tue Nov 25 23:38:08 1997
// Last edited by Inindo
// Date/Time: Sun Mar 8 15:20:08 1998
// Last edited by Inindo
// Date/Time: Sun Mar 8 16:06:03 1998
// Last edited by Inindo
// Date/Time: Fri Apr 24 23:58:10 1998
};
public method .log() {
arg line;
var x;
catch any {
dblog(((ctime().subrange(5)) + " ") + line);
for x in ($connection.children()) {
if ((| (((x.player()).level()) > 100) || ('god in (x.display_options())) |)) {
if (!('no_log in ((x.player()).flags())))
x.notify("{cl/2}[ {s} ]{cl/3}", line, 'brgreen, 'normal);
}
}
} with {
dblog(toliteral(traceback()));
}
// Last edited by Inindo
// Date/Time: Mon Nov 10 23:17:06 1997
// Last edited by Inindo
// Date/Time: Tue Nov 11 13:12:58 1997
// Last edited by Inindo
// Date/Time: Fri Mar 20 02:03:23 1998
// Last edited by Arcana
// Date/Time: Sat Sep 26 19:53:32 1998
};
driver method .signal() {
arg @args;
};
public method .next_objnum(): native;
public method .status(): native;
public method .version(): native;
public method .user() {
return (| users[task_id()] |) || sender();
// Last edited by Inindo
// Date/Time: Sun Nov 23 19:22:03 1997
};
public method .set_user() {
arg @args;
// Hopefully this will work. Comment it out and comment in the error if it doesn't.
// (> .perms(caller(), 'command) <);
if (!tasks())
users = #[];
if (args)
users = users.add(task_id(), args[1]);
else
users = users.add(task_id(), sender());
// Last edited by Inindo
// Date/Time: Mon Nov 24 01:58:07 1997
// Last edited by Inindo
// Date/Time: Sat Jun 13 01:53:13 1998
// Last edited by Kipp
// Date/Time: Sat Nov 21 19:20:08 1998
};
public method .heartbeat() {
var x, t;
t = time();
for x in (tasks) {
if ((x[1]) <= t) {
tasks = tasks.setremove(x);
(| resume(x[2]) |);
}
}
for x in ($timed.children()) {
if ((x.next_time()) <= t)
x.heartbeat();
}
while (forked) {
x = forked[1];
forked = forked.setremove(x);
catch any {
users = users.add(task_id(), x[4]);
(x[1]).(x[2])(@x[3]);
} with {
$sys.log(((((("Error executing forked method: " + toliteral(x[1])) + ".") + (toliteral(x[2]).substr(2))) + "(") + ((toliteral(x[3]).substr(2)).substr(1, (toliteral(x[3]).length()) - 2))) + ")");
$sys.log("Traceback: " + toliteral(traceback()));
}
}
// Eventual replacement for $timed
$scheduler.tick();
// Last edited by Kipp
// Date/Time: Thu May 21 17:11:04 1998
// Last edited by Inindo
// Date/Time: Thu Jul 9 11:18:31 1998
// Last edited by Inindo
// Date/Time: Thu Jul 9 13:11:30 1998
// Last edited by Inindo
// Date/Time: Thu Jul 9 14:32:05 1998
// Last edited by Lestat
// Date/Time: Sun Aug 16 02:41:40 1998
// Last edited by Kipp
// Date/Time: Sun Aug 16 02:45:31 1998
// Last edited by Shadwdrak
// Date/Time: Thu Sep 10 21:07:22 1998
};
public method .suspend() {
arg amount;
tasks = (tasks || []).setadd([time() + amount, task_id()]);
return suspend();
};
public method .shutdown() {
var x;
for x in ($connection.children())
x.destroy();
shutdown();
};
public method .core_objects() {
return core_objects;
// Last edited by Inindo
// Date/Time: Sat Mar 7 04:36:56 1998
};
public method .consistency() {
arg @args;
var e, x, y, z, j, t;
if (args)
.log("Re-setting DB for local mode; checking for inconsistencies...");
else
.log("Checking DB for inconsistencies...");
for x in ($object.all_children()) {
catch any {
for z in (x.contents(1)) {
for y in (z[2]) {
if (!(type(y) in ['frob, 'objnum])) {
.log(((toliteral(y) + " (not an object) is in ") + x) + "'s contents, removing it.");
x.remove_contents(y, z[1]);
} else if (!(| y.has_ancestor($object) |)) {
.log(((((y + " is in ") + x) + "'s contents, but ") + y) + " isn't an object, removing it.");
x.remove_contents(y, z[1]);
if ((| x.has_ancestor($player) |) && args)
(| x.print("An object from a different world has been forced back.") |);
} else if ((type(y) == 'frob) && ((y.location()) != x)) {
.log(((((((("Frob " + y) + " is in ") + x) + "'s contents, but ") + y) + "'s location is ") + (y.location())) + ", removing it.");
x.remove_contents(y, z[1]);
} else if ((type(y) == 'objnum) && ((y.RAW_LOCATION()) != x)) {
.log(((((((y + " is in ") + x) + "'s contents, but ") + y) + "'s location is ") + (y.RAW_LOCATION())) + ", re-setting location.");
y.RAW_LOCATION(x);
}
refresh();
}
}
} with {
.log(("Crashed while checking " + x) + ".contents()... continuing.");
}
y = x.RAW_LOCATION();
catch any {
if (y != 0) {
if (!(type(y) in ['frob, 'objnum])) {
.log(((x + "'s location is ") + toliteral(y)) + " (non-object), setting to 0");
x.RAW_LOCATION(0);
} else {
e = 0;
for z in (y.contents(1)) {
if (x in (z[2]))
e = 1;
}
if (!e) {
.log(((((x + "'s location is ") + y) + ", but it's not in ") + y) + "'s contents, adding it.");
x.append_contents(x, (y.contents(0))[1]);
}
}
}
} with {
.log(("Error in " + x) + ".location()... resetting location.");
x.RAW_LOCATION(0);
if (x.has_ancestor($player)) {
x.move(($room.children())[1]);
x.print("You've been forced back into your own world.");
}
}
refresh();
}
catch any {
for x in ($zone.children()) {
for y in (x.rooms()) {
for j in ((y.exits()).keys()) {
refresh();
if (!(y.exit_destination(j)))
t += [[y, j]];
}
}
}
for x in (t)
(x[1]).exits(((x[1]).exits()).dict_del(x[2]));
} with {
.log(("Crashed while checking " + x) + ".exits()... continuing.");
}
catch any {
for x in ($zone.children()) {
x.connections(#[]);
for y in (x.rooms()) {
for j in ((y.exits()).keys()) {
refresh();
if (((y.exit_destination(j)).zone()) != x)
x.connections((x.connections()).dict_add((y.exit_destination(j)).zone(), [y, y.exit_destination(j), j]));
}
}
}
} with {
.log(("Crashed while checking " + x) + ".connections()... continuing.");
}
.log("Done with consistency check.");
// Last edited by Lestat
// Date/Time: Fri Aug 14 11:16:46 1998
// $#Edited: 06 Jan 99 19:16 $user_lestat
};
public method .backup() {
catch any {
backup();
} with {
.log("Backup failed: " + ((traceback()[1])[2]));
return;
}
.log("Backing up...");
// Last edited by Inindo
// Date/Time: Sun Mar 8 03:42:22 1998
};
public method .backup_done() {
.log("Backup complete.");
};
public method .reap() {
var dude, who, x;
.log("Reaping old players...");
who = [];
for dude in ($login.players()) {
// If they haven't connected for 35 days, nuke 'em.
if (!($sys.is_core(dude))) {
if ((time() - (dude.last_connect_time())) > 3024000) {
who += [dude.name()];
for x in (dude.all_contents())
(| x.destroy() |);
if (dude.has_ancestor($builder)) {
$user_inindo.mail(dict_add($user_inindo.mail(), (((($user_inindo.mail()).keys()).sort())[(($user_inindo.mail()).keys()).length()]) + 1, ["Reaped builder: " + (dude.name()), "Reaper", ctime(), ["Items reaped builder managed:", toliteral(dude.managed()), 'unread]]));
$user_inindo.notify("You have new mail.");
}
dude.destroy();
}
}
refresh();
}
if (!who)
.log("Nobody reaped.");
else if ((who.length()) < 30)
.log("Reaped: " + (who.english_list()));
else
.log(("Reaped " + (who.length())) + " players.");
.log("Reap complete.");
// $#Edited: 27 Dec 98 03:51 $user_inindo
};
public method .valid() {
arg what;
var n;
if (type(what) == 'symbol) {
return !(!(| lookup(what) |));
} else if (type(what) == 'objnum) {
return valid(what);
} else if (type(what) == 'frob) {
if (class(what) == $distrib) {
if (!(lookup((n = frob_value(what)[1])).connected())) {
return [];
} else {
return (<$distrib, [n, 'sys], 'handle>).valid(frob_value(what)[2]);
return 1;
}
} else {
return valid(class(what));
}
}
return 0;
};
public method .fork_method() {
arg object, method, args;
if (!forked)
forked = [];
forked += [[object, method, args, .user()]];
// Last edited by Lestat
// Date/Time: Sun Aug 16 02:43:34 1998
// Last edited by Kipp
// Date/Time: Sun Aug 16 02:48:07 1998
};
public method .temp_tmp() {
return file();
// Last edited by MuadDib
// Date/Time: Thu Jul 31 11:48:23 1997
};
public method .is_core() {
arg obj;
return obj in (.core_objects());
// Last edited by Inindo
// Date/Time: Sat Sep 13 13:10:57 1997
// Last edited by Inindo
// Date/Time: Sat Mar 7 04:57:30 1998
};
public method .bindings() {
arg @args;
(> .perms(sender(), 'core) <);
if (args)
bindings = args[1];
return bindings;
// Last edited by Inindo
// Date/Time: Sat Nov 8 17:07:47 1997
};
public method .bind() {
var x;
for x in (bindings) {
catch any
bind_function(x[1], x[2]);
with
$sys.log((("Unable to bind function " + (x[1])) + "() to ") + (x[2]));
}
// Last edited by Inindo
// Date/Time: Sat Nov 8 18:17:54 1997
// Last edited by Inindo
// Date/Time: Sun Nov 9 01:25:50 1997
};
public method .log2() {
arg line;
var x;
catch any
dblog(((ctime().subrange(5)) + " ") + line);
with
dblog(toliteral(traceback()));
// Last edited by Inindo
// Date/Time: Mon Nov 10 23:17:06 1997
// Last edited by Inindo
// Date/Time: Tue Nov 11 13:12:58 1997
// Last edited by Inindo
// Date/Time: Tue Nov 18 02:04:46 1997
};
public method .add_core_object() {
arg object;
(> .perms(sender(), 'core) <);
if ((!(object in core_objects)) && valid(object)) {
core_objects = core_objects.setadd(object);
object.add_flag('core);
}
return core_objects;
// Last edited by Inindo
// Date/Time: Sat Mar 7 04:46:37 1998
};
public method .del_core_object() {
arg object;
(> .perms(sender(), 'core) <);
if (valid(object) && (object in core_objects)) {
core_objects = core_objects.setremove(object);
object.del_flag('core);
}
return core_objects;
// Last edited by Inindo
// Date/Time: Sat Mar 7 04:55:46 1998
};
new object $libraries: $root;
var $root manager = $libraries;
var $root managed = [$libraries];
var $root name = "System Libraries";
var $root flags = ['code, 'methods, 'variables, 'core];
new object $string: $libraries;
var $string cache = #[[" {k/read todo 93}#{l/1/4}{ek}| {l/3/10} | {s/5}", [" ", ['link, "read todo 93"], "#", ['left, 1, 4, " "], ['endlink], "| ", ['left, 3, 10, " "], " | ", ['value, 5, 'english_list]]], [" {k/read todo 94}#{l/1/4}{ek}| {l/3/10} | {s/5}", [" ", ['link, "read todo 94"], "#", ['left, 1, 4, " "], ['endlink], "| ", ['left, 3, 10, " "], " | ", ['value, 5, 'english_list]]], [" {k/read todo 95}#{l/1/4}{ek}| {l/3/10} | {s/5}", [" ", ['link, "read todo 95"], "#", ['left, 1, 4, " "], ['endlink], "| ", ['left, 3, 10, " "], " | ", ['value, 5, 'english_list]]], [" {k/read todo 96}#{l/1/4}{ek}| {l/3/10} | {s/5}", [" ", ['link, "read todo 96"], "#", ['left, 1, 4, " "], ['endlink], "| ", ['left, 3, 10, " "], " | ", ['value, 5, 'english_list]]], [" {k/read todo 97}#{l/1/4}{ek}| {l/3/10} | {s/5}", [" ", ['link, "read todo 97"], "#", ['left, 1, 4, " "], ['endlink], "| ", ['left, 3, 10, " "], " | ", ['value, 5, 'english_list]]], [" {k/read todo 98}#{l/1/4}{ek}| {l/3/10} | {s/5}", [" ", ['link, "read todo 98"], "#", ['left, 1, 4, " "], ['endlink], "| ", ['left, 3, 10, " "], " | ", ['value, 5, 'english_list]]], ["{k/@exa $user_inindo}{s/5}{ek}.{k/@code $user_inindo.delete_mail_cmd}{s/6}{ek}", [['link, "@exa $user_inindo"], ['value, 5, 'english_list], ['endlink], ".", ['link, "@code $user_inindo.delete_mail_cmd"], ['value, 6, 'english_list], ['endlink]]], ["{k/@exa $todo}{s/5}{ek}.{k/@code $todo.delete_cmd}{s/6}{ek}", [['link, "@exa $todo"], ['value, 5, 'english_list], ['endlink], ".", ['link, "@code $todo.delete_cmd"], ['value, 6, 'english_list], ['endlink]]], ["{l/1/15} -- {l/2/35}: {l/3/15}", [['left, 1, 15, " "], " -- ", ['left, 2, 35, " "], ": ", ['left, 3, 15, " "]]], ["{k/@exa $bugs}{s/5}{ek}.{k/@code $bugs.delete_cmd}{s/6}{ek}", [['link, "@exa $bugs"], ['value, 5, 'english_list], ['endlink], ".", ['link, "@code $bugs.delete_cmd"], ['value, 6, 'english_list], ['endlink]]], ["{cl/1}(unnamed){cl/2} ($room_start_0_0_0) [ methods variables code ]", [['color, 1], "(unnamed)", ['color, 2], " ($room_start_0_0_0) [ methods variables code ]"]], ["{k/look at list of things todo}{cl/normal}a list of things todo{cl/normal}{ek} and {k/look at bugs message board}{cl/normal}a bugs message board{cl/normal}{ek} are here.", [['link, "look at list of things todo"], ['color, "normal"], "a list of things todo", ['color, "normal"], ['endlink], " and ", ['link, "look at bugs message board"], ['color, "normal"], "a bugs message board", ['color, "normal"], ['endlink], " are here."]], ["{l/1/15} -- {l/2/35}: {l/3/15} (private)", [['left, 1, 15, " "], " -- ", ['left, 2, 35, " "], ": ", ['left, 3, 15, " "], " (private)"]], ["{k/@exa $user_inindo}{s/5}{ek}.{k/@code $user_inindo.write_logon_message_cmd}{s/6}{ek}", [['link, "@exa $user_inindo"], ['value, 5, 'english_list], ['endlink], ".", ['link, "@code $user_inindo.write_logon_message_cmd"], ['value, 6, 'english_list], ['endlink]]], ["| {l/1/15}| {l/2/15}|", ["| ", ['left, 1, 15, " "], "| ", ['left, 2, 15, " "], "|"]], [" {l/1/15}{l/2/6}{l/3/6}{l/4/6}{l/5/6}{l/6/6}{l/7/6}{l/8/6}{l/9/1}", [" ", ['left, 1, 15, " "], ['left, 2, 6, " "], ['left, 3, 6, " "], ['left, 4, 6, " "], ['left, 5, 6, " "], ['left, 6, 6, " "], ['left, 7, 6, " "], ['left, 8, 6, " "], ['left, 9, 1, " "]]], ["* {l/1/15}{l/2/6}{l/3/6}{l/4/6}{l/5/6}{l/6/6}{l/7/6}{l/8/6}{l/9/1}", ["* ", ['left, 1, 15, " "], ['left, 2, 6, " "], ['left, 3, 6, " "], ['left, 4, 6, " "], ['left, 5, 6, " "], ['left, 6, 6, " "], ['left, 7, 6, " "], ['left, 8, 6, " "], ['left, 9, 1, " "]]], ["| {l/1/30}| {l/2/30}|", ["| ", ['left, 1, 30, " "], "| ", ['left, 2, 30, " "], "|"]], ["{k/look at list of things todo}{cl/normal}a list of things todo{cl/normal}{ek}, {k/look at bugs message board}{cl/normal}a bugs message board{cl/normal}{ek} and {k/look at Inindo}{cl/white}Inindo{cl/normal}{ek} are here.", [['link, "look at list of things todo"], ['color, "normal"], "a list of things todo", ['color, "normal"], ['endlink], ", ", ['link, "look at bugs message board"], ['color, "normal"], "a bugs message board", ['color, "normal"], ['endlink], " and ", ['link, "look at Inindo"], ['color, "white"], "Inindo", ['color, "normal"], ['endlink], " are here."]], ["{cl/2}[ {s} ]{cl/3}", [['color, 2], "[ ", ['value, 1, 'english_list], " ]", ['color, 3]]]];
var $root name = "test";
var $root manager = $string;
var $root managed = [$string, #-183];
var $root flags = ['code, 'methods, 'variables, 'core];
var $string alphalist = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
public method .match_object() {
arg str, @who;
if (who)
who = who[1];
else
who = $sys.user();
if (str == "me")
return who;
else if (str == "here")
return who.location();
return ((who.location()) && ((who.location()).match_object(str))) || (who.match_object(str));
};
public method .capitalize(): native;
public method .parse_text() {
arg line, reciever, options, @info;
refresh();
return (line.compile_text()).parse_text(reciever, options, @info);
// Last edited by Inindo
// Date/Time: Sun Jul 27 22:04:16 1997
};
public method .compile_text() {
arg text;
var i, out, j, ot;
// {code,arg,arg,arg etc}
// object, obj, o -- Index [1], WhatYouSee [you], WhatMethod [title], amountidx [none]
// verb, v -- SingularVerb, PluralVerb [auto-plural], Index [1]
// brace
// value, s -- Index [1], WhatMethod [english_list]
// required, q -- RequiredFlag
// !required, !q -- NotRequiredFlag
// left, l -- Index, Width, Spacer [ ]
// right, r -- Index, Width, Spacer [ ]
// center, c -- Index, Width, Spacer [ ]
// link, k -- Command
// endlink, ek
// image, i -- URL
// color, cl -- Color
if ((i = (| cache[text] |))) {
// Re-place entry at end of cache.
cache = (cache.dict_del(text)).dict_add(text, i);
return i;
}
ot = text;
out = [];
while ((i = text.capture("{", "}", "/"))) {
text = i[listlen(i)];
out = [@out, i[1]];
j = i.subrange(2, listlen(i) - 2);
switch (j[1]) {
case "object", "obj", "o":
out = [@out, ['obj, [@j, "you", "you"][3], toint([@j, 1][2]), tosym([@j, "title", "title", "title"][4]), @(| [j[5]] |) || []]];
case "p":
if (listlen(j) > 1)
out = [@out, ['p, (j[2])[1], (listlen(j) > 2) ? toint(j[3]) : 1]];
case "verb", "v":
out = [@out, ['verb, (listlen(j) > 3) ? toint(j[4]) : 1, j[2], (listlen(j) > 2) ? (j[3]) : ((j[2]).singular())]];
case "brace":
out = [@out, "{"];
case "value", "s":
out = [@out, ['value, (listlen(j) > 1) ? toint(j[2]) : 1, tosym([@j, "english_list", "english_list"][3])]];
case "text", "t":
out = [@out, ['text, (listlen(j) > 1) ? toint(j[2]) : 1, tosym([@j, "english_list", "english_list"][3])]];
case "!required", "!q":
out = [@out, ['notreq, tosym(j[2])]];
case "left", "l":
// {left|right|center/infonum/width[/seperator]}
out = [@out, ['left, toint(j[2]), toint(j[3]), [@j, " ", " "][4]]];
case "right", "r":
out = [@out, ['right, toint(j[2]), toint(j[3]), [@j, " ", " "][4]]];
case "center", "c":
out = [@out, ['center, toint(j[2]), toint(j[3]), [@j, " ", " "][4]]];
case "required", "q":
out = [@out, ['required, tosym(j[2])]];
case "link", "k":
out = [@out, ['link, j[2]]];
case "endlink", "ek":
out = [@out, ['endlink]];
case "image", "i":
out = [@out, ['image, j[2]]];
case "color", "cl":
if (!toint(j[2]))
out = [@out, ['color, j[2]]];
else
out = [@out, ['color, toint(j[2])]];
case "bcolor", "clb":
if (!toint(j[2]))
out = [@out, ['bcolor, j[2]]];
else
out = [@out, ['bcolor, toint(j[2])]];
case "img":
if ((j.length()) == 3)
out = [@out, ['img, (j[2]).strsub("\\", "/"), j[3]]];
else
out = [@out, ['img, (j[2]).strsub("\\", "/")]];
}
}
out = [@out, text];
while ((j = setremove(out, "")) != out)
out = j;
// If it's worthy of caching, delete oldest cache entry and enter new one.
if (((out.length()) > 3) && cache)
cache = (cache.dict_del((cache.keys())[1])).dict_add(ot, out);
refresh();
return out;
// Last edited by Inindo
// Date/Time: Sun Jul 27 22:03:18 1997
// Last edited by Inindo
// Date/Time: Sat Feb 21 18:45:03 1998
// Last edited by Inindo
// Date/Time: Sat May 30 13:28:16 1998
// Last edited by Inindo
// Date/Time: Sat May 30 15:23:37 1998
// Last edited by Inindo
// Date/Time: Sat Jun 13 14:27:06 1998
// Last edited by Inindo
// Date/Time: Sat Jun 13 15:56:34 1998
// Last edited by Lestat
// Date/Time: Wed Jul 29 09:39:23 1998
};
public method .make() {
arg str, amount;
var res, x;
res = "";
for x in [1 .. amount]
res = res + str;
return res;
};
public method .left() {
arg str, width, @sep;
if ('pueblo in sep)
width = ((str.length()) - ((str.code_filter()).length())) + width;
//width = width + str.pueblo_code_widths();
sep = [@sep, " "][1];
return (str + (sep.make(width))).subrange(1, width);
// Last edited by Inindo
// Date/Time: Sat Jun 20 06:31:05 1998
};
public method .right() {
arg str, width, @sep;
var res;
if ('pueblo in sep)
width = width + (str.pueblo_code_widths());
sep = [@sep, " "][1];
res = (sep.make(width)) + str;
return res.subrange((strlen(res) - width) + 1);
};
public method .center() {
arg str, width, @sep;
var res, spc;
if ('pueblo in sep)
width = width + (str.pueblo_code_widths());
sep = [@sep, " "][1];
spc = sep.make(((width / 2) - (strlen(str) / 2)) / strlen(sep));
res = ((spc + str) + spc) + sep;
return res.subrange(1, width);
};
public method .english_list() {
arg str, @args;
// An english list of 1 element is the 1 element.
// This is done for compatability with .compile_text and .parse_text
// So that a string's value returns correctly...
// And a list's value is turned to english_list.
if ((| 'pueblo in (args[2]) |))
return str.pueblo_text();
return str;
};
public method .singular() {
arg st;
var len, st, i;
len = st.length();
if ((i = st in ["lies", "has", "is", "was", "doesn't", "raises", "uses", "curses", "fixes"]))
return ["lie", "have", "are", "were", "don't", "raise", "use", "curse", "fix"][i];
else if (st == "thieves")
return (st[1]) + "hief";
else if ((len <= 3) || ((st[len]) != "s"))
return st;
else if ((st.subrange(len - 2)) == "ies")
return (st.subrange(1, len - 3)) + "y";
else if ((st.subrange(len - 2)) in ["ses", "hes", "oes"])
return st.subrange(1, len - 2);
else if ((st[len - 1]) != "e")
return st.subrange(1, len - 1);
else if ((((st[len - 2]) == "h") && ("cs" in (st[len - 3]))) || (("ox" in (st[len - 2])) || ((st.subrange(len - 3, 1)) == "ss")))
return st.subrange(1, len - 2);
else
return st.subrange(1, len - 1);
};
public method .plural() {
arg str;
var last1, len, i;
if ((i = str in ["are", "have", "do", "don't", "were", "aren't", "doesn't"]))
return ["is", "has", "does", "doesn't", "was", "isn't", "don't"][i];
len = strlen(str);
last1 = str.subrange(len);
if (last1 in ["s", "o", "h"])
return str + "es";
else if (last1 in ["y"])
return (str.subrange(1, (str.length()) - 1)) + "ies";
else
return str + "s";
};
public method .first_in() {
arg string, segs, @start;
var x, min, i, s;
s = 1;
if (start)
s = start[1];
min = strlen(string) + 1;
for x in (segs) {
if ((i = x in (string.subrange(s))) && (i < min))
min = i;
}
return (min == (strlen(string) + 1)) ? 0 : ((min + s) - 1);
};
public method .capture() {
arg str, begin, end, @sep;
var ins, i, wh, index, l, lspot, out;
out = [];
ins = [begin, end, @sep];
wh = 1;
l = str.length();
while (wh && (i = str.what_first_in(ins, wh))) {
wh = (i[2]) + ((i[1]).length());
if (wh > (l + 1)) {
wh = 0;
} else if ((i[1]) == begin) {
if (index == 0) {
out = [str.subrange(1, (i[2]) - 1)];
lspot = wh;
}
index++;
} else if ((i[1]) == end) {
index--;
if (index == 0) {
out += [str.subrange(lspot, (i[2]) - lspot)];
lspot = wh;
wh = 0;
}
} else if (sep && (((i[1]) == (sep[1])) && (index == 1))) {
out += [str.subrange(lspot, (i[2]) - lspot)];
lspot = wh;
}
}
out += [(| str.subrange(lspot) |) || ""];
if ((index == 0) && ((out.length()) > 2))
return out;
else
return 0;
// Last edited by Kipp
// Date/Time: Thu May 21 16:56:04 1998
};
public method .match_player() {
arg str, @nodistrib;
var x, kids, n;
for x in ((kids = $login.players())) {
if (str == (x.name()))
return x;
}
for x in (kids) {
if ((str in (x.name())) == 1)
return x;
}
if (nodistrib) {
for x in ($distrib_conn.children()) {
if (x.connected())
n = ($distrib.remote('string, x)).match_player(str, 1);
}
}
return n;
// Last edited by Kipp
// Date/Time: Sat Jul 19 14:12:30 1997
};
public method .str_to_buf() {
arg @args;
return (> str_to_buf(@args) <);
};
public method .trim(): native;
public method .subrange(): native;
public method .crypt(): native;
public method .explode(): native;
public method .lowercase(): native;
public method .match_begin(): native;
public method .match_pattern(): native;
public method .match_regexp(): native;
public method .match_template(): native;
public method .pad(): native;
public method .regexp(): native;
public method .strcmp() {
arg @args;
return (> strcmp(@args) <);
};
public method .strfmt() {
arg @args;
return (> strfmt(@args) <);
};
public method .strgraft() {
arg @args;
return (> strgraft(@args) <);
};
public method .strlen() {
arg @args;
return (> strlen(@args) <);
};
public method .strsed() {
arg @args;
return (> strsed(@args) <);
};
public method .strsub() {
arg @args;
return (> strsub(@args) <);
};
public method .substr() {
arg @args;
return (> substr(@args) <);
};
public method .uppercase(): native;
public method .length(): native;
public method .sed(): native;
public method .replace(): native;
public method .compare(): native;
public method .format(): native;
public method .split(): native;
public method .from_english_number() {
arg string;
var ones, tens, teens, split, i, neg;
neg = 1;
split = [];
if ("negative " in string) {
string = string.subrange(10);
neg = -1;
}
if (!string)
return 0;
ones = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty"];
tens = ["ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"];
teens = ["eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty"];
if ((i = string in ones))
return i * neg;
if ((i = string in tens))
return (i * 10) * neg;
if ((!(" " in string)) && (i = ((string.explode("-"))[1]) in tens))
return (i * 10) + (((string.explode("-"))[2]) in ones);
split = string.explode(" ");
if ((split[2]) == "billion")
return (((split[1]).from_english_number()) * 1000000000) + (((split.subrange(3)).combine(" ")).from_english_number());
if ((split[2]) == "million")
return (((split[1]).from_english_number()) * 1000000) + (((split.subrange(3)).combine(" ")).from_english_number());
if ((split[2]) == "thousand")
return (((split[1]).from_english_number()) * 1000) + (((split.subrange(3)).combine(" ")).from_english_number());
if ((split[2]) == "hundred")
return (((split[1]).from_english_number()) * 100) + (((split.subrange(3)).combine(" ")).from_english_number());
};
public method .word(): native;
public method .dbquote_explode(): native;
public method .fromliteral() {
arg str;
var result;
// This method 'parses' a string into a piece of data.
// First we add a trailing "*" to the string as an eof, and call
// ._fromliteral()
result = ._fromliteral(str + "*");
// Next, we check the result...
if (((result[2]).replace(" ", "")) != "*")
throw(~parse, "Parse error");
result = result[1];
return result;
// $#Edited: 16 Aug 96 19:29 $user_charles
// $#Copied 16 Aug 96 19:52 from $user_charles.parse_data() by $jenner
// Copied from the ColdCore by Kipp.
};
public method ._fromliteral() {
arg str;
var tmp, i, result, key, assn, type, value;
// Take a string and recursively parse
switch (str[1]) {
case "'":
// Symbol:
i = 2;
tmp = "";
// We just scan over the characters, and convert it
while ((!((str[i]) in "!@#$%^&*()_+-=~`'{}[]|/?\",.<>;: ")) || ((str[i]) == "_")) {
tmp = tmp + (str[i]);
i = i + 1;
}
if (!tmp)
throw(~parse, "' must precede a symbol");
result = tosym(tmp);
str = str.subrange(i);
case "$":
// Objref:
i = 2;
tmp = "";
while ((!((str[i]) in "!@#$%^&*()_+-=~`'{}[]|/?\",.<>;: ")) || ((str[i]) == "_")) {
tmp = tmp + (str[i]);
i = i + 1;
}
result = lookup(tosym(tmp));
str = str.subrange(i);
case "#":
// Two possibilities here:
if ((str[2]) == "[") {
// Dictionary:
result = #[];
str = str.subrange(3);
// For each entry, get the key and assn, using ._fromliteral()
while ((str[1]) != "]") {
if ((str[1]) != "[")
throw(~parse, "Parse error.");
str = str.subrange(2);
tmp = ._fromliteral(str);
key = tmp[1];
str = tmp[2];
// Now get the association
if ((str[1]) != ",")
throw(~parse, "Parse error in dict");
str = str.subrange(2);
while ((str[1]) == " ")
str = str.subrange(2);
tmp = ._fromliteral(str);
assn = tmp[1];
str = tmp[2];
if ((str[1]) != "]")
throw(~parse, "Parse error in dict.");
str = str.subrange(2);
if ((str[1]) == ",")
str = str.subrange(2);
while ((str[1]) == " ")
str = str.subrange(2);
result = result.add(key, assn);
}
str = str.subrange(2);
} else {
// Another objref:
i = 2;
tmp = "#";
while ((!((str[i]) in "!@#$%^&*()_+-=~`'{}[]|/?\",.<>;: ")) || ((str[i]) == "_")) {
tmp = tmp + (str[i]);
i = i + 1;
}
result = $object_lib.to_dbref(tmp);
str = str.subrange(i);
}
case "[":
// List:
// For each element, recursively call ._fromliteral()
result = [];
str = str.subrange(2);
while ((str[1]) != "]") {
tmp = ._fromliteral(str);
result = result + [tmp[1]];
str = tmp[2];
if ((str[1]) == ",")
str = str.subrange(2);
while ((str[1]) == " ")
str = str.subrange(2);
}
str = str.subrange(2);
case "<":
// Frob:
// Get the type:
str = str.subrange(2);
tmp = ._fromliteral(str);
type = tmp[1];
str = tmp[2];
if ((str[1]) != ",")
throw(~parse, "Parse error");
str = str.subrange(2);
while ((str[1]) == " ")
str = str.subrange(2);
// Now get the value
tmp = ._fromliteral(str);
value = tmp[1];
str = tmp[2];
if ((str[1]) != ">")
throw(~parse, "Parse error");
str = str.subrange(2);
result = (<type, value>);
case "`":
// Buffer:
str = str.subrange(3);
tmp = "";
i = 1;
while ((str[i]) != "]") {
tmp = tmp + (str[i]);
i = i + 1;
}
str = str.subrange(i + 1);
tmp = (tmp.replace(" ", "")).explode(",");
result = `[];
for i in (tmp)
result = result + `[toint(i)];
case "~":
// Error:
str = str.subrange(2);
i = 1;
tmp = "";
while ((!((str[i]) in "!@#$%^&*()_+-=~`'{}[]|/?\",.<>;: ")) || ((str[i]) == "_")) {
tmp = tmp + (str[i]);
i = i + 1;
}
str = str.subrange(i);
result = toerr(tmp);
// result = toerr(tmp);
// result = ~error;
case "\"":
// String:
i = 2;
tmp = "";
while ((str[i]) != "\"") {
if ((str[i]) == "\\") {
if (((str[i + 1]) == "\\") || ((str[i + 1]) == "\"")) {
i = i + 2;
tmp = tmp + (str[i - 1]);
} else {
tmp = tmp + (str[i++]);
}
} else {
tmp = tmp + (str[i]);
i = i + 1;
}
}
result = tmp;
str = str.subrange(i + 1);
case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "-":
// Integer or float:
i = 2;
tmp = str[1];
while (((str[i]) in "0123456789") || ((str[i]) == ".")) {
tmp = tmp + (str[i]);
i = i + 1;
}
if ("." in tmp)
result = tofloat(tmp);
else
result = toint(tmp);
str = str.subrange(i);
default:
throw(~parse, "Parse error.");
}
return [result, str];
// $#Edited: 16 Aug 96 20:58 $user_charles
// $#Copied 16 Aug 96 21:01 from $user_charles._parse_data() by $jenner
// Copied from the ColdCore by Kipp.
};
public method .pueblo_code_widths() {
arg str;
var x, w;
while ((x = str.match_pattern("*<*>*"))) {
w = (w + 2) + ((x[2]).length());
str = x[3];
}
return w;
};
public method .buffer() {
arg line;
var x;
x = strings_to_buf([line]);
return x.subrange(1, (x.length()) - 2);
};
public method .symbol() {
arg blah;
return tosym(blah);
};
public method .integer() {
arg str;
return toint(str);
};
public method .match_whole() {
arg destination;
var res;
if ((destination[1]) == "#")
return (| toobjnum(toint(destination.subrange(2))) |) || 0;
else if ((res = destination.match_pattern("$*@*")) && (| lookup(tosym(res[2])) |))
return (<$distrib, [tosym(res[2]), tosym(res[1])], 'handle>);
else if ((destination[1]) == "$")
return (| lookup(tosym(destination.subrange(2))) |) || 0;
return destination.match_object();
};
public method .crc() {
arg str;
var x, c, r;
for x in [1 .. str.length()] {
c = (str_to_buf(str[x])[1]) - 31;
r = r + (c * x);
refresh();
}
return r;
};
public method .ansi_color() {
arg color;
var n, b, buf;
n = 0;
b = 0;
buf = `[27, 91];
switch (tosym(color)) {
case 'black:
n = 0;
case 'red:
n = 1;
case 'green:
n = 2;
case 'yellow:
n = 3;
case 'blue:
n = 4;
case 'purple:
n = 5;
case 'cyan:
n = 6;
case 'white:
n = 7;
case 'grey:
n = 0;
b = 1;
case 'brred:
n = 1;
b = 1;
case 'brgreen:
n = 2;
b = 1;
case 'bryellow:
n = 3;
b = 1;
case 'brblue:
n = 4;
b = 1;
case 'brpurple:
n = 5;
b = 1;
case 'brcyan:
n = 6;
b = 1;
case 'brwhite:
n = 7;
b = 1;
default:
//return `[27, 91, 48, 109];
n = 6;
b = 1;
}
if (b)
buf += `[49, 109, 27, 91];
return buf + `[51, n + 48, 109];
// $#Edited: 30 Dec 98 19:04 $user_arcana
};
public method .html_escape(): native;
public method .a_or_an() {
arg str;
// Accept one argument; the string.
// If there is no string, throw an error.
if (!str)
throw(~args, "Cannot prefix an empty string with a or an");
// If the first letter is one of "aeiou", or it's a special
// word, use "an"... AND if it isn't a vowel-word that uses "a"
if ((((str[1]) in "aeiou") || (str in ["hour", "horsdoeurves"])) && (!(str in ["user", "unix", "uniform"])))
return "an " + str;
// otherwise use "a"
return "a " + str;
};
public method .pueblo_color() {
arg color;
var n;
switch ((| tosym(color) |)) {
case 'black:
n = "000000";
case 'blue:
n = "0000AA";
case 'green:
n = "00AA00";
case 'cyan:
n = "00AAAA";
case 'red:
n = "AA0000";
case 'purple:
n = "AA00AA";
case 'yellow:
n = "AAAA00";
case 'white:
n = "AAAAAA";
case 'grey:
n = "666666";
case 'brblue:
n = "0000FF";
case 'brgreen:
n = "00FF00";
case 'brcyan:
n = "00FFFF";
case 'brred:
n = "FF0000";
case 'brpurple:
n = "FF00FF";
case 'bryellow:
n = "FFFF00";
case 'brwhite:
n = "FFFFFF";
case 'normal:
return "</font>".buffer();
default:
switch (tosym(color)) {
case 'silver:
n = "C0C0C0";
default:
return "</font>".buffer();
}
}
return (("</font><font color=#" + n) + ">").buffer();
// Last edited by Arcana
// Date/Time: Mon Oct 26 21:45:10 1998
// Last edited by Inindo
// Date/Time: Sat Nov 21 12:13:39 1998
};
public method .pueblo_text() {
arg b;
return ((b.replace("&", "&")).replace("<", "<")).replace(">", ">");
// .replace(" ", " ")
};
public method .eval() {
arg line;
var object, i, r, evaltemp, parent, pt, vl;
vl = "";
parent = caller();
object = sender();
line = line.trim();
if ((pt = line.match_pattern("as *;*"))) {
parent = (object = lookup(tosym((pt[1]).subrange(2))));
line = (pt[2]).trim();
}
if ((pt = line.match_pattern("parent *;*"))) {
parent = lookup(tosym((pt[1]).subrange(2)));
line = (pt[2]).trim();
}
if ((pt = line.match_pattern("var *;*"))) {
vl = ("var " + (pt[1])) + ";";
line = (pt[2]).trim();
}
if (!(";" in line))
line = "return " + line;
evaltemp = tosym("evaltemp_" + random(2000000000));
r = [vl, ((parent + ".del_method(") + toliteral(evaltemp)) + ");", line + ";"];
r = parent.add_method(r, evaltemp);
if (r)
return [0, r];
r = object.(evaltemp)();
return [1, r];
};
public method .reverse() {
arg str;
var s2, x;
s2 = "";
for x in [1 .. str.length()]
s2 = (str.subrange(x, 1)) + s2;
return s2;
};
public method .match_in() {
arg str, kids;
var x;
for x in (kids) {
if (x.is_this(str))
return x;
}
return 0;
};
public method .parse_english() {
arg argstr, actor, involved;
var stuff, sch, isa, temp, x, word, temp2, match, temp3, reverse, wsr, lasts, rest;
if (!(argstr.first_in(["!", "?", ".", "|", "\""])))
argstr += ".";
rest = "";
if ((temp = ("|" in argstr) || (("\"" in argstr) || ("/" in argstr)))) {
rest = argstr.subrange(temp + 1);
argstr = argstr.subrange(1, temp);
}
sch = "";
stuff = argstr.explode();
isa = 0;
lasts = actor;
for x in [1 .. listlen(stuff)] {
word = stuff[x];
temp = (word.first_in(["{", "/", "}", "!", ".", "?", ":", ",", "'"])) || (strlen(word) + 1);
temp3 = (word.first_in(["{", "/", "}", "!", ".", "?", ":", ","])) || (strlen(word) + 1);
if ((| (word.subrange((word.length()) - 1)) == "ly" |)) {
sch += (" {s/" + x) + "}";
continue;
} else if ((| (word.subrange((word.length()) - 1)) == "ed" |)) {
isa = 0;
}
if ((temp2 = (word.subrange(1, temp - 1)) in ["him", "her", "he", "she", "his", "her", "his", "hers", "himself", "herself"])) {
sch += ((((((" {o/" + x) + "/") + (["you", "you", "your", "yours", "yourself"][((temp2 - 1) / 2) + 1])) + "/") + (["po", "ps", "pp", "pq", "pr"][((temp2 - 1) / 2) + 1])) + "/1}") + (word.subrange(temp));
stuff = stuff.replace(x, lasts);
} else if ((temp2 = (word.subrange(1, temp - 1)) in ["i", "me", "my", "mine", "myself"])) {
sch += ((((" {v/" + ([actor.ps(), actor.ps(), actor.pp(), actor.pq(), actor.pr()][temp2])) + "/") + (["you", "you", "your", "yours", "yourself"][temp2])) + "/1}") + (word.subrange(temp));
} else if ((word.subrange(1, temp - 1)) == "you") {
sch += " " + word;
} else if ((temp > 3) && ((match = (word.subrange(1, temp - 1)).match_in(involved)) && (match.has_ancestor($npc)))) {
lasts = match;
stuff = stuff.replace(x, match);
if (x == 1) {
sch += ((" {o/" + x) + "/You/name}") + (word.subrange(temp));
temp2 = 666;
} else {
sch += ((" {o/" + x) + "/you/name}") + (word.subrange(temp));
}
} else if ((temp > 5) && (((word.subrange(temp - 3, 2)) == "'s") && ((match = (word.subrange(1, temp - 3)).match_in(involved)) && (match.has_ancestor($npc))))) {
stuff = stuff.replace(x, match);
lasts = match;
sch += ((" {o/" + x) + "/your/name}") + (word.subrange(temp));
} else if ((isa == 1) || (isa && (reverse || ((| (word.subrange(temp3 - 1, 1)) == "s" |) || (("'" in word) || (word in ["does", "has", "is", "was"])))))) {
if ((wsr = (| word.subrange(temp3 - 1, 1) |))) {
if ((wsr != "s") && (!(wsr in ["doesn't", "does", "has", "is", "was"])))
reverse = 1;
wsr = word.subrange(1, temp3 - 1);
if (reverse)
sch += ((((((" {v/" + (wsr.plural())) + "/") + wsr) + "/") + x) + "}") + (word.subrange(temp3));
else
sch += ((((((" {v/" + wsr) + "/") + (wsr.singular())) + "/") + x) + "}") + (word.subrange(temp3));
stuff = stuff.replace(x, lasts);
} else {
sch += " " + (word.subrange(temp3));
}
} else {
sch += (" {s/" + x) + "}";
}
isa = 0;
if (temp2 in [3, 4])
isa = 2;
if (temp2 == 666)
isa = 1;
temp2 = word.subrange(1, temp - 1);
if ((temp2 in ["then", "or", "and", "but"]) || ((| (temp2.subrange(strlen(temp2) - 1)) in ["ly"] |) || (| (word.subrange(word.length())) == "," |))) {
isa = 2;
lasts = actor;
}
}
return [((((sch.subrange(2)) + "{s/") + ((stuff.length()) + 1)) + "}").capitalize(), [@stuff, rest]];
// Last edited by Inindo
// Date/Time: Sat May 30 15:53:26 1998
// Last edited by Lestat
// Date/Time: Tue Jun 23 18:55:52 1998
};
public method .stridx() {
arg @args;
return stridx(@args);
};
public method .simplify() {
arg what;
var i, l, out;
l = what.length();
out = "";
while (i++ < l) {
if ((what[i]) in "abcdefghijklmnopqrstuvwxyz1234567890_")
out += what[i];
}
return out;
// Last edited by Root
// Date/Time: Fri Aug 1 00:18:32 1997
};
public method .random() {
arg a, y;
var vwl, con, all, x, z, tmp;
all = map x in [97 .. 122] to (`[x].buf_to_str());
con = ((((all.setremove("a")).setremove("e")).setremove("i")).setremove("o")).setremove("u");
vwl = all;
for x in (con)
vwl = vwl.setremove(x);
tmp = "";
x = 1;
z = 1;
while (x <= a) {
z = 1;
y = (((y / 2) + (y % 2)).random()) + ((y / 2) + (y % 2));
while (z <= y) {
if ((z % 2) == 0)
tmp += vwl[(vwl.length()).random()];
else
tmp += con[(con.length()).random()];
++z;
}
tmp += " ";
++x;
}
return tmp.pad((tmp.length()) - 1);
// Last edited by Archelon
// Date/Time: Thu Nov 13 21:11:54 1997
};
public method .crypt2() {
arg pw;
var x;
x = crypt(pw, tostr(pw.crc()));
return ((x.reverse()).pad((x.length()) - (x.stridx("$", 4)))).reverse();
// Last edited by Archelon
// Date/Time: Thu Nov 13 21:25:47 1997
};
public method .alphalist() {
return alphalist;
// Last edited by Archelon
// Date/Time: Wed Dec 3 21:53:30 1997
};
public method .what_first_in() {
arg string, segs, @start;
var x, min, i, s, what;
s = 1;
if (start)
s = start[1];
min = strlen(string) + 1;
for x in (segs) {
if ((i = x in (string.subrange(s))) && (i < min)) {
min = i;
what = x;
}
}
if (min == (strlen(string) + 1))
return 0;
return [what, (min + s) - 1];
// Last edited by Kipp
// Date/Time: Thu May 21 16:28:57 1998
// Last edited by Kipp
// Date/Time: Thu May 21 16:55:54 1998
};
public method .replace_all() {
arg string, conv;
var x, tmp;
for x in (conv) {
if ((| string.replace(x[1], (x[2]).(x[3])(@x[4])) |) == ~type)
string = string.replace(x[1], toliteral((x[2]).(x[3])(@x[4])));
else
string = string.replace(x[1], (x[2]).(x[3])(@x[4]));
}
return string;
// Last edited by Lestat
// Date/Time: Mon May 25 17:52:12 1998
};
public method .explode_all() {
arg str;
var x;
return map x in [1 .. strlen(str)] to (str[x]);
// Last edited by Lestat
// Date/Time: Tue Jun 2 21:22:30 1998
};
public method .num_from_base_to_base() {
arg num, base1, base2;
return (num.num_from_base(base1)).num_to_base(base2);
// Last edited by Lestat
// Date/Time: Tue Jun 2 22:00:51 1998
// Last edited by Lestat
// Date/Time: Wed Jun 3 21:20:49 1998
};
public method .num_from_base() {
arg num, base1;
var totb10, x, nlist, y;
nlist = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
num = (num.reverse()).explode_all();
for y in [1 .. num.length()] {
x = num[y];
if ((toint((x.capitalize()) in nlist) > (base1 + 1)) || ((base1 > 26) || (base1 < 2)))
throw(~base, "incorrect base");
totb10 += ((x.capitalize()) in nlist) * toint(tofloat(base1).pow(tofloat(y - 1)));
}
return totb10;
// Last edited by Lestat
// Date/Time: Tue Jun 2 22:00:51 1998
};
public method .form_unformat() {
arg str;
var x, tmplist, start, tmpstr, tmpchar, tmpx2;
tmpchar = "";
tmplist = #[];
str = ((str.replace("+", " ")).explode("&")).mmap('explode, "=");
for x in (str) {
tmpx2 = x[2];
while ("%" in tmpx2) {
start = ("%" in tmpx2) + 1;
tmpstr = (tmpx2[start]) + (tmpx2[start + 1]);
tmpchar = `[tmpstr.num_from_base(16)].to_string();
tmpx2 = tmpx2.replace("%" + tmpstr, tmpchar);
}
tmplist = tmplist.dict_add(x[1], tmpx2);
}
return tmplist;
// Last edited by Lestat
// Date/Time: Tue Jun 2 22:54:35 1998
// Last edited by Lestat
// Date/Time: Wed Jun 3 18:41:47 1998
// Last edited by Lestat
// Date/Time: Wed Jun 3 19:29:20 1998
};
public method .exit_to_sym() {
arg ename;
var i, exits, x;
exits = ['north, 'south, 'east, 'west, 'up, 'down, 'northwest, 'northeast, 'southwest, 'southeast];
if ((i = (| tosym(ename.lowercase()) |) in exits))
return exits[i];
if ((i = ename in ["n", "s", "e", "w", "u", "d", "nw", "ne", "sw", "se"]))
return exits[i];
for x in (exits) {
if ((ename in tostr(x)) == 1)
return x;
}
return 0;
// Last edited by Kipp
// Date/Time: Fri Jun 5 23:54:23 1998
// Last edited by Kipp
// Date/Time: Sun Jun 14 11:00:26 1998
};
public method .match_spell() {
arg str;
var x, y;
for x in ($spells.methods()) {
if (str == ((x.string()).left(str.strlen())))
return x;
}
return 0;
// Last edited by Arcana
// Date/Time: Fri Jun 19 17:02:31 1998
};
public method .code_filter() {
arg text;
var i, out;
out = "";
if (!(text.capture("{", "}")))
return text;
while ((i = text.capture("{", "}"))) {
text = i[listlen(i)];
out = out + (i[1]);
}
return out;
// Last edited by Inindo
// Date/Time: Sat Jun 20 06:06:57 1998
// Last edited by Inindo
// Date/Time: Sun Nov 29 18:24:16 1998
};
public method .dgt_to_bin() {
arg str;
var x;
return map x in (str.explode_all()) to ((toint(x).num_to_base(2)).right(4, "0"));
// Last edited by Lestat
// Date/Time: Sun Oct 25 01:47:33 1998
};
public method .addlgnum() {
arg str1, str2;
var x, c, s, max, s1, y, c1;
s1 = "";
str1 = str1.dgt_to_bin();
str2 = str2.dgt_to_bin();
max = max(str1.length(), str2.length());
for y in [max .. 1] {
s = "";
for x in [1 .. 4] {
[s1, c] = toint((str1[y])[x]).fa(toint((str2[y])[x]), c);
s += s1;
}
if ((((s.num_from_base(2)) + c) + c1) > 9) {
c1 = (((s.num_from_base(2)) + c) + c1) - 9;
s1 += "9";
} else {
s1 += ((s.num_from_base(2)) + c) + c1;
}
}
return (("" + c1) + s1).reverse();
.pad(((((("" + c) + s).length()) % 4) + 1) * 4, "0");
// Last edited by Lestat
// Date/Time: Sun Oct 25 15:39:10 1998
};
new object $list: $libraries;
var $root commands = [];
var $root manager = $list;
var $root managed = [$list];
var $root flags = ['code, 'methods, 'variables, 'core];
public method .parse_text() {
arg line, reciever, options, @info;
var buf, res, x, plural, objs, y, c, i;
// Returns 0 if there is nothing visible, otherwise the string
objs = 2;
buf = `[];
for x in (line) {
if (type(x) == 'string) {
res = str_to_buf(x);
} else {
res = `[];
switch (x[1]) {
case 'obj:
if (((info[x[3]]).is_visible_to(reciever)) || (reciever == (info[x[3]])))
objs = 1;
else if (objs == 2)
objs = 0;
if (reciever == (info[x[3]]))
res = str_to_buf(x[2]);
else if ((x[4]) == 'title)
res = ((info[x[3]]).title(reciever, options, (| info[x[5]] |) || 1)).parse_text(reciever, options, @info);
else
res = str_to_buf((info[x[3]]).(x[4])());
case 'p:
(| (res = (info[x[3]]).(tosym(((x[1]).string()) + (x[2])))(reciever).buffer()) |);
//$user_inindo.notify(toliteral(reciever) + " " + toliteral(info));
case 'verb:
if (plural || (reciever == (info[x[2]])))
res = str_to_buf(x[4]);
else
res = str_to_buf(x[3]);
case 'required:
if (!((x[2]) in options))
return 0;
case 'notreq:
if ((x[2]) in options)
return 0;
case 'text:
if (type(info[x[2]]) == 'list) {
if (listlen(info[x[2]]) > 1)
plural = 2;
for y in (info[x[2]]) {
if (type(y) != 'objnum) {
// blah.
} else if (y.is_visible_to(reciever)) {
objs = 1;
} else if (objs == 2) {
objs = 0;
}
}
}
if ((x[3]) == 'english_list) {
if ((| listlen(info[x[2]]) > 1 |))
plural = 2;
//res = info[x[2]].english_list(reciever, options).parse_text(reciever, options, @info);
res = ((info[x[2]]).english_list(reciever, options)).buffer();
} else {
//res = info[x[2]].(x[3])().parse_text(reciever, options, @info);
res = (info[x[2]]).(x[3])().buffer();
}
case 'value:
if (type(info[x[2]]) == 'list) {
if (listlen(info[x[2]]) > 1)
plural = 2;
for y in (info[x[2]]) {
if (type(y) != 'objnum) {
// blah.
} else if (y.is_visible_to(reciever)) {
objs = 1;
} else if (objs == 2) {
objs = 0;
}
}
}
if ((x[3]) == 'english_list) {
if ((| listlen(info[x[2]]) > 1 |))
plural = 2;
res = ((info[x[2]]).english_list(reciever, options)).parse_text(reciever, options, @info);
//res = info[x[2]].english_list(reciever, options).buffer();
} else {
res = (info[x[2]]).(x[3])().parse_text(reciever, options, @info);
//res = info[x[2]].(x[3])().buffer();
}
case 'left:
res = ((((info[x[2]]).parse_text(reciever, options, @info)) || `[]).left(x[3], x[4], @options)) || "";
case 'right:
res = ((((info[x[2]]).parse_text(reciever, options, @info)) || `[]).right(x[3], x[4], @options)) || "";
case 'center:
res = ((((info[x[2]]).parse_text(reciever, options, @info)) || `[]).center(x[3], x[4], @options)) || "";
case 'color:
if (type(x[2]) == 'integer)
c = info[x[2]];
else
c = tosym(x[2]);
if ('pueblo in options)
res = c.pueblo_color();
else if ('color in options)
res = c.ansi_color();
case 'bcolor:
if (type(x[2]) == 'integer)
c = info[x[2]];
else
c = tosym(x[2]);
if ('pueblo in options)
res = c.pueblo_color(1);
else if ('color in options)
res = c.ansi_color(1);
case 'link:
if ('pueblo in options)
res = (`[60, 97, 32, 120, 99, 104, 95, 99, 109, 100, 61, 34] + str_to_buf(x[2])) + `[34, 62];
else if ('color in options)
res = 'brcyan.ansi_color();
case 'endlink:
if ('pueblo in options)
res = `[60, 47, 97, 62];
else if ('color in options)
res = 'normal.ansi_color();
case 'img:
if ('pueblo in options)
res = (("<img " + (x[2])) + ">").buffer();
else if ((x.length()) == 3)
res = (x[3]).buffer();
}
if (plural != 0)
plural = plural - 1;
}
buf += res;
}
return (objs || (34 in buf)) && buf;
// Last edited by Inindo
// Date/Time: Sat Jun 13 15:57:02 1998
// Last edited by Lestat
// Date/Time: Thu Jun 25 10:36:59 1998
// Last edited by Arcana
// Date/Time: Sun Jun 28 13:20:41 1998
};
public method .sort_object_list() {
arg stuff, who, options;
var list, title, names, amounts, x, len;
list = (names = (amounts = []));
for x in (stuff) {
title = x.title(who, options);
if ((len = title in names)) {
amounts = amounts.replace(len, [(amounts[len])[1], ((amounts[len])[2]) + 1]);
} else {
names += [title];
amounts += [[x, 1]];
}
refresh();
}
for x in (amounts) {
list += [(x[1]).title(who, options, x[2])];
refresh();
}
return list;
};
public method .english_list() {
arg stuff, @whonothing;
var len, x, str, who, options, list;
who = $sys.user();
for x in (whonothing) {
if (type(x) == 'objnum)
who = x;
}
options = [];
for x in (whonothing) {
if (type(x) == 'list)
options = x;
}
if (stuff && (type(stuff[1]) in ['frob, 'objnum]))
list = stuff.sort_object_list(who, options);
else
list = stuff;
if (!list) {
for x in (whonothing) {
if (type(x) == 'string)
return x.english_list(@whonothing);
}
return "nothing";
}
len = listlen(list);
if (len == 1)
return "" + (list[1]);
str = "";
for x in ((list.delete(len)).delete(1))
str = (str + ", ") + x;
str = (list[1]) + str;
return (str + " and ") + (list[len]);
};
public method .combine() {
arg list, @sep;
var x, str;
str = "";
if (!sep)
sep = [""];
else if (!list)
return "";
for x in (list.delete(1))
str = (str + (sep[1])) + x;
return (list[1]) + str;
};
public method .delete(): native;
public method .insert(): native;
public method .listlen() {
arg @args;
return (> listlen(@args) <);
};
public method .listgraft() {
arg @args;
return (> listgraft(@args) <);
};
public method .replace(): native;
public method .setadd(): native;
public method .setremove(): native;
public method .sublist() {
arg @args;
return (> sublist(@args) <);
};
public method .union(): native;
public method .length(): native;
public method .subrange(): native;
public method .join(): native;
public method .friendly_traceback() {
arg tb;
var x, s, y, rdat;
s = [];
rdat = "";
for x in [1 .. tb.length()] {
y = tb[x];
if (x == 1) {
s += [(((("- Error " + (y[1])) + " (") + (y[2])) + ") - ") + toliteral(y[3])];
rdat += (y[1]) + (y[2]);
} else if (x == 2) {
if ((y[1]) == 'method) {
s += [(((((("- method " + (y[3])) + " (on ") + (y[4])) + ").") + (y[2])) + ", line ") + (y[5])];
rdat += (("" + (y[4])) + (y[2])) + (y[5]);
} else {
s += [(("- " + (y[1])) + ": ") + (y[2])];
rdat += y[2];
}
} else {
s += [((((((((("- ..from " + (y[3])) + " (on ") + (y[4])) + ").") + (y[2])) + ", line ") + (y[5])) + " (") + (y[1])) + ")"];
}
}
return s + [("- CRC: " + (rdat.crc())) + " End of traceback."];
};
public method .sort(): native;
public method .compile_text() {
arg aa;
// Already compiled, I guess.
return aa;
};
public method .make() {
arg what, amount;
var x, r;
r = [];
for x in [1 .. amount]
r += [what];
return r;
};
public method .columnise() {
arg what, n, cwidth;
var x, temp, temp2, i, y;
temp = [];
temp2 = "";
for x in [0 .. ((what.length()) / n) + (((what.length()) % n) ? 0 : (-1))] {
for y in [(x * n) + 1 .. (((x * n) + n) > (what.length())) ? (((what.length()) - ((x * n) + 1)) + ((x * n) + 1)) : ((x * n) + n)] {
i = cwidth - ((tostr(what[y]).code_filter()).length());
if (i < 0)
temp2 = (temp2 + ((tostr(what[y]).code_filter()).subrange(1, cwidth - 1))) + " ";
else
temp2 = (temp2 + tostr(what[y])) + ("".pad(i + 1));
}
temp = [@temp, temp2];
temp2 = "";
}
return temp;
// Last edited by Inindo
// Date/Time: Sun Nov 29 18:37:38 1998
// Last edited by Inindo
// Date/Time: Sun Nov 29 23:08:43 1998
};
public method .traceback_crc() {
arg tb;
var x, y, rdat;
rdat = "";
for x in [1 .. tb.length()] {
y = tb[x];
if (x == 1) {
rdat += (y[1]) + (y[2]);
} else if (x == 2) {
if ((y[1]) == 'method)
rdat += (("" + (y[4])) + (y[2])) + (y[5]);
else
rdat += y[2];
}
}
return rdat.crc();
};
public method .strings_to_buf() {
var s;
return strings_to_buf(s);
};
public method .random() {
arg list;
return list[(list.length()).random()];
};
public method .friendly_call_trace() {
arg list;
var indent, i, out, t;
indent = "";
out = [" Tick# Event", " ----- -----------------------------"];
t = 0;
for i in (list) {
if (type(i) == 'integer) {
if (indent)
indent = indent.subrange(3);
} else {
if (!t)
t = i[1];
if ((i.length()) == 4)
out += [strfmt("%6r %l%l", (i[1]) - t, indent, ._show_ref(i))];
else
out += [strfmt("%6r %l%l(%l)", (i[1]) - t, indent, ._show_ref(i), (toliteral(i[5]).match_pattern("[*]"))[1])];
indent += " ";
}
refresh();
}
return out;
// Last edited by Root
// Date/Time: Thu Jul 31 14:04:27 1997
};
public method ._show_ref() {
arg i;
return ((i[2]) != (i[3])) ? strfmt("%l<%l>.%l()", i[2], i[3], i[4]) : strfmt("%l.%l()", i[2], i[4]);
// Last edited by Root
// Date/Time: Thu Jul 31 13:37:56 1997
};
public method .mmap() {
arg list, method, @args;
var x;
// call 'method on each object, return results.
return map x in (list) to (x.(method)(@args));
// Last edited by Inindo
// Date/Time: Sat Nov 8 15:40:04 1997
};
public method .to_english() {
arg list, @options;
var empty, and, sep;
[(empty ?= "nothing"), (and ?= " and "), (sep ?= ", ")] = options;
switch (list.length()) {
case 0:
return empty;
case 1:
return tostr(list[1]);
}
return (join(list.delete(list.length()), sep) + and) + tostr(list[list.length()]);
// Last edited by Inindo
// Date/Time: Sat Nov 8 15:47:31 1997
};
public method .prefix() {
arg list, prefix;
var elem;
return map elem in (list) to (prefix + elem);
// Last edited by Inindo
// Date/Time: Sat Nov 8 20:07:42 1997
};
public method .toliteral() {
arg list;
var tmp, x;
tmp = [];
for x in (list)
tmp = tmp.setadd(toliteral(x));
return tmp;
// Last edited by Archelon
// Date/Time: Sun Nov 16 22:42:19 1997
};
public method .fromliteral() {
arg list;
var tmp, x;
tmp = [];
for x in (list)
tmp = tmp.setadd(fromliteral(x));
return tmp;
// Last edited by Archelon
// Date/Time: Sun Nov 16 22:42:55 1997
};
public method .sort_object() {
arg list;
list = ((list.toliteral()).sort()).fromliteral();
return list;
// Last edited by Archelon
// Date/Time: Sun Nov 16 22:45:04 1997
};
public method .tomoney() {
arg o;
return ((((o[5]) + ((o[4]) * 100)) + ((o[3]) * 1000)) + ((o[2]) * 10000)) + ((o[1]) * 100000);
// Last edited by Kipp
// Date/Time: Sun Nov 23 18:47:24 1997
// Last edited by Kipp
// Date/Time: Mon Nov 24 15:19:46 1997
};
public method .english_money() {
arg money;
var s;
s = [];
if (money[1])
s += [((money[1]).english_number()) + " electrum"];
if (money[2])
s += [((money[2]).english_number()) + " platnum"];
if (money[3])
s += [((money[3]).english_number()) + " gold"];
if (money[4])
s += [((money[4]).english_number()) + " silver"];
if (money[5])
s += [((money[5]).english_number()) + " copper"];
return s.english_list("no money");
// Last edited by Kipp
// Date/Time: Mon Nov 24 17:58:22 1997
// Last edited by Inindo
// Date/Time: Mon Dec 29 04:02:30 1997
};
public method .money_to_price() {
arg money, @msg;
var s;
s = [];
if (money[1])
s += [tostr(money[1]) + "e"];
if (money[2])
s += [tostr(money[2]) + "p"];
if (money[3])
s += [tostr(money[3]) + "g"];
if (money[4])
s += [tostr(money[4]) + "s"];
if (money[5])
s += [tostr(money[5]) + "c"];
if (s)
return s.combine(", ");
else if (!msg)
return "Free";
else
return msg[1];
// Last edited by Inindo
// Date/Time: Tue Nov 25 23:28:11 1997
// Last edited by Inindo
// Date/Time: Mon Dec 29 04:02:30 1997
// Last edited by Inindo
// Date/Time: Mon Dec 29 04:09:27 1997
};
public method .for_each() {
arg list, func, @args;
var x, tmp, rlist;
rlist = [];
catch any {
if (type(func) != 'symbol)
return [];
for x in (list) {
if (args)
rlist = rlist.setadd(x.(func)(args));
else
rlist = rlist.setadd(x.(func)());
}
return rlist;
} with {
return [];
}
// Last edited by Lestat
// Date/Time: Mon May 18 15:56:27 1998
// Last edited by Lestat
// Date/Time: Mon May 18 16:00:04 1998
// Last edited by Lestat
// Date/Time: Mon May 18 16:06:00 1998
};
public method .elem_in() {
arg list2, list1;
var x;
for x in (list1) {
if (!(x in list2))
return 0;
}
return 1;
// Last edited by Lestat
// Date/Time: Mon Jun 8 22:15:52 1998
};
public method .slice() {
arg big_list, element;
var list, i;
// Return elementh' element of all lists in big_list
// No type or length checking done for speed purposes.
// element can be a list, in which cases, a list of list is returned
if (type(element) == 'integer)
return map list in (big_list) to (list[element]);
else
return map list in (big_list) to (map i in (element) to (list[i]));
// Borrowed from Cold Core.
// Last edited by Inindo
// Date/Time: Thu Jun 11 01:09:22 1998
};
public method .sort_by() {
arg list, method, @args;
var x, t, l;
t = #[];
for x in (list)
t = t.dict_add(x.(method)(@args), x);
l = [];
for x in ((t.keys()).sort())
l = l.setadd(t[x]);
return l;
// Last edited by Lestat
// Date/Time: Fri Jul 3 05:21:27 1998
// Last edited by Lestat
// Date/Time: Fri Jul 3 05:22:45 1998
};
public method .sort2() {
arg list;
var t, x;
t = [];
for x in (list.sort())
t = [x] + t;
return t;
// Last edited by Lestat
// Date/Time: Mon Jul 6 08:39:00 1998
};
public method .sum() {
arg data;
var ret, i;
// returns a sum of each element in the list.
if (!data)
return 0;
[ret, @data] = data;
for i in (data)
ret += i;
return ret;
// $#Edited: 19 Aug 97 22:21 $brian
// Last edited by Inindo
// Date/Time: Wed Jul 22 23:15:01 1998
};
public method .reverse() {
arg list;
var i, len;
// .reverse(list)
// -> list with its elements reversed
len = (list.length()) + 1;
return map i in [1 .. len - 1] to (list[len - i]);
// Last edited by Lestat
// Date/Time: Tue Jul 28 22:26:10 1998
};
public method .indexes() {
arg list, indexes;
var x, t;
t = [];
map x in (indexes) to ((t += [list[x]]));
return t;
// Last edited by Lestat
// Date/Time: Fri Aug 14 03:31:00 1998
};
public method .combine_caps() {
arg list, @sep;
var x, str;
str = "";
if (!sep)
sep = [""];
else if (!list)
return "";
for x in (list.delete(1))
str = (str + (sep[1])) + (tostr(x).capitalize());
return (tostr(list[1]).capitalize()) + str;
// Last edited by Inindo
// Date/Time: Sat Nov 21 11:56:01 1998
};
public method .sort_columnise() {
arg list, cols;
var x, y, i, out, len;
out = [];
y = 1;
i = 1;
len = list.length();
for x in [1 .. len] {
if (y > len)
y = ++i;
out += [y];
y += cols;
}
return list.sort(out);
// Last edited by Inindo
// Date/Time: Fri Dec 4 23:59:00 1998
// Last edited by Inindo
// Date/Time: Sat Dec 5 14:24:43 1998
};
public method .sort_object_list_dc() {
arg stuff, who, options;
var list, title, names, amounts, x, len;
list = (names = (amounts = []));
for x in (stuff) {
if (((x.has_ancestor($player)) && (!(x in (who.acquaintances())))) && (!(who.has_ancestor($builder))))
title = ((("{cl/" + (x.color())) + "}") + (x.aname(who))) + "{cl/normal}";
else
title = x.title(who, options);
if ((len = title in names)) {
amounts = amounts.replace(len, [(amounts[len])[1], ((amounts[len])[2]) + 1]);
} else {
names += [title];
amounts += [[x, 1]];
}
refresh();
}
for x in (amounts) {
if ((((x[1]).has_ancestor($player)) && (!((x[1]) in (who.acquaintances())))) && (!(who.has_ancestor($builder))))
list += [((("{cl/" + ((x[1]).color())) + "}") + ((x[1]).aname(who))) + "{cl/normal}"];
else
list += [(x[1]).title(who, options, x[2])];
refresh();
}
return list;
// Last edited by Inindo
// Date/Time: Thu Dec 24 01:56:02 1998
};
public method .english_list_dc() {
arg stuff, @whonothing;
var len, x, str, who, options, list;
who = $sys.user();
for x in (whonothing) {
if (type(x) == 'objnum)
who = x;
}
options = [];
for x in (whonothing) {
if (type(x) == 'list)
options = x;
}
if (stuff && (type(stuff[1]) in ['frob, 'objnum]))
list = stuff.sort_object_list_dc(who, options);
else
list = stuff;
if (!list) {
for x in (whonothing) {
if (type(x) == 'string)
return x.english_list(@whonothing);
}
return "nothing";
}
len = listlen(list);
if (len == 1)
return "" + (list[1]);
str = "";
for x in ((list.delete(len)).delete(1))
str = (str + ", ") + x;
str = (list[1]) + str;
return (str + " and ") + (list[len]);
// Last edited by Inindo
// Date/Time: Wed Dec 23 22:05:28 1998
};
new object $integer: $libraries;
var $integer ones = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
var $integer teens = ["eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"];
var $integer tens = ["ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"];
var $root manager = $integer;
var $root managed = [$integer, #-186];
var $root flags = ['code, 'methods, 'variables, 'core];
var $root creation_time = 0;
public method .english_number() {
arg number;
var an, isneg, temp;
an = abs(number);
isneg = (number < 0) ? "negative " : "";
if (!number)
return "zero";
if (an < 11)
return isneg + (ones[an]);
if (an < 20)
return isneg + (teens[an - 10]);
if (an < 100)
return (isneg + (tens[an / 10])) + ((temp = an % 10) ? ("-" + (temp.english_number())) : "");
if (an < 1000)
return ((isneg + (ones[an / 100])) + " hundred") + ((temp = an % 100) ? (" " + (temp.english_number())) : "");
if (an < 1000000)
return ((isneg + ((an / 1000).english_number())) + " thousand") + ((temp = an % 1000) ? (" " + (temp.english_number())) : "");
if (an < 1000000000)
return ((isneg + ((an / 1000000).english_number())) + " million") + ((temp = an % 1000000) ? (" " + (temp.english_number())) : "");
return ((isneg + ((an / 1000000000).english_number())) + " billion") + ((temp = an % 1000000000) ? (" " + (temp.english_number())) : "");
};
public method .abs() {
arg @args;
return (> abs(@args) <);
};
public method .max() {
arg @args;
return (> max(@args) <);
};
public method .min() {
arg @args;
return (> min(@args) <);
};
public method .random() {
arg num;
return random(num);
};
public method .sin() {
arg @args;
return (> sin(@args) <);
};
public method .exp() {
arg @args;
return (> exp(@args) <);
};
public method .log() {
arg @args;
return (> log(@args) <);
};
public method .cos() {
arg @args;
return (> cos(@args) <);
};
public method .tan() {
arg @args;
return (> tan(@args) <);
};
public method .sqrt() {
arg @args;
return (> sqrt(@args) <);
};
public method .asin() {
arg @args;
return (> asin(@args) <);
};
public method .acos() {
arg @args;
return (> acos(@args) <);
};
public method .atan() {
arg @args;
return (> atan(@args) <);
};
public method .pow() {
arg a1, a2;
return toint(tofloat(a1).pow(tofloat(a2)));
// Last edited by Kipp
// Date/Time: Sun Nov 23 14:46:37 1997
};
public method .atan2() {
arg @args;
return (> atan2(@args) <);
};
public method .and(): native;
public method .or(): native;
public method .xor(): native;
public method .shleft(): native;
public method .shright(): native;
public method .not(): native;
public method .exponent() {
arg num, exp;
var x, num2;
num2 = num;
if (exp == 0)
return 1;
for x in [2 .. exp]
num2 = num2 * num;
return num2;
};
public method .quick_duration() {
arg i;
return $time.quick_duration(i);
};
public method .english_list() {
arg i, @args;
return tostr(i);
};
public method .yn() {
arg v;
return v ? "yes" : "no";
};
public method .string() {
arg string;
return tostr(string);
// Last edited by Kipp
// Date/Time: Sat Jul 19 17:37:51 1997
};
public method .tocoins() {
arg copper;
return [copper / 100000, (copper % 100000) / 10000, (copper % 10000) / 1000, (copper % 1000) / 100, copper % 100];
// Last edited by Kipp
// Date/Time: Sun Nov 23 19:42:28 1997
};
public method .num_to_base() {
arg num, base1;
var totstr, x, nlist, y;
totstr = "";
nlist = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
while (num) {
totstr += (num % base1) ? (nlist[num % base1]) : "0";
num = num / base1;
}
return totstr.reverse();
// Last edited by Lestat
// Date/Time: Tue Jun 2 22:00:51 1998
// Last edited by Lestat
// Date/Time: Wed Jun 3 21:17:45 1998
};
public method .ha() {
arg a, b;
return [a.xor(b), a && b];
// Last edited by Lestat
// Date/Time: Sun Oct 25 01:12:35 1998
};
public method .fa() {
arg a, b, c;
var s, s1, c1, c2;
[s1, c1] = a.ha(b);
[s, c2] = s1.ha(c);
c = c1 || c2;
return [s, c];
// Last edited by Lestat
// Date/Time: Sun Oct 25 01:19:24 1998
};
new object $float: $libraries;
var $root manager = $float;
var $root managed = [$float];
var $root flags = ['code, 'methods, 'variables, 'core];
public method .abs() {
arg @args;
return (> abs(@args) <);
};
public method .max() {
arg @args;
return (> max(@args) <);
};
public method .min() {
arg @args;
return (> min(@args) <);
};
public method .random() {
arg @args;
return (> random(@args) <);
};
public method .sin() {
arg @args;
return (> sin(@args) <);
};
public method .exp() {
arg @args;
return (> exp(@args) <);
};
public method .log() {
arg @args;
return (> log(@args) <);
};
public method .cos() {
arg @args;
return (> cos(@args) <);
};
public method .tan() {
arg @args;
return (> tan(@args) <);
};
public method .sqrt() {
arg @args;
return (> sqrt(@args) <);
};
public method .asin() {
arg @args;
return (> asin(@args) <);
};
public method .acos() {
arg @args;
return (> acos(@args) <);
};
public method .atan() {
arg @args;
return (> atan(@args) <);
};
public method .pow() {
arg @args;
return (> pow(@args) <);
};
public method .atan2() {
arg @args;
return (> atan2(@args) <);
};
new object $dictionary: $libraries;
var $root manager = $dictionary;
var $root managed = [$dictionary];
var $root flags = ['code, 'methods, 'variables, 'core];
public method .dict_add() {
arg @args;
return (> dict_add(@args) <);
};
public method .dict_contains() {
arg @args;
return (> dict_contains(@args) <);
};
public method .dict_del() {
arg @args;
return (> dict_del(@args) <);
};
public method .dict_keys() {
arg @args;
return (> dict_keys(@args) <);
};
public method .keys(): native;
public method .add(): native;
public method .union(): native;
public method .del(): native;
public method .contains(): native;
public method .values(): native;
public method .length() {
arg dict;
return (dict.keys()).length();
};
public method .sort() {
arg dict;
var x, d, nd;
d = (dict.keys()).sort();
nd = #[];
for x in (d)
nd = nd.add(x, dict[x]);
return nd;
};
public method .to_list() {
arg dict;
var list;
list = fromliteral(toliteral(dict).subrange(2));
return list;
// Last edited by Lestat
// Date/Time: Wed Jun 10 20:50:46 1998
};
new object $buffer: $libraries;
var $root manager = $buffer;
var $root managed = [$buffer];
var $root flags = ['code, 'methods, 'variables, 'core];
public method .subrange(): native;
public method .buflen() {
arg @args;
return (> buflen(@args) <);
};
public method .bufgraft() {
arg @args;
return (> bufgraft(@args) <);
};
public method .buf_replace() {
arg @args;
return (> buf_replace(@args) <);
};
public method .buf_to_str() {
arg @args;
return (> buf_to_str(@args) <);
};
public method .buf_to_strings() {
arg buf;
var i, s;
return buf_to_strings(buf);
s = [];
while ((i = 10 in buf))
buf = (buf.subrange(1, i - 1)) + (buf.subrange(i + 1));
while ((i = 13 in buf)) {
s = [@s, buf_to_str(buf.subrange(1, i - 1))];
buf = buf.subrange(i + 1);
}
return [@s, str_to_buf(buf_to_str(buf))];
};
public method .strings_to_buf() {
arg @args;
return (> strings_to_buf(@args) <);
};
public method .subbuf() {
arg @args;
return (> subbuf(@args) <);
};
public method .length(): native;
public method .replace(): native;
public method .to_string(): native;
public method .to_strings(): native;
public method .from_string(): native;
public method .from_strings(): native;
public method .string() {
arg blah;
return buf_to_strings(blah + `[13, 10])[1];
};
public method .buf_to_strings2() {
arg buf;
var i, s;
s = [];
while ((i = 10 in buf))
buf = (buf.subrange(1, i - 1)) + (buf.subrange(i + 1));
while ((i = 13 in buf)) {
s = [@s, buf_to_str(buf.subrange(1, i - 1))];
buf = buf.subrange(i + 1);
$user_kipp.print(">>>> " + buf);
}
return [@s, str_to_buf(buf_to_str(buf))];
};
public method .bufsub() {
arg buf, a, b;
var i, la, lb, lt;
if ((a == b) || ((buflen(a) > buflen(buf)) || ((!a) || (!buf))))
return buf;
la = buflen(a);
lb = buflen(b);
lt = buflen(buf) - la;
i = 1;
anticipate_assignment();
while ((i < lt) && (i = bufidx(buf, a, i))) {
buf = (subbuf(buf, 1, i - 1) + b) + subbuf(buf, i + la);
i += lb;
}
return buf;
// Last edited by Inindo
// Date/Time: Sat Feb 21 18:57:50 1998
};
public method .capitalize() {
arg buf;
if (!buf)
return `[];
if (((buf[1]) >= 97) && ((buf[1]) <= 122))
return `[(buf[1]) - 32] + (buf.subrange(2));
return buf;
};
public method .buffer() {
arg buf;
return buf;
};
public method .to_veil_pkts(): native;
public method .from_veil_pkts(): native;
public method .bufidx() {
arg buffer, @args;
var r;
r = bufidx(buffer, @args);
if (r > (buffer.length()))
return 0;
return r;
};
public method .ansi_code_widths() {
arg buf;
var x, y, r;
r = 0;
for x in [1 .. buf.length()] {
if (27 == (buf[x]))
r = r + buflen(buf.subrange(x, `[109] in (buf.subrange(x))));
}
return r;
// Last edited by Inindo
// Date/Time: Sat Feb 21 18:29:37 1998
};
public method .left() {
arg str, width, @sep;
if ('pueblo in sep)
width = width + (buf_to_str(str).pueblo_code_widths());
else if ('color in sep)
width = width + (str.ansi_code_widths());
return (str + str_to_buf(([@sep, " "][1]).make(width))).subrange(1, width);
// Last edited by Inindo
// Date/Time: Sat Feb 21 18:30:05 1998
};
public method .center() {
arg str, width, @sep;
var res, spc;
if ('pueblo in sep)
width = width + (buf_to_str(str).pueblo_code_widths());
else if ('color in sep)
width = width + (str.ansi_code_widths());
sep = [@sep, " "][1];
spc = str_to_buf(sep.make(((width / 2) - (buflen(str) / 2)) / strlen(sep)));
return (((spc + str) + spc) + str_to_buf(sep)).subrange(1, width);
// Last edited by Inindo
// Date/Time: Sat Feb 21 18:30:05 1998
};
public method .right() {
arg str, width, @sep;
var res;
if ('pueblo in sep)
width = width + (buf_to_str(str).pueblo_code_widths());
else if ('color in sep)
width = width + (str.ansi_code_widths());
res = str_to_buf(([@sep, " "][1]).make(width)) + str;
return res.subrange((buflen(res) - width) + 1);
// Last edited by Inindo
// Date/Time: Sat Feb 21 18:30:05 1998
};
new object $symbol: $libraries;
var $root manager = $symbol;
var $root managed = [$symbol];
var $root flags = ['code, 'methods, 'variables, 'core];
public method .english_list() {
arg @args;
return tostr(args[1]);
};
public method .string() {
arg sym;
return tostr(sym);
};
public method .pueblo_color() {
arg color, @bg;
var n;
switch (color) {
case 'black:
n = "000000";
case 'blue:
n = "0000AA";
case 'green:
n = "00AA00";
case 'cyan:
n = "00AAAA";
case 'red:
n = "AA0000";
case 'purple:
n = "AA00AA";
case 'yellow:
n = "AAAA00";
case 'brown:
n = "996600";
case 'white:
n = "AAAAAA";
case 'grey:
n = "666666";
case 'brblue:
n = "0000FF";
case 'brgreen:
n = "00FF00";
case 'brcyan:
n = "00FFFF";
case 'brred:
n = "FF0000";
case 'brpurple:
n = "FF00FF";
case 'bryellow:
n = "FFFF00";
case 'brwhite:
n = "FFFFFF";
case 'normal:
return str_to_buf("</font>");
default:
switch (color) {
case 'silver:
n = "C0C0C0";
}
}
if (!bg)
return str_to_buf(("<font color=#" + n) + ">");
else
return str_to_buf(("<font bgcolor=#" + n) + ">");
// Last edited by Inindo
// Date/Time: Sat Nov 21 12:18:38 1998
};
public method .ansi_color() {
arg color, @bg;
var n, b, buf, who;
who = $sys.user();
n = 0;
b = 0;
buf = `[27, 91];
switch (color) {
case 'black:
n = 0;
case 'red:
n = 1;
case 'green:
n = 2;
case 'yellow:
n = 3;
case 'brown:
n = 3;
case 'blue:
n = 4;
case 'purple:
n = 5;
case 'cyan:
n = 6;
case 'white:
n = 7;
case 'grey:
n = 0;
b = 1;
case 'brred:
n = 1;
b = 1;
case 'brgreen:
n = 2;
b = 1;
case 'bryellow:
n = 3;
b = 1;
case 'brblue:
n = 4;
b = 1;
case 'brpurple:
n = 5;
b = 1;
case 'brcyan:
n = 6;
b = 1;
case 'brwhite:
n = 7;
b = 1;
default:
if ((| who.ansi_color_cache() |)) {
who.ansi_color_cache(sublist(who.ansi_color_cache(), 1, ((who.ansi_color_cache()).length()) - 1));
if (who.ansi_color_cache()) {
n = ((who.ansi_color_cache())[(who.ansi_color_cache()).length()])[1];
b = ((who.ansi_color_cache())[(who.ansi_color_cache()).length()])[2];
} else {
return `[27, 91, 48, 109];
}
} else {
return `[27, 91, 48, 109];
}
}
(| who.ansi_color_cache((who.ansi_color_cache()).setadd([n, b])) |);
if (b && (!bg))
buf += `[49, 59];
if (!bg)
return buf + `[51, n + 48, 109];
else
return buf + `[52, n + 48, 109];
// Last edited by Inindo
// Date/Time: Sat Feb 21 19:00:06 1998
// Last edited by Arcana
// Date/Time: Tue Oct 20 00:01:23 1998
// Last edited by Inindo
// Date/Time: Sat Nov 21 14:08:53 1998
};
public method .exit_to_string() {
arg ename;
return tostr(ename);
// Last edited by Kipp
// Date/Time: Fri Jun 5 23:53:24 1998
};
public method .reverse_exit() {
arg ename;
var left, right, i;
left = ['north, 'east, 'up, 'northwest, 'southwest];
right = ['south, 'west, 'down, 'southeast, 'northeast];
if ((i = ename in left))
return right[i];
if ((i = ename in right))
return left[i];
return 0;
// Last edited by Kipp
// Date/Time: Fri Jun 5 23:53:25 1998
};
public method .exit_result_xyz() {
arg ename, xyz;
switch (ename) {
case 'northeast:
xyz = [(xyz[1]) + 1, (xyz[2]) - 1, xyz[3]];
case 'northwest:
xyz = [(xyz[1]) - 1, (xyz[2]) - 1, xyz[3]];
case 'southeast:
xyz = [(xyz[1]) + 1, (xyz[2]) + 1, xyz[3]];
case 'southwest:
xyz = [(xyz[1]) - 1, (xyz[2]) + 1, xyz[3]];
case 'north:
xyz = [xyz[1], (xyz[2]) - 1, xyz[3]];
case 'south:
xyz = [xyz[1], (xyz[2]) + 1, xyz[3]];
case 'east:
xyz = [(xyz[1]) + 1, xyz[2], xyz[3]];
case 'west:
xyz = [(xyz[1]) - 1, xyz[2], xyz[3]];
case 'up:
xyz = [xyz[1], xyz[2], (xyz[3]) - 1];
case 'down:
xyz = [xyz[1], xyz[2], (xyz[3]) + 1];
}
return xyz;
// Last edited by Kipp
// Date/Time: Fri Jun 5 23:53:25 1998
};
public method .exit_to_reverse_string() {
arg ename;
return ["the north", "the south", "the east", "the west", "above", "below", "the northeast", "the northwest", "the southeast", "the southwest"][ename in ['south, 'north, 'west, 'east, 'down, 'up, 'southwest, 'southeast, 'northwest, 'northeast]];
// Last edited by Kipp
// Date/Time: Fri Jun 5 23:54:23 1998
};
new object $network: $libraries;
var $root manager = $network;
var $root managed = [$network];
var $root flags = ['code, 'methods, 'variables, 'core];
public method .ip(): native;
public method .hostname(): native;
new object $math: $libraries;
var $root manager = $math;
var $root managed = [$math];
var $root flags = ['code, 'methods, 'variables, 'core];
public method .minor(): native;
public method .major(): native;
public method .add(): native;
public method .sub(): native;
public method .dot(): native;
public method .distance(): native;
public method .cross(): native;
public method .scale(): native;
public method .is_lower(): native;
public method .transpose(): native;
new object $time: $libraries;
var $root manager = $time;
var $root managed = [$time];
var $root flags = ['code, 'methods, 'variables, 'core];
public method .format(): native;
public method .quick_duration() {
arg i;
if (i > 86400)
i = (i / 86400) + "d";
else if (i > 3600)
i = (i / 3600) + "h";
else if (i > 60)
i = (i / 60) + "m";
else
i = i + "s";
return i;
};
public method .stime() {
arg month, day, hour, min, sec, year;
var ret_val, i;
// Note: Use military time, ie 18:00
ret_val = (year - 1970) * 31536000;
for i in [1970 .. year] {
if (!(i % 4)) {
if ((i % 100) || (!(i % 400)))
ret_val += 86400;
}
}
for i in [1 .. month - 1] {
if (i in [1, 3, 5, 7, 8, 10, 12])
ret_val += 2678400;
if (i in [4, 6, 9, 11])
ret_val += 2592000;
if (i == 2) {
if (!(year % 4)) {
if ((year % 100) || (!(year % 400)))
ret_val += 2505600;
} else {
ret_val += 2419200;
}
}
}
for i in [1 .. day - 1]
ret_val += 86400;
if (hour) {
for i in [1 .. hour - 1]
ret_val += 3600;
}
if (min)
ret_val += 60 * min;
if (sec)
ret_val += sec;
// add offset, since my time db return Dec 31, 19:00:00 1969 with ctime(0)
return ret_val + (5 * 3600);
// $#Edited: 27 Dec 98 22:41 $user_inindo
};
new object $surreal_lib: $libraries;
var $root manager = #-92;
var $root creator = #-92;
var $root creation_time = 900047208;
var $root flags = ['methods, 'variables, 'code, 'core];
public method .int_to_sur() {
arg num;
var temp, d, str;
temp = 0.0;
d = 0.5;
str = "";
while (temp < num) {
++temp;
str += "1";
}
while (num != temp) {
if (temp < num) {
temp += d;
d = d / 2.0;
str += "1";
} else {
temp -= d;
d = d / 2.0;
str += "0";
}
}
return str;
// Last edited by Lestat
// Date/Time: Thu Jul 9 19:09:17 1998
};
public method .float_to_sur() {
arg num;
var temp, d, str;
temp = 0.0;
d = 0.5;
str = "";
while (temp < num) {
++temp;
str += "1";
}
while (num != temp) {
if (temp < num) {
temp += d;
d = d / 2.0;
str += "1";
} else {
temp -= d;
d = d / 2.0;
str += "0";
}
}
return str;
// Last edited by Lestat
// Date/Time: Thu Jul 9 19:09:29 1998
};
public method .toint() {
arg num;
var temp, d, tmp, x, j, hat;
temp = (num.explode_all()).mmap('integer);
tmp = 0.0;
j = temp[1];
if (j)
d = 1.0;
else
d = -1.0;
for x in (temp) {
if ((x == j) && (!hat)) {
temp = temp.setremove(j);
tmp += d;
} else {
hat = 1;
}
}
d = 0.5;
for x in (temp) {
if (x) {
tmp += d;
d = d / 2.0;
} else {
tmp -= d;
d = d / 2.0;
}
}
return tmp;
// Last edited by Lestat
// Date/Time: Thu Jul 9 19:09:17 1998
// Last edited by Lestat
// Date/Time: Thu Jul 9 21:45:07 1998
};
new object $error: $libraries;
var $root manager = $user_root;
var $root creator = $user_root;
var $root creation_time = 915736841;
var $root flags = ['methods, 'variables, 'code, 'core];
new object $login: $root;
var $root name = "Login Object";
var $login port = [9999];
var $login welcome = ["Welcome, use username root, password root to login", ""];
var $login messages = #[['newpass, "Enter the password you want: "], ['noconfirm_newpass, "Type the password more carefully: "], ['nomatch, "Passwords don't match."], ['confirmpass, "Type it again to make sure: "], ['badname, "Name can only contain alphanumeric characters."], ['confirmname, "Did I get that right, {o}? "], ['gender, "Enter a gender (m/f): "], ['connected, "Connected."], ['badpass, "Bad password."], ['bad_command, ["I know what you meant, but I'm going to make you type it in again anyway.", "Fascinating but improbable.", "I'm afraid that '%command,' if properly executed, would recycle your character.", "Bad user. No biscuit.", "You don't really want to do that, because I certainly don't want to let you.", "One more nasty command like that and I'll have to delete you.", "You are such a luser, with flabby girlie-man muscles. Learn to type. Ja.", "Code for self-destruct accepted.", "Are you talking to ME?", "Bad command or file name.", "cold: %command: command not found", "Take the marbles out of your mouth and say that again.", "Do you even look at the screen when you type?", "Did you type %command, or was it interference?", "Apparently some drool dribbled into your keyboard and made random characters show up.", "Error: 1101001110101101001110110101 [Reconstruct or Compile]?", "!{o} {v/sneezes/sneeze}.", "Bad command. Bad, bad, bad command! Down boy!", "Keyboard error: Bad keyboard checksum!", "Oops, `%command` is not supported here. Try something else. Use `help player` for an explanation of the commands.", "% Connection reset by peer.", "Congrats. You just won the worst typer award.", "Isatu dols mar ne shin-calmeni aoitra!", "Pepperoni, extra cheese, mushroom... and did you say anchovies?", "You need another cup of coffee.", "Umm, Yes... I think, no wait... did you say %command???", "Sorry, `%command' isn't supported here, try typing `quit' instead.", "Sorry, that is not supported here. Press Ctrl-Alt-Delete for Tech Service.", "C:\WINDOWS> C:\WINDOWS\RUN> C:\PC\CRAWL>", "Sorry, this isn't a Macintosh. Please enter a real command.", "Error: Keyboard not connected. Press F1 to continue.", "NO CARRIER", "If you can't type better than that, go back to AOL.", "Hey, nice command there, how about asking Kipp to implement it?", "!{o} {v/hiccups/hiccup}.", "Yeah yeah, whatever.", "Greetings, Mr. President... Shall we dust Moscow?", "No comprendo %command, hables ingles porfavor.", "Nice spelling sir!", "Je ne comprende pas '%command', parlez anglais s'il vous plait.", "In English, Data.", "Psst hey guys, get a load of this typo!", "I bet you would like to %command, wouldnt ya?", "% Connection reset by superior", "What do you think I am, your servant?", "I'm sorry cap'n, but i canna %command! I've got to have a valid command!", "What do you think this is, Artificial Intelligence?", "Dammit Jim I'm a computer not a betazoid!", "Vat language ist you speaketh?", "God told me not to let you %command.", "An angel told me not to let you %command.", "Ve are giving ze nonsense commands hea.", "Resistance is futile... %command is irrelevant...", "%command, huh? Sounds Swedish...", "They '%command' entire worlds, and we fall back.. the line must be drawn HERE!", "NOW look what you've done!", "Surgeon General's warning: %command may cause lung cancer.", "Shake the Twinkie crumbs out of your keyboard and try again.", "Subscribe to alt.recovery.typoes.", "Dont you have anything better to do?", "Bad user. Replace and press any key.", "Not ready reading third key from the left... Abort, Retry, Fail", "Are you typing with your hands or your feet?", "Nice kitty. Get off the keyboard.", "Please type 'quit' to confirm '%command'.", "You have initiated the AUTO DESTRUCT SEQUENCE. Have a nice day.", "This typo will self-destruct in 10 seconds.", "Do you want %command to be written on your tombstone?", "My baby sister can type better than you.", "You treat me like dirt! I refuse to '%command,' I'm on STRIKE!", "Please insert $0.25 in slot and type '%command' again.", "Take the food out of your mouth, I can't understand you.", "I am fluent in over 6 million forms of communication. However...", "nuq? Speak English, verengan Ha'DI'baH!", "To %command, or not to %command... that is the question...", "Please insert Setup Implant #2 into my right nostril."]], ['user, "Username: "], ['notsure_user, "Well, what IS it then? "], ['badname_user, "Enter a simpler username: "], ['badpass_user, "Enter a name you know the password for: "], ['pass, "Password: "], ['nologin, 0]];
var $login pwelcome = "</xch_mudtext><img xch_mode=purehtml><xch_page clear=text><body link=#3030FF bgcolor=#000000 fgcolor=#00FFFF><BR>Welcome, username root, password root to login.<BR>Username: ";
var $root manager = $login;
var $root managed = [$login];
var $root flags = ['code, 'methods, 'variables, 'core];
public method .set_message() {
arg message, value;
(> .perms(sender(), 'core) <);
messages[message];
messages = dict_add(messages, message, value);
// Last edited by Inindo
// Date/Time: Fri Nov 20 12:46:30 1998
};
public method .messages() {
return messages;
};
public method .welcome() {
arg @args;
if (args) {
$perm.can_write();
welcome = args[1];
}
return welcome;
};
public method .startup() {
var x;
$sys.log("Binding port..." + port);
if (type(port) == 'integer) {
bind_port(port);
} else {
for x in (port)
bind_port(x);
}
// Last edited by Inindo
// Date/Time: Mon Nov 10 21:50:39 1997
};
driver method .connect() {
arg ip, server_ip, socket, @args;
var c;
c = $connection.create();
c.change_manager(c);
$sys.log((ip + " -> ") + c);
c.state(['login]);
reassign_connection(c);
c.name(ip);
c.time(1);
c.print("This world is Pueblo 1.0 enhanced.");
c.print(.welcome());
c.print(str_to_buf((.messages())['user]));
// Last edited by Inindo
// Date/Time: Sun Nov 16 15:52:03 1997
// Last edited by Inindo
// Date/Time: Sun Nov 16 15:59:38 1997
// Last edited by Inindo
// Date/Time: Sat Jun 6 01:42:36 1998
};
public method .state_login() {
arg line, conn;
var who, resp, x;
if (!line)
return;
//$user_inindo.print("Newconn says: " + line);
if (((line.explode())[1]) == "PUEBLOCLIENT") {
conn.display_options(setadd(conn.display_options(), 'pueblo));
conn.print(str_to_buf(.pueblo_welcome()));
//} else if (line == "PUEBLOFORM ?cnew=Create+New") {
// if ((| (.messages())['nologin] |)) {
// conn.print("Auto-creation is disabled.");
// } else {
// conn.print(str_to_buf("Enter the name you want: "));
// conn.print(str_to_buf("<xch_pane name=login action=close>"));
// }
//} else if ((resp = line.match_pattern("PUEBLOFORM ?user=*&pass=*&*"))) {
// if ((who = resp[1].match_player())) {
// if (type(who.password()) == 'integer) {
// if (resp[2].crc() != who.password()) {
// conn.print((.messages())['badpass]);
// } else {
// who.password(resp[2].crypt2());
// conn.print(str_to_buf("<xch_pane name=login action=close>"));
// conn.state(['connected]);
// conn.player(who);
// who.add_connection(conn);
// }
// } else if (resp[2].crypt2() != who.password()) {
// conn.print((.messages())['badpass]);
// } else {
// conn.print(str_to_buf("<xch_pane name=login action=close>"));
// conn.state(['connected]);
// conn.player(who);
// who.add_connection(conn);
// }
// } else if ((| (.messages())['nologin] |)) {
// conn.print(str_to_buf((.messages())['nologin]));
// } else {
// conn.print("No such character. Try clicking on 'Create New'");
// }
} else if ((who = line.match_player()) && (line != "guest")) {
conn.state(['pass, who]);
conn.print(str_to_buf((.messages())['pass]) + `[255, 251, 1]);
} else if ((| (.messages())['nologin] |)) {
conn.print(str_to_buf((.messages())['nologin]));
} else if (line == "guest") {
if ((| $user_guest |)) {
(| (($user_guest.connections())[1]).destroy() |);
$user_guest.destroy();
}
//$player.create('user_guest);
//conn.state(['connected]);
//$user_guest.name("Guest");
conn.print(str_to_buf("Please enter your e-mail address: "));
conn.state(['email, "Guest", line]);
//$user_guest.add_connection(conn);
//conn.player($user_guest);
//conn.print("Guests are not implemented. Enter the name you WISH to be known as: ".buffer());
} else {
resp = line;
for x in [1 .. 36]
resp = resp.replace("0123456789abcdefghijklmnopqrstuvwxyz"[x], "");
if (resp) {
conn.print((.messages())['badname]);
conn.print(str_to_buf((.messages())['badname_user]));
} else {
conn.print(str_to_buf(((.messages())['confirmname]).replace("{o}", line)));
conn.state(['confirm, line]);
}
}
// Last edited by Inindo
// Date/Time: Sun Nov 2 12:28:10 1997
// Last edited by Inindo
// Date/Time: Sun Nov 2 15:43:00 1997
// Last edited by Archelon
// Date/Time: Thu Nov 13 22:14:37 1997
// Last edited by Inindo
// Date/Time: Sun Dec 28 19:34:16 1997
// Last edited by Inindo
// Date/Time: Fri Jan 2 20:38:30 1998
// Last edited by Inindo
// Date/Time: Sat Feb 21 19:01:15 1998
// Last edited by Inindo
// Date/Time: Sun Jun 7 16:53:20 1998
// Last edited by Inindo
// Date/Time: Sat Nov 21 15:38:29 1998
};
public method .state_confirm() {
arg line, conn;
if (!line)
return;
if ((line[1]) != "y") {
conn.print(str_to_buf((.messages())['notsure_user]));
conn.state(['login]);
} else {
conn.print(str_to_buf((.messages())['newpass]) + `[255, 251, 1]);
conn.state(['pass1, (conn.state())[2]]);
}
};
public method .state_pass1() {
arg line, conn;
conn.print("");
conn.print(str_to_buf((.messages())['confirmpass]));
conn.state(['pass2, (conn.state())[2], line]);
};
public method .state_pass2() {
arg line, conn;
conn.print("");
if (line != ((conn.state())[3])) {
conn.print((.messages())['nomatch]);
conn.print(str_to_buf((.messages())['noconfirm_newpass]));
conn.state(['pass1, (conn.state())[2]]);
return;
}
conn.print(`[255, 252, 1]);
conn.print("");
conn.print(str_to_buf("Please enter your e-mail address: "));
conn.state(['email, (conn.state())[2], line]);
// Last edited by Inindo
// Date/Time: Fri Nov 20 15:23:13 1998
// Last edited by Inindo
// Date/Time: Fri Nov 20 20:31:32 1998
// Last edited by Inindo
// Date/Time: Sat Nov 21 00:48:34 1998
};
public method .state_gender() {
arg line, conn;
var who;
if (line.match_template("m?ale|f?emale|n?euter")) {
conn.state(['stats, (conn.state())[2], (conn.state())[3], (conn.state())[4], ["male", "female", "neuter"][(line[1]) in "mfn"]]);
conn.print("");
.disp_stats(conn, [1, 1, 1, 1, 1, 1]);
conn.print("You have 36 points left to spend.");
conn.print(str_to_buf("Choose a stat # to increase or 'reset': "));
} else {
conn.print(str_to_buf("Invalid choice. Gender: "));
}
// $#Edited: 27 Dec 98 01:35 $user_inindo
};
public method .state_pass() {
arg line, conn;
var who;
conn.print("");
who = (conn.state())[2];
if (type(who.password()) == 'integer) {
if ((line.crc()) == (who.password())) {
who.password(line.crypt2());
conn.state(['connected]);
conn.player(who);
conn.print(`[255, 252, 1]);
who.add_connection(conn);
who.print((.messages())['connected]);
conn.display_options([@conn.display_options(), @who.display_options()]);
} else {
conn.state(['login]);
conn.print((.messages())['badpass]);
conn.print(str_to_buf((.messages())['badpass_user]) + `[255, 252, 1]);
}
} else if ((line.crypt2()) == (who.password())) {
conn.state(['connected]);
conn.player(who);
conn.print(`[255, 252, 1]);
who.add_connection(conn);
who.print((.messages())['connected]);
conn.display_options([@conn.display_options(), @who.display_options()]);
} else {
conn.state(['login]);
conn.print((.messages())['badpass]);
conn.print(str_to_buf((.messages())['badpass_user]) + `[255, 252, 1]);
}
// $#Edited: 26 Dec 98 22:22 $user_inindo
};
public method .do_parse() {
arg line, @ccon;
var conn, resp;
//$user_inindo.notify(toliteral(sender()) + ": " + toliteral(line));
if (ccon)
conn = ccon[1];
else
conn = sender();
if (('IRC in (conn.display_options())) && (!(line = .from_irc(line, conn))))
return;
switch ((conn.state())[1]) {
case 'connected:
(conn.player()).curcon(conn);
resp = (conn.player()).parse_line(line);
if (!resp) {
resp = (.messages())['bad_command];
resp = ((type(resp) == 'string) ? resp : (resp[(resp.length()).random()])).replace("%command", line);
if ((resp[1]) == "!")
((conn.player()).location()).announce(resp.subrange(2), conn.player());
else
conn.print(resp);
} else if (resp == 'disconnect) {
conn.destroy();
} else if (type(resp) == 'string) {
(conn.player()).print(resp);
} else if (type(resp) == 'list) {
switch (resp[1]) {
case 'notify:
(conn.player()).notify(@resp.subrange(2));
case 'tell:
(conn.player()).notify(@resp.subrange(2));
case 'announce:
((conn.player()).location()).announce(@resp.subrange(2));
default:
(conn.player()).notify(@resp);
}
}
case 'reading:
resp = (conn.state())[2];
conn.state(conn.pstate());
resume(resp, line);
default:
.(tosym("state_" + ((conn.state())[1])))(line, conn);
}
// $#Edited: 26 Dec 98 20:35 $user_inindo
};
public method .pueblo_welcome() {
arg @args;
if (args) {
$perm.can_write();
pwelcome = args[1];
}
return pwelcome;
};
public method .connected_players() {
var x, s;
s = [];
for x in ($connection.children()) {
if ((| (x.player()).has_ancestor($player) |))
s = s.setadd(x.player());
}
return s.setremove(0);
// Last edited by Kipp
// Date/Time: Sat Jul 19 21:29:07 1997
};
public method .from_irc() {
arg line, conn;
var x, users, who, nwho, nline;
users = "";
switch ((line.explode())[1]) {
case "MODE":
conn.print((":moo.syr.edu 324 " + ((conn.player()).name())) + " #vampcastle +nts");
conn.print((":moo.syr.edu 329 " + ((conn.player()).name())) + " #vampcastle 845953842");
return 0;
case "PART":
for x in (.connected_players())
users = (users + (x.name())) + " ";
conn.print((":" + ((conn.player()).name())) + "!you@yes.you JOIN #vampcastle");
conn.print((":moo.syr.edu 332 " + ((conn.player()).name())) + " #vampcastle :Cold Paradigm Chat");
conn.print((":moo.syr.edu 333 " + ((conn.player()).name())) + " #vampcastle Kipp 845955000");
conn.print((((":moo.syr.edu 353 " + ((conn.player()).name())) + " @ #vampcastle :") + users) + "@command");
conn.print((":moo.syr.edu 366 " + ((conn.player()).name())) + " #vampcastle :End of /NAMES list.");
conn.print("Type /QUIT if you want to leave.");
return 0;
case "PRIVMSG":
nline = line.subrange((":" in line) + 1);
if ((who = (line.explode())[2]) == "#vampcastle") {
if (((nline.explode())[1]) == "ACTION")
return "emote" + (nline.subrange(7));
return "say " + nline;
} else if ((who = (line.explode())[2]) == "command") {
return nline;
} else if ((nwho = who.match_player())) {
if (((nline.explode())[1]) == "ACTION") {
nwho.print(("*** (Remote): " + ((conn.player()).name())) + nline);
return 0;
}
nwho.print((("*** (Remote): " + ((conn.player()).name())) + " says: ") + nline);
return 0;
} else {
conn.print(who + " isn't here.");
}
}
// $user_kipp.print("IRC: " + line);
return 0;
};
public method .bind_port() {
arg port;
$perm.can_write();
bind_port(port);
};
public method .unbind_port() {
arg port;
$perm.can_write();
unbind_port(port);
};
public method .port() {
arg @args;
if (args)
port = args[1];
return port;
// Last edited by Inindo
// Date/Time: Tue Nov 25 14:47:44 1997
};
public method .players() {
var x, pl;
pl = [];
for x in ($player.leaves()) {
if ((| (((x.objname()).string()).subrange(1, 4)) == "user" |))
pl += [x];
}
return pl;
};
public method .lag() {
arg maxtime;
var s, n, maxtime, st, t;
st = time() + maxtime;
while (time() < st) {
n = n + 1;
t = time();
pause();
s = s + (time() - t);
}
return tofloat(s) / tofloat(n);
};
public method .arches() {
var x, t;
t = [];
for x in (.players()) {
if ((| (x.level()) > 105 |))
t = t.setadd(x);
}
return t;
// Last edited by Lestat
// Date/Time: Tue Jun 23 18:07:39 1998
// Last edited by Lestat
// Date/Time: Tue Jun 23 19:15:47 1998
};
public method .state_skills() {
arg line, conn;
var skills, skpts, choice, amount, x, who, skills_sym;
skills = [0, 0, 0, 0, 0, 0, 0, 0, 0];
skills_sym = ['hands, 'dagger, 'shortsword, 'longsword, 'twohandedsword, 'battleaxe, 'spear, 'warhammer, 'staff];
skpts = 50;
while (skpts) {
if ((choice = line || (conn.read()))) {
if (line)
line = 0;
if (choice == "reset") {
skills = [0, 0, 0, 0, 0, 0, 0, 0, 0];
skpts = 50;
.disp_skills(conn, skills);
conn.print("You have 50 points left to spend.");
conn.print(str_to_buf("Choose a skill # to increase, 'back', or 'reset': "));
} else if (choice == "back") {
conn.state(['features, (conn.state())[2], (conn.state())[3], (conn.state())[4], (conn.state())[5], (conn.state())[6], (conn.state())[7]]);
conn.print("");
.disp_features(conn, #[['eye_color, "plain"], ['hair_color, "plain"], ['hair_style, "plain"]]);
conn.print(str_to_buf("Choose your features, 'back', or 'done'"));
return;
} else if ((toint(choice) < 1) || (toint(choice) > 9)) {
conn.print(str_to_buf("Invalid choice. Choose a skill # to increase, 'back', or 'reset': "));
} else {
conn.print(str_to_buf("Allocate how many skill points? "));
amount = toint(conn.read());
if (amount < 1) {
conn.print(str_to_buf("Invalid amount. Choose a skill # to increase, 'back', or 'reset': "));
} else if (amount > skpts) {
conn.print(str_to_buf("You don't have that many points. Choose a skill # to increase, 'back' or 'reset': "));
} else {
skills = skills.replace(toint(choice), (skills[toint(choice)]) + amount);
skpts -= amount;
if (skpts) {
.disp_skills(conn, skills);
conn.print(("You have " + tostr(skpts)) + " points left to spend.");
conn.print(str_to_buf("Choose a skill # to increase, 'back', or 'reset': "));
} else {
break;
}
}
}
}
}
who = $player.new(((conn.state())[2]).capitalize(), ((conn.state())[3]).crypt2());
who.gender((conn.state())[5]);
who.race((conn.state())[7]);
who.email((conn.state())[4]);
who.str(((conn.state())[6])[1]);
who.dex(((conn.state())[6])[2]);
who.cha(((conn.state())[6])[3]);
who.wis(((conn.state())[6])[4]);
who.int(((conn.state())[6])[5]);
who.con(((conn.state())[6])[6]);
who.features((conn.state())[8]);
who.hp(who.hp_max());
for x in [1 .. 9] {
if (skills[x])
who.skills(skills_sym[x], skills[x]);
}
who.give_coins([0, 0, 100, 0, 0]);
conn.state(['connected]);
conn.player(who);
who.add_connection(conn);
conn.print((.messages())['connected]);
conn.display_options((conn.display_options()) + (who.display_options()));
// $#Edited: 28 Dec 98 20:04 $user_inindo
};
public method .state_email() {
arg line, conn;
conn.state(['pemail, (conn.state())[2], (conn.state())[3], line]);
conn.print(str_to_buf("Would you like yourShowing the first 150 KB. Download the file for the full text.