5. Adding Rooms and Objects from Code¶
You've already built rooms and objects with in-game commands (@dig, @create) in the Builder's Guide. Those same things can be built with Python using create_object, through the @py command — useful once you want to build many things at once, or build them with custom starting behavior.
> @py evennia.create_object("typeclasses.objects.Object", key="a rusty key", location=here)
<Object: a rusty key>
"typeclasses.objects.Object" is the typeclass (the blueprint from Lesson 3) to build from, key is its name, and location=here drops it in the room you're standing in (here is a shortcut @py understands for your current room).
Rooms work the same way:
> @py evennia.create_object("typeclasses.rooms.Room", key="The Armory")
<Room: The Armory>
A room made this way has no exits yet — you'd still connect it with @open, same as any room you dig with @dig.
Try it
Use @py to create one object in your current room, then look to confirm it's there.
Tip
@py runs real Python, one line at a time — the same rules from Unit 3 apply, including that a typo gives you a traceback to read.