The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Todo:

* messages still in duplicate when the same player logs in twice; make room's tell_object operate uniquely.

* need a black list black list, so we can re-add ourself to things that get serialized by Acme::State even though we're in %INC

* need an error log viewabe by all.

* eval and its output should be sent to the whole room.

* Better account management.

* There's code around to parse LPC and convert it to Perl. It would be neat to offer a full blown 2.4.5 lib for people to play around in.

* Acme::IRCLike would probably be more popular -- bolt an IRC server onto your app.

* Also, a telnet interface beyond just an HTTP interface would be nice. Should be easy to do.

* Let "players" wander between apps. Offer RPC to support this.

* Optionally take an existing Continuity instance with path_session set and optionally parameters for the paths to use for chat pull and commands. Not sure how to work this; each path gets its own coroutine, but there is still only one main(). Continuity doesn't have a registry of which paths go to which callbacks.

Done:

* messages in triplicate because each player has three routines and is inserted into the floor three times. oops.

* build the ajax.chat.js into source. -- okay, test.

* eval, call

* inventory's insert() method should set the insertee's environment to itself. that way, all objects have an environment.

* Commands need to do $floor->tell_object or $self->tell_object rather than output directly.

* Put @messages into the room ($floor). Get the chat action out of the main loop. Dispatch all actions. Maybe.

NAME

Acme::MUDLike - Hang out inside of your application

SYNOPSIS

    use Acme::MUDLike; 
    my $server = Acme::MUDLike->new;

    # ... your code here

    $server->loop;  # or call the Event or AnyEvent event loop

Connect to the URL provided and cut and paste into the text box:

    /eval package sword; our @ISA = qw/Acme::MUDLike::object/; sub new { my $pack = shift; $pack->SUPER::new(name=>"sword", @_); }
    /clone sword
    /i
    /call sword name
    wee, fun!  oh, hai everyone!

DESCRIPTION

Multi user chat, general purpose object tracer, eval, and give/drop/take/clone/dest/look.

Adds a social element to software development and develop it from within. Chat within the application, eval code inside of it (sort of like a simple Read-Eval-Parse Loop). Call methods in objects from the command line. Create instances of objects, give them to people, drop them on the floor.

The idea is take the simple command line interface and extend it with more commands, and to create tools and helper objects that inspect and modify the running program from within.

It fires up a Continuity/HTTP::Daemon based Web server on port 2000 and prints out a login URL on the command line. Paste the URL into your browser. Chat with other users logged into the app. Messages beginning with a slash, /, are interpreted as commands:

/look

See who else and what else is in the room.

/call

Call a function in an object; eg, if you're holding a toaster, you can write:

  /call toaster add_bread 1
/eval

Executes Perl. $self is your own player object. $self->inventory is an Acme::MUDLike::inventory object with delete, insert, named, apply, and contents methods. $self->environment is also an Acme::MUDLike::inventory object holding you and other players and objects in the room. The environment and players in it all have tell_object methods that takes a string to add to their message buffer. Calling tell_object in the environment sends the message to all players. Objects define various other methods.

/who

List of who is logged in. Currently the same /look.

/inventory

Or /i or /inv. Lists the items you are carrying.

/clone

Creates an instance of an object given a package name. Eg:

  /clone sword
/take

Pick up an item from the floor (the room) and place it in your inventory. Or alternatively /take item from player to take something from someone.

/drop

Drop an item on the floor.

/give

Eg:

  /give sword to scrottie

Transfers an object to another player.

/dest

Destroys an object instance.

new()

Each running program may only have one Acme::MUDLike instance running. It would be dumb to have two coexisting parallel universes tucked away inside the same program. Hell, if anything, it would be nice to do some peer discovery, RPC, object serialization, etc, and share objects between multiple running programs.

continuity

Optional. Pass in an existing Continuity instance. Must have been created with the parameter path_session => 1.

port

Optional. Defaults to 2000. This and other parameters, such as those documented in Continuity, are passed through to Continuity->new().

password

Optional. Password to use. Everyone gets the same password, and anyone with the password can log in with any name. Otherwise one is pseudo-randomly generated and printed to stdout.

HISTORY

0.01

Original version; created by h2xs 1.23 with options

  -A -C -X -b 5.8.0 -c -n Acme::MUDLike

TODO

(Major items... additional in the source.)

Test. Very, very green right now.
Telnet in as well as HTTP.
JavaScript vi/Acme::SubstituteSubs integration.
Multiple rooms. Right now, there's just one.

The JavaScript based vi and file browser I've been using with Acme::SubstituteSubs isn't in any of my modules yet so development from within isn't really practical using just these modules. There's some glue missing.

SEE ALSO

Continuity
Continuity::Monitor
Acme::State
Acme::SubstituteSubs

Acme::State preserves state across runs and Acme::SubstituteSubs. These three modules work on their own but are complimentary to each other. Using Acme::SubstituteSubs, the program can be modified in-place without being restarted, so you don't have to log back in again after each change batch of changes to the code. Code changes take effect immediately. Acme::State persists variable values when the program is finally stopped and restarted. Acme::State will also optionally serialize code references to disc, so you can eval subs into existance and let it save them to disc for you and then later use B::Deparse to retrieve a version of the source.

The Todo comments near the top of the source.

AUTHOR

Scott Walters, <scott@slowass.net>

COPYRIGHT AND LICENSE

Copyright (C) 2009 by Scott Walters

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.9 or, at your option, any later version of Perl 5 you may have available. By using this software, you signify that you like llamas.

Includes code by John Resig:

 jQuery 1.1.2 - New Wave Javascript

 Copyright (c) 2007 John Resig (jquery.com) 
 Dual licensed under the MIT (MIT-LICENSE.txt)
 and GPL (GPL-LICENSE.txt) licenses.

 $Date: 2007-02-28 12:03:00 -0500 (Wed, 28 Feb 2007) $
 $Rev: 1465 $

Includes code by Awwaiid (Brock Wilcox)

8 POD Errors

The following errors were encountered while parsing the POD:

Around line 597:

'=item' outside of any '=over'

Around line 655:

You forgot a '=back' before '=head2'

Around line 662:

'=item' outside of any '=over'

Around line 681:

You forgot a '=back' before '=head1'

Around line 697:

'=item' outside of any '=over'

Around line 709:

You forgot a '=back' before '=head1'

Around line 711:

'=item' outside of any '=over'

Around line 731:

You forgot a '=back' before '=head1'