MOOcode (or MOO code, or just MOO) is the
programming language used to script internally the
MOO MUD server. It takes the power of
C, stirs in a little of the elegant stylings of
Pascal (but without all the
suckage), and adds a tantalizing whiff of
Lisp for good measure. Its only real shortcomings (aside from the fact that it can't be used standalone, which is a fault which is being mended by a number of developers-- presently, it's nearly perfect for the niche it was meant to fit into) are the lack of switch and true C-style for statements. In MOOcode, all objects have a unique numerical ID (including those created by other players, of course) and libraries are handled by reference objects which you may call verbs (which is MOO terminology for methods) on. Global variables cannot be added, but can be nearly equated by properties on the "system object", #0. A property on #0 can be referred to with a shorthand of $-- For instance, the generic room is referred to as $room. Without further ado, here's a little smidgen of demonstrative code (
ROT13 en/decryption in MOO, made a bit longer than it needs to be for demonstrative purposes):
alphabet = "abcdefghijklmnopqrstuvwxyzabcdefghijklm";
final = "";
for x in ($string_utils:char_list(argstr))
if(index(alphabet, x))
final = final + alphabet[index(alphabet, x) + 13]
else
final = final + x;
endif
endfor
return final;
And, in closing, the only obfuscated MOO code ever publicized (to my knowledge-- MOOcode is odd to obfuscate because the parser prettily formats all newly created verbs, removing extra whitespace and so on, so you have to store them in seperate text files to keep your beautiful ASCII art from being mangled):
{q=this, r= #20:( "upperc"+ "ase")(((
"m"))),h="r",o="r" ,p=q. ("lo" +"ca" +"ti"
+"on"),y=p,d="d",{ u="_" +"ut" +"i"+ "ls",
!!(s=#0. (tostr(( "st"+ "ri"+ "ng"+ u)))
):("fr"+ "om_li"+ "st") ({}), l="O" , p:(
tostr(1, "annou"+ "nce_all_bu"+ "t")[2..$])(
setremove (p.(tostr ("contents" )),player),
r+$string_utils:space(2, l)+(v={"c","1(5)"} [ abs(
$-$-1)])+(h="o")+(w=$string_utils :from_ascii(100)
+"e"+" "+o+h+v+toobj(29-8+1).alphabet[11]+"s"))}};