Evennia allows for a lot of freedom when designing your game - but to code efficiently you still need to adopt some best practices as well as find a good place to start to learn.
Here are some pointers to get you going.
Evennia is developed using Python. Even if you are more of a designer than a coder, it is wise to learn how to read and understand basic Python code. If you are new to Python, or need a refresher, take a look at our two-part Python introduction.
Explore Evennia interactively¶
When new to Evennia it can be hard to find things or figure out what is available. Evennia offers a special interactive python shell that allows you to experiment and try out things. It’s recommended to use ipython for this since the vanilla python prompt is very limited. Here are some simple commands to get started:
# [open a new console/terminal] # [activate your evennia virtualenv in this console/terminal] pip install ipython # [only needed the first time] cd mygame evennia shell
This will open an Evennia-aware python shell (using ipython). From within this shell, try
import evennia evennia.<TAB>
That is, enter
evennia. and press the
<TAB> key. This will show you all the resources made
available at the top level of Evennia’s “flat API”. See the flat API page for more
info on how to explore it efficiently.
You can complement your exploration by peeking at the sections of the much more detailed Developer Central. The Tutorials section also contains a growing collection of system- or implementation-specific help.
Use a python syntax checker¶
Evennia works by importing your own modules and running them as part of the server. Whereas Evennia should just gracefully tell you what errors it finds, it can nevertheless be a good idea for you to check your code for simple syntax errors before you load it into the running server. There are many python syntax checkers out there. A fast and easy one is pyflakes, a more verbose one is pylint. You can also check so that your code looks up to snuff using pep8. Even with a syntax checker you will not be able to catch every possible problem - some bugs or problems will only appear when you actually run the code. But using such a checker can be a good start to weed out the simple problems.
Plan before you code¶
Before you start coding away at your dream game, take a look at our Game Planning page. It might hopefully help you avoid some common pitfalls and time sinks.
Code in your game folder, not in the evennia/ repository¶
As part of the Evennia setup you will create a game folder to host your game code. This is your
home. You should never need to modify anything in the
evennia library (anything you download
from us, really). You import useful functionality from here and if you see code you like, copy&paste
it out into your game folder and edit it there.
If you find that Evennia doesn’t support some functionality you need, make a Feature Request about it. Same goes for bugs. If you add features or fix bugs yourself, please consider Contributing your changes upstream!
Learn to read tracebacks¶
Python is very good at reporting when and where things go wrong. A traceback shows everything you need to know about crashing code. The text can be pretty long, but you usually are only interested in the last bit, where it says what the error is and at which module and line number it happened - armed with this info you can resolve most problems.
Evennia will usually not show the full traceback in-game though. Instead the server outputs errors
to the terminal/console from which you started Evennia in the first place. If you want more to show
in-game you can add
IN_GAME_ERRORS = True to your settings file. This will echo most (but not all)
tracebacks both in-game as well as to the terminal/console. This is a potential security problem
though, so don’t keep this active when your game goes into production.
A common confusing error is finding that objects in-game are suddenly of the type
DefaultObjectrather than your custom typeclass. This happens when you introduce a critical Syntax error to the module holding your custom class. Since such a module is not valid Python, Evennia can’t load it at all. Instead of crashing, Evennia will then print the full traceback to the terminal/console and temporarily fall back to the safe
DefaultObjectuntil you fix the problem and reload.
Docs are here to help you¶
Some people find reading documentation extremely dull and shun it out of principle. That’s your call, but reading docs really does help you, promise! Evennia’s documentation is pretty thorough and knowing what is possible can often give you a lot of new cool game ideas. That said, if you can’t find the answer in the docs, don’t be shy to ask questions! The discussion group and the irc chat are also there for you.
The most important point¶
And finally, of course, have fun!