mirror of
https://github.com/evennia/evennia.git
synced 2026-03-18 22:06:30 +01:00
235 lines
No EOL
18 KiB
HTML
235 lines
No EOL
18 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||
|
||
<title>Quirks — Evennia 1.0-dev documentation</title>
|
||
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/language_data.js"></script>
|
||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
</head><body>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">Quirks</a></li>
|
||
</ul>
|
||
<div class="develop">develop branch</div>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="quirks">
|
||
<h1>Quirks<a class="headerlink" href="#quirks" title="Permalink to this headline">¶</a></h1>
|
||
<p>This is a list of various quirks or common stumbling blocks that people often ask about or report
|
||
when using (or trying to use) Evennia. They are not bugs.</p>
|
||
<section id="forgetting-to-use-reload-to-see-changes-to-your-typeclasses">
|
||
<h2>Forgetting to use @reload to see changes to your typeclasses<a class="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 <code class="docutils literal notranslate"><span class="pre">@reload</span></code>
|
||
command or, from the command line do <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">evennia.py</span> <span class="pre">reload</span></code> before you see your changes.</p>
|
||
</section>
|
||
<section id="web-admin-to-create-new-account">
|
||
<h2>Web admin to create new Account<a class="headerlink" href="#web-admin-to-create-new-account" title="Permalink to this headline">¶</a></h2>
|
||
<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 <code class="docutils literal notranslate"><span class="pre">MULTIACCOUNT_MODE</span></code> you are in. If you are in
|
||
<code class="docutils literal notranslate"><span class="pre">MULTIACCOUNT_MODE</span></code> <code class="docutils literal notranslate"><span class="pre">0</span></code> or <code class="docutils literal notranslate"><span class="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
|
||
particular character.</p>
|
||
</section>
|
||
<section id="mutable-attributes-and-their-connection-to-the-database">
|
||
<h2>Mutable attributes and their connection to the database<a class="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>
|
||
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span> <span class="nb">object</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">mylist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">]</span>
|
||
</pre></div>
|
||
</td></tr></table></div>
|
||
<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 <code class="docutils literal notranslate"><span class="pre">PackedList</span></code> or a
|
||
<code class="docutils literal notranslate"><span class="pre">PackedDict</span></code> that works just like their namesakes except they save themselves to the database when
|
||
changed). So if you do</p>
|
||
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
||
<span class="normal">2</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span> <span class="n">alist</span> <span class="o">=</span> <span class="nb">object</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">mylist</span>
|
||
<span class="n">alist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span>
|
||
</pre></div>
|
||
</td></tr></table></div>
|
||
<p>this updates the database behind the scenes, so both <code class="docutils literal notranslate"><span class="pre">alist</span></code> and <code class="docutils literal notranslate"><span class="pre">object.db.mylist</span></code> are now
|
||
<code class="docutils literal notranslate"><span class="pre">[1,2,3,4]</span></code></p>
|
||
<p>If you don’t want this, Evennia provides a way to stably disconnect the mutable from the database by
|
||
use of <code class="docutils literal notranslate"><span class="pre">evennia.utils.dbserialize.deserialize</span></code>:</p>
|
||
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
||
<span class="normal">2</span>
|
||
<span class="normal">3</span>
|
||
<span class="normal">4</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span> <span class="kn">from</span> <span class="nn">evennia.utils.dbserialize</span> <span class="kn">import</span> <span class="n">deserialize</span>
|
||
|
||
<span class="n">blist</span> <span class="o">=</span> <span class="n">deserialize</span><span class="p">(</span><span class="nb">object</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">mylist</span><span class="p">)</span>
|
||
<span class="n">blist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span>
|
||
</pre></div>
|
||
</td></tr></table></div>
|
||
<p>The property <code class="docutils literal notranslate"><span class="pre">blist</span></code> is now <code class="docutils literal notranslate"><span class="pre">[1,2,3,4]</span></code> whereas <code class="docutils literal notranslate"><span class="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 <code class="docutils literal notranslate"><span class="pre">mylist</span></code> Attribute.</p>
|
||
</section>
|
||
<section id="commands-are-matched-by-name-or-alias">
|
||
<h2>Commands are matched by name <em>or</em> alias<a class="headerlink" href="#commands-are-matched-by-name-or-alias" title="Permalink to this headline">¶</a></h2>
|
||
<p>When merging <a class="reference internal" href="../Components/Commands.html"><span class="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 <code class="docutils literal notranslate"><span class="pre">look</span></code> and an alias <code class="docutils literal notranslate"><span class="pre">ls</span></code>, introducing
|
||
another command with a key <code class="docutils literal notranslate"><span class="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>
|
||
</section>
|
||
<section id="objects-turning-to-defaultobject">
|
||
<h2>Objects turning to <code class="docutils literal notranslate"><span class="pre">DefaultObject</span></code><a class="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 <code class="docutils literal notranslate"><span class="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 <code class="docutils literal notranslate"><span class="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>
|
||
</section>
|
||
<section id="overriding-of-magic-methods">
|
||
<h2>Overriding of magic methods<a class="headerlink" href="#overriding-of-magic-methods" title="Permalink to this headline">¶</a></h2>
|
||
<p>Python implements a system of <a class="reference external" href="https://docs.python.org/3/reference/datamodel.html#emulating-container-types">magic
|
||
methods</a>, usually
|
||
prefixed and suffixed by double-underscores (<code class="docutils literal notranslate"><span class="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 <code class="docutils literal notranslate"><span class="pre">obj1</span></code> greater than or equal to <code class="docutils literal notranslate"><span class="pre">obj2</span></code>?</p>
|
||
<p>Neither object is a number, but given <code class="docutils literal notranslate"><span class="pre">obj1.size</span> <span class="pre">==</span> <span class="pre">"small"</span></code> and <code class="docutils literal notranslate"><span class="pre">obj2.size</span> <span class="pre">==</span> <span class="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 <code class="docutils literal notranslate"><span class="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
|
||
(<code class="docutils literal notranslate"><span class="pre">{'small':0,</span> <span class="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.
|
||
Try to avoid doing so.</p>
|
||
</section>
|
||
<section id="known-upstream-bugs">
|
||
<h2>Known upstream bugs<a class="headerlink" href="#known-upstream-bugs" title="Permalink to this headline">¶</a></h2>
|
||
<ul>
|
||
<li><p>There is currently (Autumn 2017) a bug in the <code class="docutils literal notranslate"><span class="pre">zope.interface</span></code> installer on some Linux Ubuntu
|
||
distributions (notably Ubuntu 16.04 LTS). Zope is a dependency of Twisted. The error manifests in
|
||
the server not starting with an error that <code class="docutils literal notranslate"><span class="pre">zope.interface</span></code> is not found even though <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">list</span></code>
|
||
shows it’s installed. The reason is a missing empty <code class="docutils literal notranslate"><span class="pre">__init__.py</span></code> file at the root of the zope
|
||
package. If the virtualenv is named “evenv” as suggested in the <a class="reference internal" href="../Setup/Setup-Quickstart.html"><span class="doc">Setup Quickstart</span></a>
|
||
instructions, use the following command to fix it:</p>
|
||
<div class="highlight-shell notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span>touch evenv/local/lib/python2.7/site-packages/zope/__init__.py
|
||
</pre></div>
|
||
</td></tr></table></div>
|
||
<p>This will create the missing file and things should henceforth work correctly.</p>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
<div class="clearer"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<p class="logo"><a href="../index.html">
|
||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
|
||
</a></p>
|
||
<div id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="../search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script>$('#searchbox').show(0);</script>
|
||
<p><h3><a href="../index.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">Quirks</a><ul>
|
||
<li><a class="reference internal" href="#forgetting-to-use-reload-to-see-changes-to-your-typeclasses">Forgetting to use @reload to see changes to your typeclasses</a></li>
|
||
<li><a class="reference internal" href="#web-admin-to-create-new-account">Web admin to create new Account</a></li>
|
||
<li><a class="reference internal" href="#mutable-attributes-and-their-connection-to-the-database">Mutable attributes and their connection to the database</a></li>
|
||
<li><a class="reference internal" href="#commands-are-matched-by-name-or-alias">Commands are matched by name <em>or</em> alias</a></li>
|
||
<li><a class="reference internal" href="#objects-turning-to-defaultobject">Objects turning to <code class="docutils literal notranslate"><span class="pre">DefaultObject</span></code></a></li>
|
||
<li><a class="reference internal" href="#overriding-of-magic-methods">Overriding of magic methods</a></li>
|
||
<li><a class="reference internal" href="#known-upstream-bugs">Known upstream bugs</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/Coding/Quirks.md.txt"
|
||
rel="nofollow">Show Page Source</a></li>
|
||
</ul>
|
||
</div><h3>Links</h3>
|
||
<ul>
|
||
<li><a href="https://www.evennia.com">Home page</a> </li>
|
||
<li><a href="https://github.com/evennia/evennia">Evennia Github</a> </li>
|
||
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
||
<li>
|
||
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
||
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
||
<a href="https://evennia.blogspot.com/">Blog</a>
|
||
</li>
|
||
</ul>
|
||
<h3>Versions</h3>
|
||
<ul>
|
||
<li><a href="Quirks.html">1.0-dev (develop branch)</a></li>
|
||
<li><a href="../../0.9.5/index.html">0.9.5 (v0.9.5 branch)</a></li>
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">Quirks</a></li>
|
||
</ul>
|
||
<div class="develop">develop branch</div>
|
||
</div>
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2020, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
|
||
</div>
|
||
</body>
|
||
</html> |