<li><aclass="reference internal"href="#forgetting-to-use-reload-to-see-changes-to-your-typeclasses">Forgetting to use <codeclass="docutils literal notranslate"><spanclass="pre">reload</span></code> to see changes to your typeclasses</a></li>
<li><aclass="reference internal"href="#web-admin-to-create-new-account">Web admin to create new Account</a></li>
<li><aclass="reference internal"href="#mutable-attributes-and-their-connection-to-the-database">Mutable attributes and their connection to the database</a></li>
<li><aclass="reference internal"href="#commands-are-matched-by-name-or-alias">Commands are matched by name <em>or</em> alias</a></li>
<li><aclass="reference internal"href="#objects-turning-to-defaultobject">Objects turning to <codeclass="docutils literal notranslate"><spanclass="pre">DefaultObject</span></code></a></li>
<li><aclass="reference internal"href="#overriding-of-magic-methods">Overriding of magic methods</a></li>
<li><aclass="reference internal"href="#things-to-remember-about-the-flat-api">Things to remember about the flat API</a><ul>
<li><aclass="reference internal"href="#to-remember-when-importing-from-evennia">To remember when importing from <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code></a></li>
<h2>Forgetting to use <codeclass="docutils literal notranslate"><spanclass="pre">reload</span></code> to see changes to your typeclasses<aclass="headerlink"href="#forgetting-to-use-reload-to-see-changes-to-your-typeclasses"title="Permalink to this headline">¶</a></h2>
<p>Firstly: Reloading the server is a safe and usually quick operation which will <em>not</em> disconnect any
accounts.</p>
<p>New users tend to forget this step. When editing source code (such as when tweaking typeclasses and
commands or adding new commands to command sets) you need to either use the in-game <codeclass="docutils literal notranslate"><spanclass="pre">@reload</span></code>
command or, from the command line do <codeclass="docutils literal notranslate"><spanclass="pre">python</span><spanclass="pre">evennia.py</span><spanclass="pre">reload</span></code> before you see your changes.</p>
<p>If you use the default login system and are trying to use the Web admin to create a new Player
account, you need to consider which <codeclass="docutils literal notranslate"><spanclass="pre">MULTIACCOUNT_MODE</span></code> you are in. If you are in
<codeclass="docutils literal notranslate"><spanclass="pre">MULTIACCOUNT_MODE</span></code><codeclass="docutils literal notranslate"><spanclass="pre">0</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">1</span></code>, the login system expects each Account to also have a Character
object named the same as the Account - there is no character creation screen by default. If using
the normal mud login screen, a Character with the same name is automatically created and connected
to your Account. From the web interface you must do this manually.</p>
<p>So, when creating the Account, make sure to also create the Character <em>from the same form</em> as you
create the Account from. This should set everything up for you. Otherwise you need to manually set
the “account” property on the Character and the “character” property on the Account to point to each
other. You must also set the lockstring of the Character to allow the Account to “puppet” this
<h2>Mutable attributes and their connection to the database<aclass="headerlink"href="#mutable-attributes-and-their-connection-to-the-database"title="Permalink to this headline">¶</a></h2>
<p>When storing a mutable object (usually a list or a dictionary) in an Attribute</p>
<p>you should know that the connection to the database is retained also if you later extract that
Attribute into another variable (what is stored and retrieved is actually a <codeclass="docutils literal notranslate"><spanclass="pre">PackedList</span></code> or a
<codeclass="docutils literal notranslate"><spanclass="pre">PackedDict</span></code> that works just like their namesakes except they save themselves to the database when
<p>this updates the database behind the scenes, so both <codeclass="docutils literal notranslate"><spanclass="pre">alist</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">object.db.mylist</span></code> are now
<p>The property <codeclass="docutils literal notranslate"><spanclass="pre">blist</span></code> is now <codeclass="docutils literal notranslate"><spanclass="pre">[1,2,3,4]</span></code> whereas <codeclass="docutils literal notranslate"><spanclass="pre">object.db.mylist</span></code> remains unchanged. If you want to
update the database you’d need to explicitly re-assign the updated data to the <codeclass="docutils literal notranslate"><spanclass="pre">mylist</span></code> Attribute.</p>
<h2>Commands are matched by name <em>or</em> alias<aclass="headerlink"href="#commands-are-matched-by-name-or-alias"title="Permalink to this headline">¶</a></h2>
<p>When merging <aclass="reference internal"href="../Components/Commands.html"><spanclass="doc std std-doc">command sets</span></a> it’s important to remember that command objects are identified
<em>both</em> by key <em>or</em> alias. So if you have a command with a key <codeclass="docutils literal notranslate"><spanclass="pre">look</span></code> and an alias <codeclass="docutils literal notranslate"><spanclass="pre">ls</span></code>, introducing
another command with a key <codeclass="docutils literal notranslate"><spanclass="pre">ls</span></code> will be assumed by the system to be <em>identical</em> to the first one.
This usually means merging cmdsets will overload one of them depending on priority. Whereas this is
logical once you know how command objects are handled, it may be confusing if you are just looking
at the command strings thinking they are parsed as-is.</p>
<h2>Objects turning to <codeclass="docutils literal notranslate"><spanclass="pre">DefaultObject</span></code><aclass="headerlink"href="#objects-turning-to-defaultobject"title="Permalink to this headline">¶</a></h2>
<p>A common confusing error for new developers is finding that one or more objects in-game are suddenly
of the type <codeclass="docutils literal notranslate"><spanclass="pre">DefaultObject</span></code> rather than the typeclass you wanted it to be. 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 to get to the typeclasses within. To keep on running,
Evennia will solve this by printing the full traceback to the terminal/console and temporarily fall
back to the safe <codeclass="docutils literal notranslate"><spanclass="pre">DefaultObject</span></code> until you fix the problem and reload. Most errors of this kind will
be caught by any good text editors. Keep an eye on the terminal/console during a reload to catch
such errors - you may have to scroll up if your window is small.</p>
<p>Python implements a system of <aclass="reference external"href="https://docs.python.org/3/reference/datamodel.html#emulating-container-types">magic
methods</a>, usually
prefixed and suffixed by double-underscores (<codeclass="docutils literal notranslate"><spanclass="pre">__example__</span></code>) that allow object instances to have
certain operations performed on them without needing to do things like turn them into strings or
numbers first– for example, is <codeclass="docutils literal notranslate"><spanclass="pre">obj1</span></code> greater than or equal to <codeclass="docutils literal notranslate"><spanclass="pre">obj2</span></code>?</p>
<p>Neither object is a number, but given <codeclass="docutils literal notranslate"><spanclass="pre">obj1.size</span><spanclass="pre">==</span><spanclass="pre">"small"</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">obj2.size</span><spanclass="pre">==</span><spanclass="pre">"large"</span></code>, how might
one compare these two arbitrary English adjective strings to figure out which is greater than the
other? By defining the <codeclass="docutils literal notranslate"><spanclass="pre">__ge__</span></code> (greater than or equal to) magic method on the object class in which
you figure out which word has greater significance, perhaps through use of a mapping table
(<codeclass="docutils literal notranslate"><spanclass="pre">{'small':0,</span><spanclass="pre">'large':10}</span></code>) or other lookup and comparing the numeric values of each.</p>
<p>Evennia extensively makes use of magic methods on typeclasses to do things like initialize objects,
check object existence or iterate over objects in an inventory or container. If you override or
interfere with the return values from the methods Evennia expects to be both present and working, it
can result in very inconsistent and hard-to-diagnose errors.</p>
<p>The moral of the story– it can be dangerous to tinker with magic methods on typeclassed objects.
<h2>Things to remember about the flat API<aclass="headerlink"href="#things-to-remember-about-the-flat-api"title="Permalink to this headline">¶</a></h2>
<p>The flat API is a series of ‘shortcuts’ on the <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code> main library root (defined in
<codeclass="docutils literal notranslate"><spanclass="pre">evennia/__init__.py</span></code>). Its componentas are documented <aclass="reference internal"href="../Evennia-API.html"><spanclass="doc std std-doc">as part of the auto-documentation</span></a>.</p>
<h3>To remember when importing from <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code><aclass="headerlink"href="#to-remember-when-importing-from-evennia"title="Permalink to this headline">¶</a></h3>
<p>Properties on the root of the <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code> package are <em>not</em> modules in their own right. They are just
shortcut properties stored in the <codeclass="docutils literal notranslate"><spanclass="pre">evennia/__init__.py</span></code> module. That means that you cannot use dot-
notation to <codeclass="docutils literal notranslate"><spanclass="pre">import</span></code> nested module-names over <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code>. The rule of thumb is that you cannot use
<codeclass="docutils literal notranslate"><spanclass="pre">import</span></code> for more than one level down. Hence you can do</p>
<p>This will give you an <codeclass="docutils literal notranslate"><spanclass="pre">ImportError</span></code> telling you that the module <codeclass="docutils literal notranslate"><spanclass="pre">default_cmds</span></code> cannot be found -
this is becasue <codeclass="docutils literal notranslate"><spanclass="pre">default_cmds</span></code> is just a <em>variable</em> stored in <codeclass="docutils literal notranslate"><spanclass="pre">evennia.__init__.py</span></code>; this cannot be
imported from. If you really want full control over which level of package you import you can always
bypass the root package and import directly from from the real location. For example
<codeclass="docutils literal notranslate"><spanclass="pre">evennia.DefaultObject</span></code> is a shortcut to <codeclass="docutils literal notranslate"><spanclass="pre">evennia.objects.objects.DefaultObject</span></code>. Using this full
path will have the import mechanism work normally. See <codeclass="docutils literal notranslate"><spanclass="pre">evennia/__init__.py</span></code> to see where the