Skip to content

3. Classes and Objects

Every room, exit, and item you've already created in the Builder's Guide with @dig, @open, and @create is a Python object — a specific thing built from a class, which is the blueprint for it.

Open mudgame/typeclasses/rooms.py and you'll find the blueprint for every room in your game:

from evennia.objects.objects import DefaultRoom
from .objects import ObjectParent


class Room(ObjectParent, DefaultRoom):
    """
    Rooms are like any Object, except their location is None.
    """
    pass

pass means "nothing extra — just use all the default behavior Evennia already provides." Every room you've dug with @dig is an object built from exactly this Room class. When you want your rooms to behave differently, this is the file where that change goes.

The same pattern repeats in typeclasses/objects.py (items), characters.py (your avatar), and exits.py (the connections between rooms) — each with its own pass waiting to be replaced with real code.

Try it

Open typeclasses/rooms.py and typeclasses/objects.py in nano and find the pass line in each. That's where code from later lessons in this unit will go.

Tip

You don't need to understand everything else in these files yet — functions, parameters, and classes all work the same way they did in Unit 3, just organized by Evennia's conventions.

Next: Your First Custom Command →