My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
DevelopmentOverview  
An overview of what a developer needs to know
Featured, Phase-Implementation
Updated Jan 20, 2010 by richard.m.tew@gmail.com

Introduction

The goal of this wiki page is to give developers who may be potentially interested in using this MUD framework an overview of how to get it working, and special information needed to develop with it.

Getting Started

The only dependency you need to obtain is Stackless Python.

All other dependencies are already included within the contrib sub-directory.

Steps:

  1. Check out the trunk from the repository.
  2. Copy config.ini.base to a new file named config.ini.
  3. Edit config.ini customising the options shown within. You will want to specify the name of your MUD, its status and your email address in the identity section. And perhaps also modify other options.
  4. At this point, the framework should be ready to run. Type python bootstrap.py and it should start up, ready to accept telnet connections.

Directory Structure

There are three directories under which scripts are located.

  • games
  • mudlib
  • contrib
Ideally as a developer, you should only have to modify code under the games directory. The mudlib directory should serve to provide the code that you use underneath your game code, and should be generic enough that you do not need to change it. The contrib directory is where copies of external dependencies are located, and where general code that does not fit under the mudlib directory is also located.

The games Directory

You might have noticed that there are several subdirectories under the games directory. The framework only uses one of these at a time, and at this time the one used by default is "room - simple", which aims to implement a simple room-based game model. You can read more about how this is configured in the ScriptDirectories wiki page.

Creating Your Own Game

This is a matter of simply copying one of the existing subdirectories under the games directory (export it if you are using a checkout of SVN), and modifying bootstrap.py to point to it as described in the ScriptDirectories wiki page.

Special namespaces

The code under the games and mudlib directories is managed by a special framework which adds two special features.

  • The code is made available to be imported through the code reloading system, without the use of the Python package or module systems.
  • Any files added, modified or deleted under these directories are detected, and the code reloading system puts the changes in place.

The code reloading framework is described in the CodeReloading wiki page. And the way in which code under each directory is mapped to importable namespaces is described in the ScriptDirectories wiki page.

import mudlib

class ANewCommand(mudlib.Command):
    def Run(self, verb, argString):
        pass

import game

class ACustomObject(game.world.Object):
    pass

Built-in Objects

The MUD framework automatically puts in place special global objects which are available to all game and mudlib code.

The sorrows object

This object provides a direct references to all the services which are running. Some of these may be mudlib services, and the rest will come from your game.

    if sorrows.users.UserExists("richard"):
        print "User richard exists"

    commandNames = sorrows.commands.List()
    print "There are %d commands available" % len(commandNames)

    body = sorrows.world.GetBody("richard")
    roomDescription = body.Look()
    print "The description of the room richard is in:"
    print roomDescription

Services are automatically inserted into this namespace as they finish starting up.

The events object

This object is a global event handler installed so that low-level events can be sent and received in an easy and natural way. You can read about how to use it in the SimpleEvents wiki page. But avoid using it for game events, as it is not suited for that purpose.

    events.UserLogin("richard")

Note that because this framework is based around code reloading, it is best that event registration is done by the code reloading system automatically. This is described in the linked wiki page.


Sign in to add a comment
Powered by Google Project Hosting