LambdaMOO

LambdaMOO is a virtual environment composed of a server, a database, a messaging system, and an object-oriented programming language called LambdaMOO

Note:
LambdaMOO listens for Telnet requests on lions.cs.ndsu.nodak.edu:7777 and
listens for HTTP requests on http://lions.cs.ndsu.nodak.edu:7778

Main Points

  • The object system is a single-inheritance abstraction hierarchy
    Every object has exactly 1 parent and 0-N children

  • Objects inherit properties and verbs/functions/methods from their parents
    Parents denote class

  • Creating a new object will invoke its constructor named initialize (if such exists) which is inherited from its parent/class

  • verbs/functions/methods on a child object specialize their parent and can explicitly reference parent code, but do not by default
    - the reference function is called with pass(@args) Example

  • There are two modalities for verbs/functions/methods:

    1. verbs: are for keyboard invocation and have special syntax:
      e.g. verb [direct-object [preposition indirect-object]]
      e.g. @move me to $player_start

    2. functions/methods: have the more standard software interface: parameter passing
      e.g. object:verb(<parameter-list>)
      e.g. exit:move(player)

  • It is possible to invoke both verbs and functions/methods from the command line - but they require different syntax

  • The command line parser assumes you are entering a verb - there are a few special verbs

    • say shorthand is "

    • emote shorthand is :

    • eval shorthand is ; (very useful for software testing)

    • verbs are referenced with a colon (:) and properties are referenced with a period (.)

  • There is a 4-level hierarchy of permissions in LambdaMOO: player, builder, programmer, and wizard

    1. player can invoke verbs on the command line

    2. builder can use certain commands to create objects, etc.

    3. programmer can write verbs/functions/methods on objects they own

    4. wizard

  • You connect to LambdaMOO using telnet either in its simple form or as embedded within MacMOOSE, tkMOO-light, or a more specialized client program.

    • Quote from What is Telnet? (http://www.grex.org/telnet.html)
      "Telnet programs are a type of terminal emulation program, just like modem-based communications programs. The difference is that they allow you to access other computers through the Internet, rather than by dialing the other computers directly.
      Telnet programs "talk" to other Internet-connected computers using what's called the "telnet protocol" for communication. This protocol specifies how telnet programs should send data back and forth, allowing for interactive text sessions."

  • You can write verbs/functions on an object using the builtin LambdaMOO line editor (not recommended) or using an editing client like MacMOOSE or tkMOO-light

  • The environment enforces a tick counter to limit the time a process will run (to prevent infinite loops), and kills processes that try to run longer

  • If you are REALLY SURE the function is correct, but just needs more time to complete a lengthy execution, you can over-ride the tick limit with suspend() or $command_utils:suspend_if_needed(0)

The LambdaMOO language

The LambdaMOO language syntax is similar to C++

  • iteration is usually done with a for-endfor loop, although there is also a 'while' construct

  • conditionals are if-elseif-else-endif, there is no case statement

  • assignment is with = and equality is tested with ==

  • standard output is with the player:tell verb

  • there is a large set of utility libraries: $list_utils, $string_utils, $command_utils, $object_utils, are the most commonly used; but see also $math_utils, $time_utils, $set_utils

  • there is also a large set of builtin verbs, see help builtin for a list

  • the developers of the LambdaMOO language recommend using these (because they are optimized)

    • the special in operator

    • the 'spreading' parameter passing

  • the language supports asynchronous background processing with fork()

  • the language supports exception handling with try

  • objects are provided an explicit constructor function, named initialize

  • Every time you enter a room, the enterfunc on that room (or its parent/ancestor), is invoked; similarly, when you leave, an exitfunc is invoked. (However, these are special cases, where normal error message are not sent in the normal way, so the developer must use command line invocations to test them).

  • Note: LambdaMOO maintains a dynamic "bug list" for storing (searchable) error messages at
    http://lions.cs.ndsu.nodak.edu:7778/bugs
    and (browsable) error messages at
    http://lions.cs.ndsu.nodak.edu:7778/bugs/browse

Random Examples

-> "hi there
You say, "hi there"

-> :bends at the waist
Wizard bends at the waist

-> ;children($player)
=> {#38, #2134, #281, #91}

-> @kids $player
generic player(#6) has 4 kids.
Everyman(#38)   Generic Software Agent(#2134)   Fred(#281)
   Generic Mail Receiving Player(#91) 

-> ;$string_utils:nn(children(#6))
=> "Everyman (#38), Generic Software Agent (#2134), Fred (#281),
   and Generic Mail Receiving Player (#91)" 

-> #here
=> #94  (The Wizard's Garage)

-> #me
=> #2  (Wizard)

-> home
You're already home!

-> @list #94:enterfunc
Object #94 does not define that verb, but its ancestor #139 does.
#139:enterfunc   none none none
 1:  object = args[1];
 2:  if (is_player(object) && object.location == this 
   && object == player)
 3:    player = object;
 4:    player:update_history(player, "explore", "enter", {this});
 5:    if ($object_utils:defines_property(player, "history"))
 6:      player.history.rooms = setadd(player.history.rooms, this);
 7:    endif
 8:    "Modification for event aware objects JHS 
   shimer@plains.nodak.edu";
 9:    for thing in (this:contents())
10:      if ($object_utils:has_verb(thing, "player_enters"))
11:        thing:player_enters(player);
12:      endif
13:    endfor
14:    "END Modification for Data aware object";
15:    "Modification for background sound daemon JHS 
   shimer@plains.nodak.edu";
16:    if (player.gui)
17:      if (!this:running())
18:        this:start_daemon();
19:      endif
20:    endif
21:    "END Mod";
22:  endif
23:  $directive:gui_enter_room_except(object, player);
24:  pass(@args);

-> @parents #94
The Wizard's Garage(#94)   Geology Room(#139)   generic room(#3)
   Root Class(#1) 

-> @list #3:enterfunc
#3:enterfunc   this none this
 1:  object = args[1];
 2:  if (is_player(object) && object.location == this)
 3:    player = object;
 4:    this:look_self(player.brief);
 5:  endif
 6:  if (object == this.blessed_object)
 7:    this.blessed_object = #-1;
 8:  endif

-> @parents me
Wizard(#2)   generic wizard(#56)   generic programmer(#57)
generic builder(#4)   Game Player(#2162)   Frand's player
class(#90)   Generic Mail Receiving Player(#91)   generic
player(#6)   Root Class(#1) 

-> @parents here
The Wizard's Garage(#94)   Geology Room(#139)   
   generic room(#3)   Root Class(#1)

-> help random
Showing help on `random()':
----
Syntax:  random (num <mod>)   => num

<mod> must be a positive number; 
   otherwise, `E_INVARG' is returned.  A
   number is chosen randomly from the range 
   `[1..<mod>]' and returned.

NOTE: all examples are typed on ONE LINE

-> ;for cnt in [1..3] 
    x = random(3); 
    if (x < 2) 
      player:tell(cnt, ". ", x, " is less");
    elseif (x == 2) 
      player:tell(cnt, ". ", x, " is equal"); 
    else 
      player:tell(cnt, ". ", x, " is greater"); 
    endif 
  endfor
1. 2 is equal
2. 1 is less
3. 3 is greater
=> 0


Created/Modified: 24Jan00/28Jan01
Comments? Write slator@cs.ndsu.edu