Updated HTML docs

This commit is contained in:
Griatch 2021-10-26 21:41:11 +02:00
parent 66d0ad0bc9
commit 7900aad365
2073 changed files with 32986 additions and 41197 deletions

View file

@ -14,6 +14,8 @@
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"processClass": "tex2jax_process|mathjax_process|math|output_area"}})</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" />
@ -38,22 +40,22 @@
<div class="bodywrapper">
<div class="body" role="main">
<section id="default-exit-errors">
<section class="tex2jax_ignore mathjax_ignore" id="default-exit-errors">
<h1>Default Exit Errors<a class="headerlink" href="#default-exit-errors" title="Permalink to this headline"></a></h1>
<p>Evennia allows for exits to have any name. The command “kitchen” is a valid exit name as well as
“jump out the window” or “north”. An exit actually consists of two parts: an <a class="reference internal" href="../Components/Objects.html"><span class="doc">Exit Object</span></a>
and an <a class="reference internal" href="../Components/Commands.html"><span class="doc">Exit Command</span></a> stored on said exit object. The command has the same key and aliases
“jump out the window” or “north”. An exit actually consists of two parts: an <a class="reference internal" href="../Components/Objects.html"><span class="doc std std-doc">Exit Object</span></a>
and an <a class="reference internal" href="../Components/Commands.html"><span class="doc std std-doc">Exit Command</span></a> stored on said exit object. The command has the same key and aliases
as the object, which is why you can see the exit in the room and just write its name to traverse it.</p>
<p>If you try to enter the name of a non-existing exit, it is thus the same as trying a non-exising
command; Evennia doesnt care about the difference:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="o">&gt;</span> <span class="n">jump</span> <span class="n">out</span> <span class="n">the</span> <span class="n">window</span>
<span class="n">Command</span> <span class="s1">&#39;jump out the window&#39;</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">available</span><span class="o">.</span> <span class="n">Type</span> <span class="s2">&quot;help&quot;</span> <span class="k">for</span> <span class="n">help</span><span class="o">.</span>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> &gt; jump out the window
Command &#39;jump out the window&#39; is not available. Type &quot;help&quot; for help.
</pre></div>
</div>
<p>Many games dont need this type of freedom however. They define only the cardinal directions as
valid exit names (Evennias <code class="docutils literal notranslate"><span class="pre">&#64;tunnel</span></code> command also offers this functionality). In this case, the
error starts to look less logical:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> &gt; west
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> &gt; west
Command &#39;west&#39; is not available. Maybe you meant &quot;@set&quot; or &quot;@reset&quot;?
</pre></div>
</div>
@ -61,39 +63,12 @@ error starts to look less logical:</p>
error message just told us that we couldnt go there.</p>
<section id="adding-default-error-commands">
<h2>Adding default error commands<a class="headerlink" href="#adding-default-error-commands" title="Permalink to this headline"></a></h2>
<p>To solve this you need to be aware of how to <a class="reference internal" href="Starting/Part1/Adding-Commands.html"><span class="doc">write and add new commands</span></a>.
<p>To solve this you need to be aware of how to <a class="reference internal" href="Starting/Part1/Adding-Commands.html"><span class="doc std std-doc">write and add new commands</span></a>.
What you need to do is to create new commands for all directions you want to support in your game.
In this example all well do is echo an error message, but you could certainly consider more
advanced uses. You add these commands to the default command set. Here is an example of such a set
of commands:</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>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span>
<span class="normal">14</span>
<span class="normal">15</span>
<span class="normal">16</span>
<span class="normal">17</span>
<span class="normal">18</span>
<span class="normal">19</span>
<span class="normal">20</span>
<span class="normal">21</span>
<span class="normal">22</span>
<span class="normal">23</span>
<span class="normal">24</span>
<span class="normal">25</span>
<span class="normal">26</span>
<span class="normal">27</span>
<span class="normal">28</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="c1"># for example in a file mygame/commands/movecommands.py</span>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># for example in a file mygame/commands/movecommands.py</span>
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">default_cmds</span>
@ -122,22 +97,10 @@ of commands:</p>
<span class="n">key</span> <span class="o">=</span> <span class="s2">&quot;west&quot;</span>
<span class="n">aliases</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;w&quot;</span><span class="p">]</span>
</pre></div>
</td></tr></table></div>
</div>
<p>Make sure to add the directional commands (not their parent) to the <code class="docutils literal notranslate"><span class="pre">CharacterCmdSet</span></code> class in
<code class="docutils literal notranslate"><span class="pre">mygame/commands/default_cmdsets.py</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>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="c1"># in mygame/commands/default_cmdsets.py</span>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/commands/default_cmdsets.py</span>
<span class="kn">from</span> <span class="nn">commands</span> <span class="kn">import</span> <span class="n">movecommands</span>
@ -151,30 +114,23 @@ of commands:</p>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">movecommands</span><span class="o">.</span><span class="n">CmdExitErrorSouth</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">movecommands</span><span class="o">.</span><span class="n">CmdExitErrorWest</span><span class="p">())</span>
</pre></div>
</td></tr></table></div>
</div>
<p>After a <code class="docutils literal notranslate"><span class="pre">&#64;reload</span></code> these commands (assuming you dont get any errors - check your log) will be
loaded. What happens henceforth is that if you are in a room with an Exitobject (lets say its
“north”), the proper Exit-command will overload your error command (also named “north”). But if you
enter an direction without having a matching exit for it, you will fallback to your default error
commands:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="o">&gt;</span> <span class="n">east</span>
<span class="n">You</span> <span class="n">cannot</span> <span class="n">move</span> <span class="n">east</span><span class="o">.</span>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> &gt; east
You cannot move east.
</pre></div>
</div>
<p>Further expansions by the exit system (including manipulating the way the Exit command itself is
created) can be done by modifying the <a class="reference internal" href="../Components/Typeclasses.html"><span class="doc">Exit typeclass</span></a> directly.</p>
created) can be done by modifying the <a class="reference internal" href="../Components/Typeclasses.html"><span class="doc std std-doc">Exit typeclass</span></a> directly.</p>
</section>
<section id="additional-comments">
<h2>Additional Comments<a class="headerlink" href="#additional-comments" title="Permalink to this headline"></a></h2>
<p>So why didnt we create a single error command above? Something like this:</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>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span> <span class="k">class</span> <span class="nc">CmdExitError</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">MuxCommand</span><span class="p">):</span>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="k">class</span> <span class="nc">CmdExitError</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">MuxCommand</span><span class="p">):</span>
<span class="s2">&quot;Handles all exit-errors.&quot;</span>
<span class="n">key</span> <span class="o">=</span> <span class="s2">&quot;error_cmd&quot;</span>
<span class="n">aliases</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;north&quot;</span><span class="p">,</span> <span class="s2">&quot;n&quot;</span><span class="p">,</span>
@ -183,10 +139,10 @@ created) can be done by modifying the <a class="reference internal" href="../Com
<span class="s2">&quot;west&quot;</span><span class="p">,</span> <span class="s2">&quot;w&quot;</span><span class="p">]</span>
<span class="c1">#[...]</span>
</pre></div>
</td></tr></table></div>
</div>
<p>The anwer is that this would <em>not</em> work and understanding why is important in order to not be
confused when working with commands and command sets.</p>
<p>The reason it doesnt work is because Evennias <a class="reference internal" href="../Components/Commands.html"><span class="doc">command system</span></a> compares commands <em>both</em>
<p>The reason it doesnt work is because Evennias <a class="reference internal" href="../Components/Commands.html"><span class="doc std std-doc">command system</span></a> compares commands <em>both</em>
by <code class="docutils literal notranslate"><span class="pre">key</span></code> and by <code class="docutils literal notranslate"><span class="pre">aliases</span></code>. If <em>either</em> of those match, the two commands are considered <em>identical</em>
as far as cmdset merging system is concerned.</p>
<p>So the above example would work fine as long as there were no Exits at all in the room. But what
@ -248,7 +204,7 @@ matching “north” exit-command.</p>
<h3>Versions</h3>
<ul>
<li><a href="Default-Exit-Errors.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>
<li><a href="../../0.95/index.html">0.95 (v0.9.5 branch)</a></li>
</ul>
</div>