Python Universe Builder

PUB Overview

PUB consists of a set of Python files: In addition, any game will include a main program file which sets up the game objects and makes it run.

There are several key concepts to understand in PUB. First, it is fully object-oriented; if you're comfy with that concept, skip to the next paragraph. Here's the idea: you define a class, which is a data structure with certain attributes (name, description, and so on). A class also defines some functions which can be applied to objects of that class. So far, pretty simple. Here's the neat bit: when defining a new class, you don't have to start from scratch. Instead, you can declare a base class, and your new class will automatically inherit all the attributes and functions of that base class. You just define whatever new properties or different functions make your new class different from its base.

There are only two big sets of related classes: Things and Verbs. Other PUB classes include Event, which keeps track of some code to be executed in the future; the Scheduler, which maintains a list of Events; the Command class, which stores the actor, verb, and objects involved in any action; and the Parser class, which takes a string (e.g., typed by the player) and breaks it into Commands.

Everything you see in the game -- the rooms, the rocks, the characters, even you (the player) -- is a Thing. A Thing is a Python object which has attributes such as name, desc, and size, and methods like GetName(), GetNote(), and so on. These are all explained in the Thing page of the library reference. Two methods especially deserve note:


What happens when the player types a command?

Here's the exact sequence of calls that get executed when a player enters a command. You'll rarely need to know most of this, but since you insist...
http://www.strout.net/python/pub/doc/overview.html
Last Modified: 5/04/96 . . . . . . Joe Strout . . . joe@strout.net