<h1><spanclass="section-number">4. </span>Overview of your new Game Dir<aclass="headerlink"href="#overview-of-your-new-game-dir"title="Permalink to this headline">¶</a></h1>
<p>Next we will take a little detour to look at the <em>Tutorial World</em>. This is a little solo adventure
that comes with Evennia, a showcase for some of the things that are possible.</p>
<p>Now we have ‘run the game’ a bit and started with our forays into Python from inside Evennia.
It is time to start to look at how things look ‘outside of the game’. Let’s do a tour of your game-dir
Like everywhere in the docs we’ll assume it’s called <codeclass="docutils literal notranslate"><spanclass="pre">mygame</span></code>.</p>
<blockquote>
<div><p>When looking through files, ignore files ending with <codeclass="docutils literal notranslate"><spanclass="pre">.pyc</span></code> and the
<codeclass="docutils literal notranslate"><spanclass="pre">__pycache__</span></code> folder if it exists. This is internal Python compilation files that you should never
need to touch. Files <codeclass="docutils literal notranslate"><spanclass="pre">__init__.py</span></code> is also often empty and can be ignored (they have to do with
Python package management).</p>
</div></blockquote>
<p>You may have noticed when we were building things in-game that we would often refer to code through
<divclass="highlight-none notranslate"><divclass="highlight"><pre><span></span>A 'python path' uses '.' instead of '/' or '`\\`' and
skips the `.py` ending of files. It can also point to
the code contents of python files. Since Evennia is already
looking for code in your game dir, your python paths can start
from there.
So a path `/home/foo/devel/mygame/commands/command.py`
would translate to a Python-path `commands.command`.
<p>This is a fundamental aspect of coding Evennia - <em>you create code and then you tell Evennia where that
code is and when it should be used</em>. Above we told it to create a red button by pulling from specific code
in the <codeclass="docutils literal notranslate"><spanclass="pre">contribs/</span></code> folder but the same principle is true everywhere. So it’s important to know where code is
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">commands/</span></code> - This holds all your custom commands (user-input handlers). You both add your own
and override Evennia’s defaults from here.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">server</span></code>/ - The structure of this folder should not change since Evennia expects it.</p>
<ul>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">conf/</span></code> - All server configuration files sits here. The most important file is <codeclass="docutils literal notranslate"><spanclass="pre">settings.py</span></code>.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">logs/</span></code> - Server log files are stored here. When you use <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span><spanclass="pre">--log</span></code> you are actually
tailing the files in this directory.</p></li>
</ul>
</li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">typeclasses/</span></code> - this holds empty templates describing all database-bound entities in the
game, like Characters, Scripts, Accounts etc. Adding code here allows to customize and extend
the defaults.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">web/</span></code> - This is where you override and extend the default templates, views and static files used
for Evennia’s web-presence, like the website and the HTML5 webclient.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">world/</span></code> - this is a “miscellaneous” folder holding everything related to the world you are
building, such as build scripts and rules modules that don’t fit with one of the other folders.</p></li>
</ul>
</li>
</ul>
<blockquote>
<div><p>The <codeclass="docutils literal notranslate"><spanclass="pre">server/</span></code> subfolder should remain the way it is - Evennia expects this. But you could in
principle change the structure of the rest of your game dir as best fits your preference.
Maybe you don’t need a world/ folder but prefer many folders with different aspects of your world?
Or a new folder ‘rules’ for your RPG rules? This is fine. If you move things around you just need
to update Evennia’s default settings to point to the right places in the new structure.</p>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">commands/</span></code> folder holds Python modules related to creating and extending the <aclass="reference internal"href="../../../Components/Commands.html"><spanclass="doc std std-doc">Commands</span></a>
of Evennia. These manifest in game like the server understanding input like <codeclass="docutils literal notranslate"><spanclass="pre">look</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">dig</span></code>.</p>
<divclass="highlight-none notranslate"><divclass="highlight"><pre><span></span>A `class` is template for creating object-instances of a particular type
in Python. We will explain classes in more detail in the next
<li><p><aclass="reference external"href="https://github.com/evennia/evennia/blob/master/evennia/game_template/commands/command.py">command.py</a> (Python-path: <codeclass="docutils literal notranslate"><spanclass="pre">commands.command</span></code>) - this contain the
base <em>classes</em> for designing new input commands, or override the defaults.</p></li>
a cmdset (Command-Set) groups Commands together. Command-sets can be added and removed from objects on the fly,
meaning a user could have a different set of commands (or versions of commands) available depending on their circumstance
in the game. In order to add a new command to the game, it’s common to import the new command-class
from <codeclass="docutils literal notranslate"><spanclass="pre">command.py</span></code> and add it to one of the default cmdsets in this module.</p></li>
<p>This folder contains resource necessary for running Evennia. Contrary to the other folders, the structure
of this should be kept the way it is.</p>
<ulclass="simple">
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">evennia.db3</span></code> - you will only have this file if you are using the default SQLite3 database. This file
contains the entire database. Just copy it to make a backup. For development you could also just
make a copy once you have set up everything you need and just copy that back to ‘reset’ the state.
If you delete this file you can easily recreate it by running <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span><spanclass="pre">migrate</span></code>.</p></li>
<p>This holds the server logs. When you do <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span><spanclass="pre">--log</span></code>, the evennia program is in fact tailing and concatenating
the <codeclass="docutils literal notranslate"><spanclass="pre">server.log</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">portal.log</span></code> files in this directory. The logs are rotated every week. Depending on your settings,
other logs, like the webserver HTTP request log can also be found here.</p>
<p>This contains all configuration files of the Evennia server. These are regular Python modules which
means that they must be extended with valid Python. You can also add logic to them if you wanted to.</p>
<p>Common for the settings is that you generally will never them directly via their python-path; instead Evennia
knows where they are and will read them to configure itself at startup.</p>
<ul>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">settings.py</span></code> - this is by far the most important file. It’s nearly empty by default, rather you
are expected to copy&paste the changes you need from <aclass="reference external"href="https://github.com/evennia/evennia/blob/master/evennia/default_settings.py">evennia/default_settings.py</a>.
The default settings file is extensively documented. Importing/accessing the values in the settings
<p>You cannot assign to the settings file dynamically; you must change the <codeclass="docutils literal notranslate"><spanclass="pre">settings.py</span></code> file directly to
change a setting.</p>
</li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">secret_settings.py</span></code> - If you are making your code effort public, you may not want to share all settings online.
There may be server-specific secrets or just fine-tuning for your game systems that you prefer be kept secret
from the players. Put such settings in here, it will override values in <codeclass="docutils literal notranslate"><spanclass="pre">settings.py</span></code> and not be included in
version control.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">at_initial_setup.py</span></code> - When Evennia starts up for the very first time, it does some basic tasks, like creating the
superuser and Limbo room. Adding to this file allows to add more actions for it to for first-startup.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">at_search.py</span></code> - When searching for objects and either finding no match or more than one match, it will
respond by giving a warning or offering the user to differentiate between the multiple matches. Modifying
the code here will change this behavior to your liking.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">at_server_startstop.py</span></code> - This allows to inject code to execute every time the server starts, stops or reloads
in different ways.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">connection_screens.py</span></code> - This allows for changing the connection screen you see when you first connect to your
game.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">inlinefuncs.py</span></code> - <em>Inlinefuncs</em> are optional and limited ‘functions’ that can be embedded in any strings being
sent to a player. They are written as <codeclass="docutils literal notranslate"><spanclass="pre">$funcname(args)</span></code> and are used to customize the output
depending on the user receiving it. For example sending people the text <codeclass="docutils literal notranslate"><spanclass="pre">"Let's</span><spanclass="pre">meet</span><spanclass="pre">at</span><spanclass="pre">$realtime(13:00,</span><spanclass="pre">GMT)!</span></code>
would show every player seeing that string the time given in their own time zone. The functions added to this
module will become new inlinefuncs in the game.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">inputfucs.py</span></code> - When a command like <codeclass="docutils literal notranslate"><spanclass="pre">look</span></code> is received by the server, it is handled by an <em>inputfunc</em>
that redirects it to the cmdhandler system. But there could be other inputs coming from the clients, like
button-presses or the request to update a health-bar. While most common cases are already covered, this is
where one adds new functions to process new types of input.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">lockfuncs.py</span></code> - <em>Locks</em> restrict access to things in-game. Lock funcs are used in a mini-language
to defined more complex locks. For example you could have a lockfunc that checks if the user is carrying
a given item, is bleeding or has a certain skill value. New functions added in this modules will
become available for use in lock definitions.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">mssp.py</span></code> - Mud Server Status Protocol is a way for online MUD archives/listings (which you usually have
to sign up for) to track which MUDs are currently online, how many players they have etc. While Evennia handles
the dynamic information automatically, this is were you set up the meta-info about your game, such as its
theme, if player-killing is allowed and so on. This is a more generic form of the Evennia Game directory.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">portal_services_plugins.py</span></code> - If you want to add new external connection protocols to Evennia, this is the place
to add them.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">server_services_plugins.py</span></code> - This allows to override internal server connection protocols.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">web_plugins.py</span></code> - This allows to add plugins to the Evennia webserver as it starts.</p></li>
<p>The <aclass="reference internal"href="../../../Components/Typeclasses.html"><spanclass="doc std std-doc">Typeclasses</span></a> of Evennia are Evennia-specific Python classes whose instances save themselves
<aclass="reference internal"href="../../../Components/Accounts.html"><spanclass="doc std std-doc">Account</span></a> represents the player connecting to the game. It holds information like email,
<aclass="reference internal"href="../../../Components/Channels.html"><spanclass="doc std std-doc">Channels</span></a> are used to manage in-game communication between players.</p></li>
<aclass="reference internal"href="../../../Components/Objects.html"><spanclass="doc std std-doc">Objects</span></a> represent all things having a location within the game world.</p></li>
The <aclass="reference internal"href="../../../Components/Objects.html#characters"><spanclass="std std-doc">Character</span></a> is a subclass of Objects, controlled by Accounts - they are the player’s
<aclass="reference internal"href="../../../Components/Objects.html#rooms"><spanclass="std std-doc">Room</span></a> is also a subclass of Object; describing discrete locations. While the traditional
<aclass="reference internal"href="../../../Components/Objects.html#exits"><spanclass="std std-doc">Exits</span></a> is another subclass of Object. Exits link one Room to another.</p></li>
<aclass="reference internal"href="../../../Components/Scripts.html"><spanclass="doc std std-doc">Scripts</span></a> are ‘out-of-character’ objects. They have no location in-game and can serve as basis for
<p>This folder contains folders for overriding the default web-presence of Evennia with your own designs.
Most of these folders are empty except for a README file or a subset of other empty folders.</p>
<ulclass="simple">
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">media/</span></code> - this empty folder is where you can place your own images or other media files you want the
web server to serve. If you are releasing your game with a lot of media (especially if you want videos) you
should consider re-pointing Evennia to use some external service to serve your media instead.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">static_overrides/</span></code> - ‘static’ files include fonts, CSS and JS. Within this folder you’ll find sub-folders for
overriding the static files for the <codeclass="docutils literal notranslate"><spanclass="pre">admin</span></code> (this is the Django web-admin), the <codeclass="docutils literal notranslate"><spanclass="pre">webclient</span></code> (this is thet
HTML5 webclient) and the <codeclass="docutils literal notranslate"><spanclass="pre">website</span></code>. Adding files to this folder will replace same-named files in the
default web presence.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">template_overrides/</span></code> - these are HTML files, for the <codeclass="docutils literal notranslate"><spanclass="pre">webclient</span></code> and the <codeclass="docutils literal notranslate"><spanclass="pre">website</span></code>. HTML files are written
using <aclass="reference external"href="https://jinja.palletsprojects.com/en/2.11.x/">Jinja</a> templating, which means that one can override
only particular parts of a default template without touching others.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">static/</span></code> - this is a work-directory for the web system and should <em>not</em> be manually modified. Basically,
Evennia will copy static data from <codeclass="docutils literal notranslate"><spanclass="pre">static_overrides</span></code> here when the server starts.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">urls.py</span></code> - this module links up the Python code to the URLs you go to in the browser.</p></li>
<p>This folder only contains some example files. It’s meant to hold ‘the rest’ of your game implementation. Many
people change and re-structure this in various ways to better fit their ideas.</p>
<ulclass="simple">
<li><p><aclass="reference external"href="https://github.com/evennia/evennia/blob/master/evennia/game_template/world/batch_cmds.ev">batch_cmds.ev</a> - This is an <codeclass="docutils literal notranslate"><spanclass="pre">.ev</span></code> file, which is essentially
just a list of Evennia commands to execute in sequence. This one is empty and ready to expand on. The
<aclass="reference internal"href="Tutorial-World.html"><spanclass="doc std std-doc">Tutorial World</span></a> was built with such a batch-file.</p></li>
<li><p><aclass="reference external"href="https://github.com/evennia/evennia/blob/master/evennia/game_template/world/prototypes.py">prototypes.py</a> - A <aclass="reference internal"href="../../../Components/Prototypes.html"><spanclass="doc std std-doc">prototype</span></a> is a way