You are in the Original Gamer's Client README file. The room is dark, but you can make out tapestries hanging on the walls, and a portcullis is set into the western wall. A +1 short sword lies near your feet. [Exits: west]
Original Gamer's Client is my attempt at a MUD client, using Python and Tk. Why did I write this, you ask? Honestly, I couldn't tell you. I blame the voices in my head. What I do know is this:
DEPENDENCIES
- Python 2.2 or higher (With Tkinter) - Available from http://www.python.org/
- Twisted 1.0 or higher - Available from http://www.twistedmatrix.com/
- Optional
- zlib 1.1.3 or higher - Available from http://www.gzip.org/zlib/
- (On x86) Psyco 0.4.0 or higher - Available from http://psyco.sourceforge.net/
INSTALLATION
Python and Twisted must be installed first.
On Windows, simply run the executable. This will place "ogc.py" in your Python scripts directory - usually C:\Python<Version>\Scripts or C:\Program Files\Python<Version>\Scripts -
On *NIX, to perform a system-wide installation, run
python setup.py install
Or, to perform a single-user installation, run
python setup.py install --prefix=~/
For single-user installations, ~/lib/python<version> must be added to your PYTHONPATH environment variable in this case, and ~/bin added to your PATH (unless you don't mind invoking ~/bin/ogc.py).
FEATURES
Version 0.4
- MCCPv2 support
Version 0.3
- Persistent world information
- Python language scripted triggers
Version 0.2
- ANSI color support
- Separate input/output widgets.
CONFIGURATION
Currently OGC supports loading world information from a configuration
file. This file is simply Python source code to set each configuration
variable. Currently, the only option is 'worlds', and it should be set to a
list of World instances. For example:
worlds = [
World(
name = "Wayne's World",
host = 'wayne.com',
port = 4000,
geometry = '640x480+64+64',
connectOnStartup = True,
wrap = 'word',
filters = None,
font = 'Courier',
size = 12,
scrollback = 500,
showStatus = 0
)
]
This creates a single world, Wayne's World, located at wayne.com:4000 that will be connected to on startup. The window size will be 640x480 and located 64 pixels down and 64 pixels to the right of the top-left hand corner of the desktop. If the 'geometry' field is set to None, a default size and position is used. The 'wrap' field should be one of 'none', 'word', or 'char', and determines the style of line wrapping used by this world. 'filters' is a list of input filters or None. 'font' and 'size' determine how text is displayed in the output window. 'scrollback' is the number of lines that will be retained in memory for each window connected to this world. showStatus is either 0 or 1 and controls whether the status bar is shown below the input field or not.
As of version 0.2.4, the prefered way to modify the configuration is directly through the GUI rather than by editing the configuration file.
FILTERS
OGC filters perform the same task as triggers in most clients, but also have the capability to redirect output to other windows, transform it before it is displayed, and more. Filters are written in Python and can be anything from simple variable assignment to complicated rule definitions using classes and functions.
In the basic form, a filter body contains two variables, "trigger" and "output". If "trigger" is bound to a string, it is treated as a regular expression (A full explanation of regular expressions is beyond the scope of this document. See http://arglist.com/regex/regex7.html as well as the python-specific howto http://py-howto.sourceforge.net/regex/regex.html for a comprehensive introduction) and incoming text is matched against it. For example, to match the prompt on a MUD that sends something like "<100hp 100ma 100mv>", the filter body should contain:
trigger = '<([0123456789]+)hp ([0123456789]+)ma ([01234567890]+)mv>'
or more simply:
trigger = '<(\d+)hp (\d+)ma (\d+)mv>'
There are two simple options for the other half of this filter, "output". The simplest is to make it a string as well. It will be interpolated with the matched "groups" (anything between parenthesis in the trigger) and then sent to the game server. For example:
output = 'say My hitpoints are %s. My mana is %s. My movement points are %s.'
It is important that each matched group has a "format specifier" - a % followed by a format character. If there are more or fewer groups than format specifiers, the trigger will not function. Note that you probably shouldn't try out this filter, because the say command usually causes another prompt to be sent, which will be matched, causing another say to be sent to the game, etc.
The other option for "output" is to make it a function. The above could be duplicated with this definition:
def output(hp, ma, mv):
fmt = 'say My hitpoints are %s. My mana is %s. My movement points are %s.' sendToWorld(fmt % (hp, ma, mv))
To make things more interesting, here is a definition that would somewhat alleviate the infinite-loop problem with this example:
import time
lastTime = 0
def output(hp, ma, mv):
global lastTime
if lastTime + 1 > time.time():
# This was triggered less than one second ago, don't do anything
return
else:
fmt = 'say My hitpoints are %s. My mana is %s. My movement points are %s.'
sendToWorld(fmt % (hp, ma, mv))
lastTime = time.time()
