From: garnett@gestalt.austin.tx.us (John Garnett)
Newsgroups: rec.games.mud,comp.lang.perl
Subject: Perl Mud (was Re: MUDS IN PASCAL)
Date: 2 Sep 92 08:04:40 GMT
Followup-To: rec.games.mud

In article <1992Aug31.013920.2126@decuac.dec.com> mjr@hussar.dco.dec.com  
(Marcus J. Ranum) writes:
> tundra@wyatt.ksu.ksu.edu (Daniel Gene McDaniel) writes:
> >*SNICKER*
> >Why not code in Basic...
> 
> 	Laugh, why don't you?
> 
> 	All the MUDs I've seen except two spew memory wildly. All the MUDs
> I've seen except two have unpredictable bugs that are the result of wild
> pointers or general sloppiness in memory allocation. Maybe you're a great
> enough programmer that you never make those kinds of mistakes. I'm not,
> and I do, and I'd love a decent light BASIC compiler. I've knocked out
> code in Visual Basic that would have taken me months in C - in hours.
> 	Why not code in BASIC? Mostly narrow-mindedness. A master programmer
> will use whatever tool is best for the job. Believe me, if there were any
> decent BASICs for UNIX, they'd be a much better language to write MUDs in
> than C (Especially if you could get access to the interpreter!). Hell, Perl
> is probably better...
> mjr.

Regarding your last comment hypothesizing that Perl would be better...

I actually spent some time coding a Mud in Perl and it got to the point where
it was actually quite a bit of fun to work on.  Perl is a pretty nifty  
prototyping tool for building a mud. Perl makes it easy to deal with sockets  
and the eval() feature makes it possible for mudlib code to error out without  
crashing the mud.

Here is an example action written in Perl (the drop command):

local($id, $arg) = (&this_user, &this_input);
local($oid);

if (!defined ($oid = &present($arg,$id))) {
        &set_fail("You don't have that.");
        0;
} else {
        &set_fail("You can't drop that.");
        if (&move($oid, &environment($id)) == &MOVE_OK) {
          &tell($id, "You drop " . &query($oid, "eshort") . ".\n");
          &say(&query($id, "name") . " drops " . &query($oid, "eshort").".\n",
            $id);
            1;
        } else {
            0;
        }
}

When a player typed 'drop xyz', the driver (in Perl) eval'd the above
piece of code.

I never did completely finish the mud but it did get to the point where
players can log in and talk to each other, pick up objects, and generally
muck about.  The mud itself is about 1,000 lines of Perl code.
Here is an example transcript:

gestalt[2] telnet localhost 3738
Trying 127.0.0.1...
Connected to gestalt.austin.tx.us.
Escape character is '^]'.

Welcome to Stuf!  Stuf is a most stufly mud written entirely in Perl.
Presently it is a weird merge of ideas from LPmud _and_ Tinymud.  Yep,
you heard me right :).  Yes, it is a database mud, but one with a
difference.  Perl allows associative arrays to be mapped directly
to ndbm database files.  All database updates are made simply by
changing the values in the associative array.  Perl handles caching
the database (only about 64 database entries are in memory at any time).

who the hell be you? quantum
what be your password? 

Type @commands and @actions to get a list of the available commands and
actions.  Check out the aliasing feature.  Its way cool since it lets
you use any Perl pattern matching operation to construct the alias.  I
bet there aren't any muds with a more powerful aliasing mechanism!

@commands
@actions, @alias, @cat, @clone, @commands, @create, @dump, @expand, @forget,
@gender, @help, @id, @noop, @quit, @set, @shutdown, @unalias, @unset, @update,
@who
@actions
close, drop, eat, echo, emote, examine, get, give, go, inventory, lick, look,
open, say, smell, taste
l
You feel small in the vast space.  A stairway leads down and a door is to the
west.
  a coffin
d
You are surrounded by an old decrepit subway station.
No trains are present.
  Truilkan loves acute serendipity (jacked out)
  Jacked somewhere Psyche (jacked out)
look at truilkan
You are surrounded by an old decrepit subway station.
No trains are present.
  Truilkan loves acute serendipity (jacked out)
  Jacked somewhere Psyche (jacked out)
examine truilkan
Truilkan has spiraling orange eyes with purple flecks.
u
You feel small in the vast space.  A stairway leads down and a door is to the
west.
  a coffin
examine coffin 
It's one of those Clark Kent models with a heavy hinged lid.
enter coffin
That isn't an exit.
enter lid
You duck into a coffin (inside) via a heavy hinged lid.
The comfy satin lining almost makes up for the nauseasting stench.
  Zippy Bugmonster (jacked out)
  omicron (jacked out)
  Shard (jacked out)
  Samson (jacked out)
  Pinkfish, the small guppy. (jacked out)
  test (jacked out)
  tamera (jacked out)
  wayfarer (jacked out)
  Delilah is a cute serendipity (jacked out)
smell coffin
The smell of dead bodies permeates the place.
taste coffin
Your tongue found a stray booger that must have dropped from the nostril
of one of the previous inhabitants.
close lid
a heavy hinged lid creaks shut.
go out
That exit is closed.
open lid
a heavy hinged lid creaks open.
smell lid
You don't smell anything unusual.
go out
You feel small in the vast space.  A stairway leads down and a door is to the
west.
  a coffin
close lid
a heavy hinged lid creaks shut.
smell coffin
It smells of old polished hardwood.
@who
quantum on since 02:38:12 [here]
@commands
@actions, @alias, @cat, @clone, @commands, @create, @dump, @expand, @forget,
@gender, @help, @id, @noop, @quit, @set, @shutdown, @unalias, @unset, @update,
@who
@alias
alias         s/^alias *(\S*) (.*)/@alias $1 s\/^$1\\b\/$2\//
blush         s/^blush\b/emote blushes./
chuckle       s/^chuckle\b[ ]*/emote $N chuckles $1/
cry           s/^cry */emote $N cries/
d             s/^d\b/go down/
down          s/^down\b/go down/
e             s/^e\b/go east/
enter         s/^enter\b/go/
exa           s/^exa\b/examine/
giggle        s/^giggle */emote giggles/
grab          s/^grab\b/get/
grin          s/^grin\b[ ]*/emote $N grins $1/
hug           s/^hug\b/emote hugs you./
i             s/^i\b/inventory/;
inno          s/^inno\b/emote looks innocent./
inv           s/^inv\b/inventory/
jack          s/^jack out/@quit/
kiss          s/^kiss\b/emote kisses you./
l             s/^l\b/look/;
laugh         s/^laugh\b[ ]*/emote $N laughs $1/
llick         s/^llick\b/emote licks you sensuously./
n             s/^n\b/go north/
nod           s/^nod\b[ ]*/emote $N nods $1/
out           s/^out\b/go out/
poke          s/^poke\b/emote pokes you./
ravish        s/^ravish\b/emote ravishes you thoroughly./
s             s/^s\b/go south/
shrug         s/^shrug\b/emote shrugs/
smile         s/^smile\b[ ]*/emote $N smiles $1/
smirkle       s/^smirkle\b[ ]*/emote $N smirkles $1/
snuggle       s/^snuggle\b/emote snuggles up to you./
take          s/^take\b/get/
tickle        s/^tickle\b/emote tickles you./
tingle        s/^tingle\b/emote tingles./
u             s/^u\b/go up/
up            s/^up\b/go up/
w             s/^w\b/go west/
@commands
@actions, @alias, @cat, @clone, @commands, @create, @dump, @expand, @forget,
@gender, @help, @id, @noop, @quit, @set, @shutdown, @unalias, @unset, @update,
@who
@dump quantum
maker: Root
password: qumUmcR/nt4SE
name: quantum
ishort: quantum
eshort: quantum
id: quantum,person
ilong: You seem to be inside something alive!
elong: It appears to be some sort of presence.
icount: 0
encumbrance: 30
mass: 100000
capacity: 11000
load: 60000
volume: 50000
super: 0
handle: HDL24
interactive: 1
contains: 28
get coffin
You get a coffin.
i
  a little Hershey's Kiss
  a coffin
d      
You are surrounded by an old decrepit subway station.
No trains are present.
  Truilkan loves acute serendipity (jacked out)
  Jacked somewhere Psyche (jacked out)
drop coffin
You drop a coffin.
marie arrives from the stairwell entrance.
marie smiles 
marie says: hello
say hi
You say: hi
grin
You emote: quantum grins 


--
John Garnett                   John.Garnett@gestalt.austin.tx.us (NeXT Mail ok)
                               garnett@gestalt.austin.tx.us (NeXT Mail ok)