mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
208 lines
No EOL
11 KiB
HTML
208 lines
No EOL
11 KiB
HTML
<!DOCTYPE html>
|
||
|
||
<html lang="en" data-content_root="../">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
|
||
<title>Zones — Evennia latest documentation</title>
|
||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=d75fae25" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/nature.css?v=279e0f84" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/custom.css?v=e4a91a55" />
|
||
<script src="../_static/documentation_options.js?v=c6e86fd7"></script>
|
||
<script src="../_static/doctools.js?v=9bcbadda"></script>
|
||
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
|
||
<link rel="icon" href="../_static/favicon.ico"/>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="Coding and development help" href="../Coding/Coding-Overview.html" />
|
||
<link rel="prev" title="New Models" href="Models.html" />
|
||
</head><body>
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<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="right" >
|
||
<a href="../Coding/Coding-Overview.html" title="Coding and development help"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="Models.html" title="New Models"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="Concepts-Overview.html" accesskey="U">Core Concepts</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">Zones</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section class="tex2jax_ignore mathjax_ignore" id="zones">
|
||
<h1>Zones<a class="headerlink" href="#zones" title="Link to this heading">¶</a></h1>
|
||
<p>Evennia recommends using <a class="reference internal" href="../Components/Tags.html"><span class="std std-doc">Tags</span></a> to create zones and other groupings.</p>
|
||
<p>Say you create a room named <em>Meadow</em> in your nice big forest MUD. That’s all nice and dandy, but
|
||
what if you, in the other end of that forest want another <em>Meadow</em>? As a game creator, this can
|
||
cause all sorts of confusion. For example, teleporting to <em>Meadow</em> will now give you a warning that
|
||
there are two <em>Meadow</em> s and you have to select which one. It’s no problem to do that, you just
|
||
choose for example to go to <code class="docutils literal notranslate"><span class="pre">2-meadow</span></code>, but unless you examine them you couldn’t be sure which of
|
||
the two sat in the magical part of the forest and which didn’t.</p>
|
||
<p>Another issue is if you want to group rooms in geographic regions. Let’s say the “normal” part of
|
||
the forest should have separate weather patterns from the magical part. Or maybe a magical
|
||
disturbance echoes through all magical-forest rooms. It would then be convenient to be able to
|
||
simply find all rooms that are “magical” so you could send messages to them.</p>
|
||
<section id="zones-in-evennia">
|
||
<h2>Zones in Evennia<a class="headerlink" href="#zones-in-evennia" title="Link to this heading">¶</a></h2>
|
||
<p><em>Zones</em> try to separate rooms by global location. In our example we would separate the forest into two parts - the magical and the non-magical part. Each have a <em>Meadow</em> and rooms belonging to each part should be easy to retrieve.</p>
|
||
<p>Many MUD codebases hardcode zones as part of the engine and database. Evennia does no such
|
||
distinction.</p>
|
||
<p>All objects in Evennia can hold any number of <a class="reference internal" href="../Components/Tags.html"><span class="std std-doc">Tags</span></a>. Tags are short labels that you attach to objects. They make it very easy to retrieve groups of objects. An object can have any number of different tags. So let’s attach the relevant tag to our forest:</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="n">forestobj</span><span class="o">.</span><span class="n">tags</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"magicalforest"</span><span class="p">,</span> <span class="n">category</span><span class="o">=</span><span class="s2">"zone"</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>You could add this manually, or automatically during creation somehow (you’d need to modify your
|
||
<code class="docutils literal notranslate"><span class="pre">dig</span></code> command for this, most likely). You can also use the default <code class="docutils literal notranslate"><span class="pre">tag</span></code> command during building:</p>
|
||
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> tag forestobj = magicalforest : zone
|
||
</pre></div>
|
||
</div>
|
||
<p>Henceforth you can then easily retrieve only objects with a given tag:</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="kn">import</span><span class="w"> </span><span class="nn">evennia</span>
|
||
<span class="n">rooms</span> <span class="o">=</span> <span class="n">evennia</span><span class="o">.</span><span class="n">search_tag</span><span class="p">(</span><span class="s2">"magicalforest"</span><span class="p">,</span> <span class="n">category</span><span class="o">=</span><span class="s2">"zone"</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
</section>
|
||
<section id="using-typeclasses-and-inheritance-for-zoning">
|
||
<h2>Using typeclasses and inheritance for zoning<a class="headerlink" href="#using-typeclasses-and-inheritance-for-zoning" title="Link to this heading">¶</a></h2>
|
||
<p>The tagging or aliasing systems above don’t instill any sort of functional difference between a magical forest room and a normal one - they are just arbitrary ways to mark objects for quick retrieval later. Any functional differences must be expressed using <a class="reference internal" href="../Components/Typeclasses.html"><span class="std std-doc">Typeclasses</span></a>.</p>
|
||
<p>Of course, an alternative way to implement zones themselves is to have all rooms/objects in a zone inherit from a given typeclass parent - and then limit your searches to objects inheriting from that given parent. The effect would be similar but you’d need to expand the search functionality to
|
||
properly search the inheritance tree.</p>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
<div class="clearer"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="Main">
|
||
<div class="sphinxsidebarwrapper">
|
||
<p class="logo"><a href="../index.html">
|
||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo of Evennia"/>
|
||
</a></p>
|
||
<search 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" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</search>
|
||
<script>document.getElementById('searchbox').style.display = "block"</script>
|
||
<h3><a href="../index.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">Zones</a><ul>
|
||
<li><a class="reference internal" href="#zones-in-evennia">Zones in Evennia</a></li>
|
||
<li><a class="reference internal" href="#using-typeclasses-and-inheritance-for-zoning">Using typeclasses and inheritance for zoning</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<div>
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="Models.html"
|
||
title="previous chapter">New Models</a></p>
|
||
</div>
|
||
<div>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="../Coding/Coding-Overview.html"
|
||
title="next chapter">Coding and development help</a></p>
|
||
</div>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/Concepts/Zones.md.txt"
|
||
rel="nofollow">Show Page Source</a></li>
|
||
</ul>
|
||
</div><h3>Links</h3>
|
||
<ul>
|
||
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
|
||
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
|
||
<li><a href="https://github.com/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>Doc Versions</h3>
|
||
<ul>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/latest/index.html">latest (main branch)</a>
|
||
</li>
|
||
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/5.x/index.html">v5.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/4.x/index.html">v4.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/3.x/index.html">v3.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/2.x/index.html">v2.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/1.x/index.html">v1.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/0.x/index.html">v0.9.5 branch (outdated)</a>
|
||
</li>
|
||
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<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="right" >
|
||
<a href="../Coding/Coding-Overview.html" title="Coding and development help"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="Models.html" title="New Models"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="Concepts-Overview.html" >Core Concepts</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">Zones</a></li>
|
||
</ul>
|
||
</div>
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2024, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
|
||
</div>
|
||
</body>
|
||
</html> |