<p><em>Exits</em> are in-game <aclass="reference internal"href="Objects.html"><spanclass="doc std std-doc">Objects</span></a> connecting other objects (usually <aclass="reference internal"href="Rooms.html"><spanclass="doc std std-doc">Rooms</span></a>) together.</p>
<blockquote>
<div><p>Note that Exits are one-way objects, so in order for two Rooms to be linked bi-directionally, there will need to be two exits.</p>
</div></blockquote>
<p>An object named <codeclass="docutils literal notranslate"><spanclass="pre">north</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">in</span></code> might be exits, as well as <codeclass="docutils literal notranslate"><spanclass="pre">door</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">portal</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">jump</span><spanclass="pre">out</span><spanclass="pre">the</span><spanclass="pre">window</span></code>.</p>
<p>An exit has two things that separate them from other objects.</p>
<olclass="simple">
<li><p>Their <codeclass="docutils literal notranslate"><spanclass="pre">.destination</span></code> property is set and points to a valid target location. This fact makes it easy and fast to locate exits in the database.</p></li>
<li><p>Exits define a special <aclass="reference internal"href="Commands.html"><spanclass="doc std std-doc">Transit Command</span></a> on themselves when they are created. This command is named the same as the exit object and will, when called, handle the practicalities of moving the character to the Exits’s <codeclass="docutils literal notranslate"><spanclass="pre">.destination</span></code> - this allows you to just enter the name of the exit on its own to move around, just as you would expect.</p></li>
</ol>
<p>The default exit functionality is all defined on the <aclass="reference internal"href="../api/evennia.objects.objects.html#evennia.objects.objects.DefaultExit"title="evennia.objects.objects.DefaultExit"><spanclass="xref myst py py-class">DefaultExit</span></a> typeclass. You could in principle completely change how exits work in your game by overriding this - it’s not recommended though, unless you really know what you are doing).</p>
<p>Exits are <aclass="reference internal"href="Locks.html"><spanclass="doc std std-doc">locked</span></a> using an <codeclass="docutils literal notranslate"><spanclass="pre">access_type</span></code> called <em>traverse</em> and also make use of a few hook methods for giving feedback if the traversal fails. See <codeclass="docutils literal notranslate"><spanclass="pre">evennia.DefaultExit</span></code> for more info.</p>
<p>Exits are normally overridden on a case-by-case basis, but if you want to change the default exit created by rooms like <codeclass="docutils literal notranslate"><spanclass="pre">dig</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">tunnel</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">open</span></code> you can change it in settings:</p>
<p>In <codeclass="docutils literal notranslate"><spanclass="pre">mygame/typeclasses/exits.py</span></code> there is an empty <codeclass="docutils literal notranslate"><spanclass="pre">Exit</span></code> class for you to modify.</p>
<sectionid="exit-details">
<h2>Exit details<aclass="headerlink"href="#exit-details"title="Permalink to this headline">¶</a></h2>
<p>The process of traversing an exit is as follows:</p>
<olclass="simple">
<li><p>The traversing <codeclass="docutils literal notranslate"><spanclass="pre">obj</span></code> sends a command that matches the Exit-command name on the Exit object. The <aclass="reference internal"href="Commands.html"><spanclass="doc std std-doc">cmdhandler</span></a> detects this and triggers the command defined on the Exit. Traversal always involves the “source” (the current location) and the <codeclass="docutils literal notranslate"><spanclass="pre">destination</span></code> (this is stored on the Exit object).</p></li>
<li><p>The Exit command checks the <codeclass="docutils literal notranslate"><spanclass="pre">traverse</span></code> lock on the Exit object</p></li>
<li><p>The Exit command triggers <codeclass="docutils literal notranslate"><spanclass="pre">at_traverse(obj,</span><spanclass="pre">destination)</span></code> on the Exit object.</p></li>
<li><p>In <codeclass="docutils literal notranslate"><spanclass="pre">at_traverse</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">object.move_to(destination)</span></code> is triggered. This triggers the following hooks, in order:</p>
<olclass="simple">
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">obj.at_pre_move(destination)</span></code> - if this returns False, move is aborted.</p></li>
<li><p>Move is performed by changing <codeclass="docutils literal notranslate"><spanclass="pre">obj.location</span></code> from source location to <codeclass="docutils literal notranslate"><spanclass="pre">destination</span></code>.</p></li>
<li><p>On the Exit object, <codeclass="docutils literal notranslate"><spanclass="pre">at_post_traverse(obj,</span><spanclass="pre">source)</span></code> is triggered.</p></li>
</ol>
<p>If the move fails for whatever reason, the Exit will look for an Attribute <codeclass="docutils literal notranslate"><spanclass="pre">err_traverse</span></code> on itself and display this as an error message. If this is not found, the Exit will instead call <codeclass="docutils literal notranslate"><spanclass="pre">at_failed_traverse(obj)</span></code> on itself.</p>
</section>
<sectionid="creating-exits-in-code">
<h2>Creating Exits in code<aclass="headerlink"href="#creating-exits-in-code"title="Permalink to this headline">¶</a></h2>
<p>For an example of how to create Exits programatically please see <aclass="reference internal"href="../Howtos/Beginner-Tutorial/Part1/Beginner-Tutorial-Creating-Things.html#linking-exits-and-rooms-in-code"><spanclass="std std-doc">this guide</span></a>.</p>