Updated HTML docs

This commit is contained in:
Griatch 2022-01-08 16:38:41 +01:00
parent f7e699eaa2
commit 7a8f150ed9
764 changed files with 60139 additions and 76788 deletions

View file

@ -18,9 +18,7 @@
<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" />
<link rel="next" title="Links" href="../Links.html" />
<link rel="prev" title="Static In Game Map" href="Static-In-Game-Map.html" />
<link rel="search" title="Search" href="../search.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
@ -31,14 +29,7 @@
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="../Links.html" title="Links"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Static-In-Game-Map.html" title="Static In Game Map"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" accesskey="U">Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Building menus</a></li>
</ul>
<div class="develop">develop branch</div>
@ -1281,12 +1272,6 @@ exhaustive but user-friendly.</p>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Static-In-Game-Map.html"
title="previous chapter">Static In Game Map</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="../Links.html"
title="next chapter">Links</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
@ -1323,14 +1308,7 @@ exhaustive but user-friendly.</p>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="../Links.html" title="Links"
>next</a> |</li>
<li class="right" >
<a href="Static-In-Game-Map.html" title="Static In Game Map"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" >Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Building menus</a></li>
</ul>
<div class="develop">develop branch</div>

View file

@ -0,0 +1,343 @@
<!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>AWSstorage system &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">AWSstorage system</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 class="tex2jax_ignore mathjax_ignore" id="awsstorage-system">
<h1>AWSstorage system<a class="headerlink" href="#awsstorage-system" title="Permalink to this headline"></a></h1>
<p>Contrib by The Right Honourable Reverend (trhr), 2020</p>
<p>This plugin migrates the Web-based portion of Evennia, namely images,
javascript, and other items located inside staticfiles into Amazon AWS (S3)
cloud hosting. Great for those serving media with the game.</p>
<p>Files hosted on S3 are “in the cloud,” and while your personal
server may be sufficient for serving multimedia to a minimal number of users,
the perfect use case for this plugin would be:</p>
<ul class="simple">
<li><p>Servers supporting heavy web-based traffic (webclient, etc) …</p></li>
<li><p>With a sizable number of users …</p></li>
<li><p>Where the users are globally distributed …</p></li>
<li><p>Where multimedia files are served to users as a part of gameplay</p></li>
</ul>
<p>Bottom line - if youre sending an image to a player every time they traverse a
map, the bandwidth reduction of using this will be substantial. If not, probably
skip this contrib.</p>
<section id="on-costs">
<h2>On costs<a class="headerlink" href="#on-costs" title="Permalink to this headline"></a></h2>
<p>Note that storing and serving files via S3 is not technically free outside of
Amazons “free tier” offering, which you may or may not be eligible for;
setting up a vanilla evennia server with this contrib currently requires 1.5MB
of storage space on S3, making the current total cost of running this plugin
~$0.0005 per year. If you have substantial media assets and intend to serve
them to many users, caveat emptor on a total cost of ownership - check AWSs
pricing structure.</p>
</section>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="technical-details">
<h1>Technical details<a class="headerlink" href="#technical-details" title="Permalink to this headline"></a></h1>
<p>This is a drop-in replacement that operates deeper than all of Evennias code,
so your existing code does not need to change at all to support it.</p>
<p>For example, when Evennia (or Django), tries to save a file permanently (say, an
image uploaded by a user), the save (or load) communication follows the path:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Evennia -&gt; Django
Django -&gt; Storage backend
Storage backend -&gt; file storage location (e.g. hard drive)
</pre></div>
</div>
<p><a class="reference external" href="https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-STATICFILES_STORAGE">django docs</a></p>
<p>This plugin, when enabled, overrides the default storage backend,
which defaults to saving files at mygame/website/, instead,
sending the files to S3 via the storage backend defined herein.</p>
<p>There is no way (or need) to directly access or use the functions here with
other contributions or custom code. Simply work how you would normally, Django
will handle the rest.</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h1>
<section id="set-up-aws-account">
<h2>Set up AWS account<a class="headerlink" href="#set-up-aws-account" title="Permalink to this headline"></a></h2>
<p>If you dont have an AWS S3 account, you should create one at
<a class="reference external" href="https://aws.amazon.com/">https://aws.amazon.com/</a> - documentation for AWS S3 is available at:
<a class="reference external" href="https://docs.aws.amazon.com/AmazonS3/latest/gsg/GetStartedWithS3.html">https://docs.aws.amazon.com/AmazonS3/latest/gsg/GetStartedWithS3.html</a></p>
<p>Credentials required within the app are AWS IAM Access Key and Secret Keys,
which can be generated/found in the AWS Console.</p>
<p>The following example IAM Control Policy Permissions can be added to
the IAM service inside AWS. Documentation for this can be found here:
<a class="reference external" href="https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html">https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html</a></p>
<p>Note that this is only required if you want to tightly secure the roles
that this plugin has access to.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="s2">&quot;Version&quot;</span><span class="p">:</span> <span class="s2">&quot;2012-10-17&quot;</span><span class="p">,</span>
<span class="s2">&quot;Statement&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="s2">&quot;Sid&quot;</span><span class="p">:</span> <span class="s2">&quot;evennia&quot;</span><span class="p">,</span>
<span class="s2">&quot;Effect&quot;</span><span class="p">:</span> <span class="s2">&quot;Allow&quot;</span><span class="p">,</span>
<span class="s2">&quot;Action&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">&quot;s3:PutObject&quot;</span><span class="p">,</span>
<span class="s2">&quot;s3:GetObjectAcl&quot;</span><span class="p">,</span>
<span class="s2">&quot;s3:GetObject&quot;</span><span class="p">,</span>
<span class="s2">&quot;s3:ListBucket&quot;</span><span class="p">,</span>
<span class="s2">&quot;s3:DeleteObject&quot;</span><span class="p">,</span>
<span class="s2">&quot;s3:PutObjectAcl&quot;</span>
<span class="p">],</span>
<span class="s2">&quot;Resource&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">&quot;arn:aws:s3:::YOUR_BUCKET_NAME/*&quot;</span><span class="p">,</span>
<span class="s2">&quot;arn:aws:s3:::YOUR_BUCKET_NAME&quot;</span>
<span class="p">]</span>
<span class="p">}</span>
<span class="p">],</span>
<span class="p">[</span>
<span class="p">{</span>
<span class="s2">&quot;Sid&quot;</span><span class="p">:</span><span class="s2">&quot;evennia&quot;</span><span class="p">,</span>
<span class="s2">&quot;Effect&quot;</span><span class="p">:</span><span class="s2">&quot;Allow&quot;</span><span class="p">,</span>
<span class="s2">&quot;Action&quot;</span><span class="p">:[</span>
<span class="s2">&quot;s3:CreateBucket&quot;</span><span class="p">,</span>
<span class="p">],</span>
<span class="s2">&quot;Resource&quot;</span><span class="p">:[</span>
<span class="s2">&quot;arn:aws:s3:::*&quot;</span>
<span class="p">]</span>
<span class="p">}</span>
<span class="p">]</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Advanced Users: The second IAM statement, CreateBucket, is only needed
for initial installation. You can remove it later, or you can
create the bucket and set the ACL yourself before you continue.</p>
</section>
<section id="dependencies">
<h2>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline"></a></h2>
<p>This package requires the dependency “boto3 &gt;= 1.4.4”, the official
AWS python package. To install, its easiest to just install Evennias
extra requirements;</p>
<ul class="simple">
<li><p>Activate your <code class="docutils literal notranslate"><span class="pre">virtualenv</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">cd</span></code> to the root of the Evennia repository. There should be an <code class="docutils literal notranslate"><span class="pre">requirements_extra.txt</span></code>
file here.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">-r</span> <span class="pre">requirements_extra.txt</span></code></p></li>
</ul>
</section>
<section id="configure-evennia">
<h2>Configure Evennia<a class="headerlink" href="#configure-evennia" title="Permalink to this headline"></a></h2>
<p>Customize the variables defined below in <code class="docutils literal notranslate"><span class="pre">secret_settings.py</span></code>. No further
configuration is needed. Note the three lines that you need to set to your
actual values.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># START OF SECRET_SETTINGS.PY COPY/PASTE &gt;&gt;&gt;</span>
<span class="n">AWS_ACCESS_KEY_ID</span> <span class="o">=</span> <span class="s1">&#39;THIS_IS_PROVIDED_BY_AMAZON&#39;</span>
<span class="n">AWS_SECRET_ACCESS_KEY</span> <span class="o">=</span> <span class="s1">&#39;THIS_IS_PROVIDED_BY_AMAZON&#39;</span>
<span class="n">AWS_STORAGE_BUCKET_NAME</span> <span class="o">=</span> <span class="s1">&#39;mygame-evennia&#39;</span> <span class="c1"># CHANGE ME! I suggest yourgamename-evennia</span>
<span class="c1"># The settings below need to go in secret_settings,py as well, but will</span>
<span class="c1"># not need customization unless you want to do something particularly fancy.</span>
<span class="n">AWS_S3_REGION_NAME</span> <span class="o">=</span> <span class="s1">&#39;us-east-1&#39;</span> <span class="c1"># N. Virginia</span>
<span class="n">AWS_S3_OBJECT_PARAMETERS</span> <span class="o">=</span> <span class="p">{</span> <span class="s1">&#39;Expires&#39;</span><span class="p">:</span> <span class="s1">&#39;Thu, 31 Dec 2099 20:00:00 GMT&#39;</span><span class="p">,</span>
<span class="s1">&#39;CacheControl&#39;</span><span class="p">:</span> <span class="s1">&#39;max-age=94608000&#39;</span><span class="p">,</span> <span class="p">}</span>
<span class="n">AWS_DEFAULT_ACL</span> <span class="o">=</span> <span class="s1">&#39;public-read&#39;</span>
<span class="n">AWS_S3_CUSTOM_DOMAIN</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1">.s3.amazonaws.com&#39;</span> <span class="o">%</span> <span class="n">settings</span><span class="o">.</span><span class="n">AWS_BUCKET_NAME</span>
<span class="n">AWS_AUTO_CREATE_BUCKET</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">STATICFILES_STORAGE</span> <span class="o">=</span> <span class="s1">&#39;evennia.contrib.base_systems.awsstorage.aws-s3-cdn.S3Boto3Storage&#39;</span>
<span class="c1"># &lt;&lt;&lt; END OF SECRET_SETTINGS.PY COPY/PASTE</span>
</pre></div>
</div>
<p>You may also store these keys as environment variables of the same name.
For advanced configuration, refer to the docs for django-storages.</p>
<p>After copying the above, run <code class="docutils literal notranslate"><span class="pre">evennia</span> <span class="pre">reboot</span></code>.</p>
</section>
<section id="check-that-it-works">
<h2>Check that it works<a class="headerlink" href="#check-that-it-works" title="Permalink to this headline"></a></h2>
<p>Confirm that web assets are being served from S3 by visiting your website, then
checking the source of any image (for instance, the logo). It should read
<code class="docutils literal notranslate"><span class="pre">https://your-bucket-name.s3.amazonaws.com/path/to/file</span></code>. If so, the system
works and you shouldnt need to do anything else.</p>
</section>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="uninstallation">
<h1>Uninstallation<a class="headerlink" href="#uninstallation" title="Permalink to this headline"></a></h1>
<p>If you havent made changes to your static files (uploaded images, etc),
you can simply remove the lines you added to <code class="docutils literal notranslate"><span class="pre">secret_settings.py</span></code>. If you
have made changes and want to uninstall at a later date, you can export
your files from your S3 bucket and put them in /static/ in the evennia
directory.</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="license">
<h1>License<a class="headerlink" href="#license" title="Permalink to this headline"></a></h1>
<p>Draws heavily from code provided by django-storages, for which these contributors
are authors:</p>
<p>Marty Alchin (S3)
David Larlet (S3)
Arne Brodowski (S3)
Sebastian Serrano (S3)
Andrew McClain (MogileFS)
Rafal Jonca (FTP)
Chris McCormick (S3 with Boto)
Ivanov E. (Database)
Ariel Núñez (packaging)
Wim Leers (SymlinkOrCopy + patches)
Michael Elsdörfer (Overwrite + PEP8 compatibility)
Christian Klein (CouchDB)
Rich Leland (Mosso Cloud Files)
Jason Christa (patches)
Adam Nelson (patches)
Erik CW (S3 encryption)
Axel Gembe (Hash path)
Waldemar Kornewald (MongoDB)
Russell Keith-Magee (Apache LibCloud patches)
Jannis Leidel (S3 and GS with Boto)
Andrei Coman (Azure)
Chris Streeter (S3 with Boto)
Josh Schneier (Fork maintainer, Bugfixes, Py3K)
Anthony Monthe (Dropbox)
EunPyo (Andrew) Hong (Azure)
Michael Barrientos (S3 with Boto3)
piglei (patches)
Matt Braymer-Hayes (S3 with Boto3)
Eirik Martiniussen Sylliaas (Google Cloud Storage native support)
Jody McIntyre (Google Cloud Storage native support)
Stanislav Kaledin (Bug fixes in SFTPStorage)
Filip Vavera (Google Cloud MIME types support)
Max Malysh (Dropbox large file support)
Scott White (Google Cloud updates)
Alex Watt (Google Cloud Storage patch)
Jumpei Yoshimura (S3 docs)
Jon Dufresne
Rodrigo Gadea (Dropbox fixes)
Martey Dodoo
Chris Rink
Shaung Cheng (S3 docs)
Andrew Perry (Bug fixes in SFTPStorage)</p>
<p>The repurposed code from django-storages is released under BSD 3-Clause,
same as Evennia, so for detailed licensing, refer to the Evennia license.</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="versioning">
<h1>Versioning<a class="headerlink" href="#versioning" title="Permalink to this headline"></a></h1>
<p>This is confirmed to work for Django 2 and Django 3.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/base_systems/awsstorage/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">AWSstorage system</a><ul>
<li><a class="reference internal" href="#on-costs">On costs</a></li>
</ul>
</li>
<li><a class="reference internal" href="#technical-details">Technical details</a></li>
<li><a class="reference internal" href="#installation">Installation</a><ul>
<li><a class="reference internal" href="#set-up-aws-account">Set up AWS account</a></li>
<li><a class="reference internal" href="#dependencies">Dependencies</a></li>
<li><a class="reference internal" href="#configure-evennia">Configure Evennia</a></li>
<li><a class="reference internal" href="#check-that-it-works">Check that it works</a></li>
</ul>
</li>
<li><a class="reference internal" href="#uninstallation">Uninstallation</a></li>
<li><a class="reference internal" href="#license">License</a></li>
<li><a class="reference internal" href="#versioning">Versioning</a></li>
</ul>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-AWSStorage.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="Contrib-AWSStorage.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">AWSstorage system</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,190 @@
<!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>Input/Output Auditing &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Input/Output Auditing</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 class="tex2jax_ignore mathjax_ignore" id="input-output-auditing">
<h1>Input/Output Auditing<a class="headerlink" href="#input-output-auditing" title="Permalink to this headline"></a></h1>
<p>Contribution by Johnny, 2017</p>
<p>Utility that taps and intercepts all data sent to/from clients and the
server and passes it to a callback of your choosing. This is intended for
quality assurance, post-incident investigations and debugging.</p>
<p>Note that this should be used with care since it can obviously be abused. All
data is recorded in cleartext. Please be ethical, and if you are unwilling to
properly deal with the implications of recording user passwords or private
communications, please do not enable this module.</p>
<p>Some checks have been implemented to protect the privacy of users.</p>
<p>Files included in this module:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>outputs.py - Example callback methods. This module ships with examples of
callbacks that send data as JSON to a file in your game/server/logs
dir or to your native Linux syslog daemon. You can of course write
your own to do other things like post them to Kafka topics.
server.py - Extends the Evennia ServerSession object to pipe data to the
callback upon receipt.
tests.py - Unit tests that check to make sure commands with sensitive
arguments are having their PII scrubbed.
</pre></div>
</div>
<section id="installation-configuration">
<h2>Installation/Configuration:<a class="headerlink" href="#installation-configuration" title="Permalink to this headline"></a></h2>
<p>Deployment is completed by configuring a few settings in server.conf. This line
is required:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>SERVER_SESSION_CLASS = &#39;evennia.contrib.utils.auditing.server.AuditedServerSession&#39;
</pre></div>
</div>
<p>This tells Evennia to use this ServerSession instead of its own. Below are the
other possible options along with the default value that will be used if unset.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span># Where to send logs? Define the path to a module containing your callback
# function. It should take a single dict argument as input
AUDIT_CALLBACK = &#39;evennia.contrib.utils.auditing.outputs.to_file&#39;
# Log user input? Be ethical about this; it will log all private and
# public communications between players and/or admins (default: False).
AUDIT_IN = False
# Log server output? This will result in logging of ALL system
# messages and ALL broadcasts to connected players, so on a busy game any
# broadcast to all users will yield a single event for every connected user!
AUDIT_OUT = False
# The default output is a dict. Do you want to allow key:value pairs with
# null/blank values? If you&#39;re just writing to disk, disabling this saves
# some disk space, but whether you *want* sparse values or not is more of a
# consideration if you&#39;re shipping logs to a NoSQL/schemaless database.
# (default: False)
AUDIT_ALLOW_SPARSE = False
# If you write custom commands that handle sensitive data like passwords,
# you must write a regular expression to remove that before writing to log.
# AUDIT_MASKS is a list of dictionaries that define the names of commands
# and the regexes needed to scrub them.
# The system already has defaults to filter out sensitive login/creation
# commands in the default command set. Your list of AUDIT_MASKS will be appended
# to those defaults.
#
# In the regex, the sensitive data itself must be captured in a named group with a
# label of &#39;secret&#39; (see the Python docs on the `re` module for more info). For
# example: `{&#39;authentication&#39;: r&quot;^@auth\s+(?P&lt;secret&gt;[\w]+)&quot;}`
AUDIT_MASKS = []
</pre></div>
</div>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/utils/auditing/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Input/Output Auditing</a><ul>
<li><a class="reference internal" href="#installation-configuration">Installation/Configuration:</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/Contribs/Contrib-Auditing.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="Contrib-Auditing.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Input/Output Auditing</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,229 @@
<!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>Barter system &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Barter system</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 class="tex2jax_ignore mathjax_ignore" id="barter-system">
<h1>Barter system<a class="headerlink" href="#barter-system" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch, 2012</p>
<p>This implements a full barter system - a way for players to safely
trade items between each other in code rather than simple <code class="docutils literal notranslate"><span class="pre">give/get</span></code>
commands. This increases both safety (at no time will one player have
both goods and payment in-hand) and speed, since agreed goods will
be moved automatically). By just replacing one side with coin objects,
(or a mix of coins and goods), this also works fine for regular money
transactions.</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Just import the CmdsetTrade command into (for example) the default
cmdset. This will make the trade (or barter) command available
in-game.</p>
<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">evennia.contrib.game_systems</span> <span class="kn">import</span> <span class="n">barter</span> <span class="c1"># &lt;---</span>
<span class="c1"># ...</span>
<span class="k">class</span> <span class="nc">CharacterCmdSet</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">CharacterCmdSet</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="k">def</span> <span class="nf">at</span> <span class="n">cmdset_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">barter</span><span class="o">.</span><span class="n">CmdsetTrade</span><span class="p">)</span> <span class="c1"># &lt;---</span>
</pre></div>
</div>
</section>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<p>In this module, a “barter” is generally referred to as a “trade”.</p>
<p>Below is an example of a barter sequence. A and B are the parties.
The <code class="docutils literal notranslate"><span class="pre">A&gt;</span></code> and <code class="docutils literal notranslate"><span class="pre">B&gt;</span></code> are their inputs.</p>
<ol>
<li><p>opening a trade</p>
<p>A&gt; trade B: Hi, I have a nice extra sword. You wanna trade?</p>
<p>B sees:
A says: “Hi, I have a nice extra sword. You wanna trade?”
A wants to trade with you. Enter trade A <emote> to accept.</p>
<p>B&gt; trade A: Hm, I could use a good sword …</p>
<p>A sees:
B says: “Hm, I could use a good sword …
B accepts the trade. Use trade help for aid.</p>
<p>B sees:
You are now trading with A. Use trade help for aid.</p>
</li>
<li><p>negotiating</p>
<p>A&gt; offer sword: This is a nice sword. I would need some rations in trade.</p>
<p>B sees: A says: “This is a nice sword. I would need some rations in trade.”
[A offers Sword of might.]</p>
<p>B&gt; evaluate sword
B sees:
&lt;Swords description and possibly stats&gt;</p>
<p>B&gt; offer ration: This is a prime ration.</p>
<p>A sees:
B says: “This is a prime ration.”
[B offers iron ration]</p>
<p>A&gt; say Hey, this is a nice sword, I need something more for it.</p>
<p>B sees:
A says: “Hey this is a nice sword, I need something more for it.”</p>
<p>B&gt; offer sword,apple: Alright. I will also include a magic apple. Thats my last offer.</p>
<p>A sees:
B says: “Alright, I will also include a magic apple. Thats my last offer.”
[B offers iron ration and magic apple]</p>
<p>A&gt; accept: You are killing me here, but alright.</p>
<p>B sees: A says: “You are killing me here, but alright.”
[A accepts your offer. You must now also accept.]</p>
<p>B&gt; accept: Good, nice making business with you.
You accept the deal. Deal is made and goods changed hands.</p>
<p>A sees: B says: “Good, nice making business with you.”
B accepts the deal. Deal is made and goods changed hands.</p>
</li>
</ol>
<p>At this point the trading system is exited and the negotiated items
are automatically exchanged between the parties. In this example B was
the only one changing their offer, but also A could have changed their
offer until the two parties found something they could agree on. The
emotes are optional but useful for RP-heavy worlds.</p>
</section>
<section id="technical-info">
<h2>Technical info<a class="headerlink" href="#technical-info" title="Permalink to this headline"></a></h2>
<p>The trade is implemented by use of a TradeHandler. This object is a
common place for storing the current status of negotiations. It is
created on the object initiating the trade, and also stored on the
other party once that party agrees to trade. The trade request times
out after a certain time - this is handled by a Script. Once trade
starts, the CmdsetTrade cmdset is initiated on both parties along with
the commands relevant for the trading.</p>
</section>
<section id="ideas-for-npc-bartering">
<h2>Ideas for NPC bartering<a class="headerlink" href="#ideas-for-npc-bartering" title="Permalink to this headline"></a></h2>
<p>This module is primarily intended for trade between two players. But
it can also in principle be used for a player negotiating with an
AI-controlled NPC. If the NPC uses normal commands they can use it
directly but more efficient is to have the NPC object send its
replies directly through the tradehandler to the player. One may want
to add some functionality to the decline command, so players can
decline specific objects in the NPC offer (decline <object>) and allow
the AI to maybe offer something else and make it into a proper
barter. Along with an AI that “needs” things or has some sort of
personality in the trading, this can make bartering with NPCs at least
moderately more interesting than just plain buy.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/game_systems/barter/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Barter system</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#usage">Usage</a></li>
<li><a class="reference internal" href="#technical-info">Technical info</a></li>
<li><a class="reference internal" href="#ideas-for-npc-bartering">Ideas for NPC bartering</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/Contribs/Contrib-Barter.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="Contrib-Barter.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Barter system</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,155 @@
<!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>Batch processor examples &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Batch processor examples</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 class="tex2jax_ignore mathjax_ignore" id="batch-processor-examples">
<h1>Batch processor examples<a class="headerlink" href="#batch-processor-examples" title="Permalink to this headline"></a></h1>
<p>Contibution by Griatch, 2012</p>
<p>Simple examples for the batch-processor. The batch processor is used for generating
in-game content from one or more static files. Files can be stored with version
control and then applied to the game to create content.</p>
<p>There are two batch processor types:</p>
<ul class="simple">
<li><p>Batch-cmd processor: A list of <code class="docutils literal notranslate"><span class="pre">#</span></code>-separated Evennia commands being executed
in sequence, such as <code class="docutils literal notranslate"><span class="pre">create</span></code>, <code class="docutils literal notranslate"><span class="pre">dig</span></code>, <code class="docutils literal notranslate"><span class="pre">north</span></code> etc. When running a script
of this type (filename ending with <code class="docutils literal notranslate"><span class="pre">.ev</span></code>), the caller of the script will be
the one performing the scripts actions.</p></li>
<li><p>Batch-code processor: A full Python script (filename ending with <code class="docutils literal notranslate"><span class="pre">.py</span></code> that
executes Evennia api calls to build, such as <code class="docutils literal notranslate"><span class="pre">evennia.create_object</span></code> or
<code class="docutils literal notranslate"><span class="pre">evennia.search_object</span></code> etc. It can be divided up into comment-separated
chunks so one can execute only parts of the script at a time (in this way its
a little different than a normal Python file).</p></li>
</ul>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<p>To test the two example batch files, you need <code class="docutils literal notranslate"><span class="pre">Developer</span></code> or <code class="docutils literal notranslate"><span class="pre">superuser</span></code>
permissions, be logged into the game and run of</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&gt; batchcommand/interactive tutorials.batchprocessor.example_batch_cmds
&gt; batchcode/interactive tutorials.batchprocessor.example_batch_code
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">/interactive</span></code> drops you in interactive mode so you can follow along what
the scripts do. Skip it to build it all at once.</p>
<p>Both commands produce the same results - they create a red-button object,
a table and a chair. If you run either with the <code class="docutils literal notranslate"><span class="pre">/debug</span></code> switch, the objects will
be deleted afterwards (for quick tests of syntax that you dont want to spam new
objects, for example).</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/tutorials/batchprocessor/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Batch processor examples</a><ul>
<li><a class="reference internal" href="#usage">Usage</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/Contribs/Contrib-Batchprocessor.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="Contrib-Batchprocessor.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Batch processor examples</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,137 @@
<!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>Script example &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Script example</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 class="tex2jax_ignore mathjax_ignore" id="script-example">
<h1>Script example<a class="headerlink" href="#script-example" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch, 2012</p>
<p>Example script for testing. This adds a simple timer that has your
character make small verbal observations at irregular intervals.</p>
<p>To test, use (in game)</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&gt; script me = contrib.tutorials.bodyfunctions.BodyFunctions
</pre></div>
</div>
<section id="notes">
<h2>Notes<a class="headerlink" href="#notes" title="Permalink to this headline"></a></h2>
<p>Use <code class="docutils literal notranslate"><span class="pre">scripts</span> <span class="pre">me</span></code> to see the script running on you. Note that even though
the timer ticks down to 0, you will <em>not</em> see an echo every tick (its
random if an echo is given on a tick or not).</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/tutorials/bodyfunctions/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Script example</a><ul>
<li><a class="reference internal" href="#notes">Notes</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/Contribs/Contrib-Bodyfunctions.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="Contrib-Bodyfunctions.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Script example</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,235 @@
<!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>Building menu &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Building menu</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 class="tex2jax_ignore mathjax_ignore" id="building-menu">
<h1>Building menu<a class="headerlink" href="#building-menu" title="Permalink to this headline"></a></h1>
<p>Contrib by vincent-lg, 2018</p>
<p>Building menus are in-game menus, not unlike <code class="docutils literal notranslate"><span class="pre">EvMenu</span></code> though using a
different approach. Building menus have been specifically designed to edit
information as a builder. Creating a building menu in a command allows
builders quick-editing of a given object, like a room. If you follow the
steps to add the contrib, you will have access to an <code class="docutils literal notranslate"><span class="pre">edit</span></code> command
that will edit any default object, offering to change its key and description.</p>
<section id="install">
<h2>Install<a class="headerlink" href="#install" title="Permalink to this headline"></a></h2>
<ol>
<li><p>Import the <code class="docutils literal notranslate"><span class="pre">GenericBuildingCmd</span></code> class from this contrib in your
<code class="docutils literal notranslate"><span class="pre">mygame/commands/default_cmdset.py</span></code> file:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.base_systems.building_menu</span> <span class="kn">import</span> <span class="n">GenericBuildingCmd</span>
</pre></div>
</div>
</li>
<li><p>Below, add the command in the <code class="docutils literal notranslate"><span class="pre">CharacterCmdSet</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># ... These lines should exist in the file</span>
<span class="k">class</span> <span class="nc">CharacterCmdSet</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">CharacterCmdSet</span><span class="p">):</span>
<span class="n">key</span> <span class="o">=</span> <span class="s2">&quot;DefaultCharacter&quot;</span>
<span class="k">def</span> <span class="nf">at_cmdset_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="nb">super</span><span class="p">(</span><span class="n">CharacterCmdSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">at_cmdset_creation</span><span class="p">()</span>
<span class="c1"># ... add the line below</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">GenericBuildingCmd</span><span class="p">())</span>
</pre></div>
</div>
</li>
</ol>
</section>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">edit</span></code> command will allow you to edit any object. You will need to
specify the object name or ID as an argument. For instance: <code class="docutils literal notranslate"><span class="pre">edit</span> <span class="pre">here</span></code>
will edit the current room. However, building menus can perform much more
than this very simple example, read on for more details.</p>
<p>Building menus can be set to edit about anything. Here is an example of
output you could obtain when editing the room:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">Editing</span> <span class="n">the</span> <span class="n">room</span><span class="p">:</span> <span class="n">Limbo</span><span class="p">(</span><span class="c1">#2)</span>
<span class="p">[</span><span class="n">T</span><span class="p">]</span><span class="n">itle</span><span class="p">:</span> <span class="n">the</span> <span class="n">limbo</span> <span class="n">room</span>
<span class="p">[</span><span class="n">D</span><span class="p">]</span><span class="n">escription</span>
<span class="n">This</span> <span class="ow">is</span> <span class="n">the</span> <span class="n">limbo</span> <span class="n">room</span><span class="o">.</span> <span class="n">You</span> <span class="n">can</span> <span class="n">easily</span> <span class="n">change</span> <span class="n">this</span> <span class="n">default</span> <span class="n">description</span><span class="p">,</span>
<span class="n">either</span> <span class="n">by</span> <span class="n">using</span> <span class="n">the</span> <span class="o">|</span><span class="n">y</span><span class="nd">@desc</span><span class="o">/</span><span class="n">edit</span><span class="o">|</span><span class="n">n</span> <span class="n">command</span><span class="p">,</span> <span class="ow">or</span> <span class="n">simply</span> <span class="n">by</span> <span class="n">entering</span> <span class="n">this</span>
<span class="n">menu</span> <span class="p">(</span><span class="n">enter</span> <span class="o">|</span><span class="n">yd</span><span class="o">|</span><span class="n">n</span><span class="p">)</span><span class="o">.</span>
<span class="p">[</span><span class="n">E</span><span class="p">]</span><span class="n">xits</span><span class="p">:</span>
<span class="n">north</span> <span class="n">to</span> <span class="n">A</span> <span class="n">parking</span><span class="p">(</span><span class="c1">#4)</span>
<span class="p">[</span><span class="n">Q</span><span class="p">]</span><span class="n">uit</span> <span class="n">this</span> <span class="n">menu</span>
</pre></div>
</div>
<p>From there, you can open the title choice by pressing t. You can then
change the room title by simply entering text, and go back to the
main menu entering &#64; (all this is customizable). Press q to quit this menu.</p>
<p>The first thing to do is to create a new module and place a class
inheriting from <code class="docutils literal notranslate"><span class="pre">BuildingMenu</span></code> in it.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.base_systems.building_menu</span> <span class="kn">import</span> <span class="n">BuildingMenu</span>
<span class="k">class</span> <span class="nc">RoomBuildingMenu</span><span class="p">(</span><span class="n">BuildingMenu</span><span class="p">):</span>
<span class="c1"># ...</span>
</pre></div>
</div>
<p>Next, override the <code class="docutils literal notranslate"><span class="pre">init</span></code> method (not <code class="docutils literal notranslate"><span class="pre">__init__</span></code>!). You can add
choices (like the title, description, and exits choices as seen above) by using
the <code class="docutils literal notranslate"><span class="pre">add_choice</span></code> method.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">RoomBuildingMenu</span><span class="p">(</span><span class="n">BuildingMenu</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">init</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">room</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_choice</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">,</span> <span class="s2">&quot;t&quot;</span><span class="p">,</span> <span class="n">attr</span><span class="o">=</span><span class="s2">&quot;key&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>That will create the first choice, the title choice. If one opens your menu
and enter t, she will be in the title choice. She can change the title
(it will write in the rooms <code class="docutils literal notranslate"><span class="pre">key</span></code> attribute) and then go back to the
main menu using <code class="docutils literal notranslate"><span class="pre">&#64;</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">add_choice</span></code> has a lot of arguments and offers a great deal of
flexibility. The most useful ones is probably the usage of callbacks,
as you can set almost any argument in <code class="docutils literal notranslate"><span class="pre">add_choice</span></code> to be a callback, a
function that you have defined above in your module. This function will be
called when the menu element is triggered.</p>
<p>Notice that in order to edit a description, the best method to call isnt
<code class="docutils literal notranslate"><span class="pre">add_choice</span></code>, but <code class="docutils literal notranslate"><span class="pre">add_choice_edit</span></code>. This is a convenient shortcut
which is available to quickly open an <code class="docutils literal notranslate"><span class="pre">EvEditor</span></code> when entering this choice
and going back to the menu when the editor closes.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">RoomBuildingMenu</span><span class="p">(</span><span class="n">BuildingMenu</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">init</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">room</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_choice</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">,</span> <span class="s2">&quot;t&quot;</span><span class="p">,</span> <span class="n">attr</span><span class="o">=</span><span class="s2">&quot;key&quot;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_choice_edit</span><span class="p">(</span><span class="s2">&quot;description&quot;</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;d&quot;</span><span class="p">,</span> <span class="n">attr</span><span class="o">=</span><span class="s2">&quot;db.desc&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>When you wish to create a building menu, you just need to import your
class, create it specifying your intended caller and object to edit,
then call <code class="docutils literal notranslate"><span class="pre">open</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="o">&lt;</span><span class="n">wherever</span><span class="o">&gt;</span> <span class="kn">import</span> <span class="nn">RoomBuildingMenu</span>
<span class="k">class</span> <span class="nc">CmdEdit</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="n">key</span> <span class="o">=</span> <span class="s2">&quot;redit&quot;</span>
<span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">menu</span> <span class="o">=</span> <span class="n">RoomBuildingMenu</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">caller</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">caller</span><span class="o">.</span><span class="n">location</span><span class="p">)</span>
<span class="n">menu</span><span class="o">.</span><span class="n">open</span><span class="p">()</span>
</pre></div>
</div>
<p>This is a very short introduction. For more details, see the <a class="reference external" href="https://github.com/evennia/evennia/wiki/Building-menus">online
tutorial</a> or read the
heavily-documented code of the contrib itself.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/base_systems/building_menu/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Building menu</a><ul>
<li><a class="reference internal" href="#install">Install</a></li>
<li><a class="reference internal" href="#usage">Usage</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/Contribs/Contrib-Building-Menu.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="Contrib-Building-Menu.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Building menu</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,205 @@
<!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>Clothing &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Clothing</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 class="tex2jax_ignore mathjax_ignore" id="clothing">
<h1>Clothing<a class="headerlink" href="#clothing" title="Permalink to this headline"></a></h1>
<p>Contribution by Tim Ashley Jenkins, 2017</p>
<p>Provides a typeclass and commands for wearable clothing. These
look of these clothes are appended to the characters description when worn.</p>
<p>Clothing items, when worn, are added to the characters description
in a list. For example, if wearing the following clothing items:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>a thin and delicate necklace
a pair of regular ol&#39; shoes
one nice hat
a very pretty dress
</pre></div>
</div>
<p>Would result in this added description:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Tim is wearing one nice hat, a thin and delicate necklace,
a very pretty dress and a pair of regular ol&#39; shoes.
</pre></div>
</div>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>To install, import this module and have your default character
inherit from ClothedCharacter in your games <a class="reference external" href="http://characters.py">characters.py</a> file:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>
<span class="kn">from</span> <span class="nn">evennia.contrib.game_systems.clothing</span> <span class="kn">import</span> <span class="n">ClothedCharacter</span>
<span class="k">class</span> <span class="nc">Character</span><span class="p">(</span><span class="n">ClothedCharacter</span><span class="p">):</span>
</pre></div>
</div>
<p>And then add <code class="docutils literal notranslate"><span class="pre">ClothedCharacterCmdSet</span></code> in your character set in
<code class="docutils literal notranslate"><span class="pre">mygame/commands/default_cmdsets.py</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>
<span class="kn">from</span> <span class="nn">evennia.contrib.game_systems.clothing</span> <span class="kn">import</span> <span class="n">ClothedCharacterCmdSet</span> <span class="o">&lt;--</span>
<span class="k">class</span> <span class="nc">CharacterCmdSet</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">CharacterCmdSet</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="n">at_cmdset_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">at_cmdset_creation</span><span class="p">()</span>
<span class="o">...</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">ClothedCharacterCmdSet</span><span class="p">)</span> <span class="c1"># &lt;--</span>
</pre></div>
</div>
<p>From here, you can use the default builder commands to create clothes
with which to test the system:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>create a pretty shirt : evennia.contrib.game_systems.clothing.Clothing
set shirt/clothing_type = &#39;top&#39;
wear shirt
</pre></div>
</div>
<p>A characters description may look like this:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Superuser(#1)
This is User #1.
Superuser is wearing one nice hat, a thin and delicate necklace,
a very pretty dress and a pair of regular ol&#39; shoes.
</pre></div>
</div>
<p>Characters can also specify the style of wear for their clothing - I.E.
to wear a scarf tied into a tight knot around the neck or draped
loosely across the shoulders - to add an easy avenue of customization.
For example, after entering:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>wear scarf draped loosely across the shoulders
</pre></div>
</div>
<p>The garment appears like so in the description:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Superuser(#1)
This is User #1.
Superuser is wearing a fanciful-looking scarf draped loosely
across the shoulders.
</pre></div>
</div>
<p>Items of clothing can be used to cover other items, and many options
are provided to define your own clothing types and their limits and
behaviors. For example, to have undergarments automatically covered
by outerwear, or to put a limit on the number of each type of item
that can be worn. The system as-is is fairly freeform - you
can cover any garment with almost any other, for example - but it
can easily be made more restrictive, and can even be tied into a
system for armor or other equipment.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/game_systems/clothing/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Clothing</a><ul>
<li><a class="reference internal" href="#installation">Installation</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/Contribs/Contrib-Clothing.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="Contrib-Clothing.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Clothing</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,176 @@
<!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>Color markups &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Color markups</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 class="tex2jax_ignore mathjax_ignore" id="color-markups">
<h1>Color markups<a class="headerlink" href="#color-markups" title="Permalink to this headline"></a></h1>
<p>Contrib by Griatch, 2017</p>
<p>Additional color markup styles for Evennia (extending or replacing the default
<code class="docutils literal notranslate"><span class="pre">|r</span></code>, <code class="docutils literal notranslate"><span class="pre">|234</span></code>). Adds support for MUSH-style (<code class="docutils literal notranslate"><span class="pre">%cr</span></code>, <code class="docutils literal notranslate"><span class="pre">%c123</span></code>) and/or legacy-Evennia
(<code class="docutils literal notranslate"><span class="pre">{r</span></code>, <code class="docutils literal notranslate"><span class="pre">{123</span></code>).</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Import the desired style variables from this module into
mygame/server/conf/settings.py and add them to the settings variables below.
Each are specified as a list, and multiple such lists can be added to each
variable to support multiple formats. Note that list order affects which regexes
are applied first. You must restart both Portal and Server for color tags to
update.</p>
<p>Assign to the following settings variables (see below for example):</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>COLOR_ANSI_EXTRA_MAP - a mapping between regexes and ANSI colors
COLOR_XTERM256_EXTRA_FG - regex for defining XTERM256 foreground colors
COLOR_XTERM256_EXTRA_BG - regex for defining XTERM256 background colors
COLOR_XTERM256_EXTRA_GFG - regex for defining XTERM256 grayscale foreground colors
COLOR_XTERM256_EXTRA_GBG - regex for defining XTERM256 grayscale background colors
COLOR_ANSI_BRIGHT_BG_EXTRA_MAP = ANSI does not support bright backgrounds; we fake
this by mapping ANSI markup to matching bright XTERM256 backgrounds
COLOR_NO_DEFAULT - Set True/False. If False (default), extend the default
markup, otherwise replace it completely.
</pre></div>
</div>
</section>
<section id="example">
<h2>Example<a class="headerlink" href="#example" title="Permalink to this headline"></a></h2>
<p>To add the {- “curly-bracket” style, add the following to your settings file,
then reboot both Server and Portal:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.base_systems</span> <span class="kn">import</span> <span class="n">color_markups</span>
<span class="n">COLOR_ANSI_EXTRA_MAP</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">CURLY_COLOR_ANSI_EXTRA_MAP</span>
<span class="n">COLOR_XTERM256_EXTRA_FG</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">CURLY_COLOR_XTERM256_EXTRA_FG</span>
<span class="n">COLOR_XTERM256_EXTRA_BG</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">CURLY_COLOR_XTERM256_EXTRA_BG</span>
<span class="n">COLOR_XTERM256_EXTRA_GFG</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">CURLY_COLOR_XTERM256_EXTRA_GFG</span>
<span class="n">COLOR_XTERM256_EXTRA_GBG</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">CURLY_COLOR_XTERM256_EXTRA_GBG</span>
<span class="n">COLOR_ANSI_BRIGHT_BG_EXTRA_MAP</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">CURLY_COLOR_ANSI_BRIGHT_BG_EXTRA_MAP</span>
</pre></div>
</div>
<p>To add the <code class="docutils literal notranslate"><span class="pre">%c-</span></code> “mux/mush” style, add the following to your settings file, then
reboot both Server and Portal:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.base_systems</span> <span class="kn">import</span> <span class="n">color_markups</span>
<span class="n">COLOR_ANSI_EXTRA_MAP</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">MUX_COLOR_ANSI_EXTRA_MAP</span>
<span class="n">COLOR_XTERM256_EXTRA_FG</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">MUX_COLOR_XTERM256_EXTRA_FG</span>
<span class="n">COLOR_XTERM256_EXTRA_BG</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">MUX_COLOR_XTERM256_EXTRA_BG</span>
<span class="n">COLOR_XTERM256_EXTRA_GFG</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">MUX_COLOR_XTERM256_EXTRA_GFG</span>
<span class="n">COLOR_XTERM256_EXTRA_GBG</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">MUX_COLOR_XTERM256_EXTRA_GBG</span>
<span class="n">COLOR_ANSI_BRIGHT_BGS_EXTRA_MAP</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">CURLY_COLOR_ANSI_BRIGHT_BGS_EXTRA_MAP</span>
</pre></div>
</div>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/base_systems/color_markups/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Color markups</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#example">Example</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/Contribs/Contrib-Color-Markups.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="Contrib-Color-Markups.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Color markups</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,174 @@
<!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>Cooldowns &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Cooldowns</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 class="tex2jax_ignore mathjax_ignore" id="cooldowns">
<h1>Cooldowns<a class="headerlink" href="#cooldowns" title="Permalink to this headline"></a></h1>
<p>Contribution by owllex, 2021</p>
<p>Cooldowns are used modelling rate-limited actions, like how often a
character can perform a given action; until a certain time has passed their
command can not be used again. This contrib provides a simple cooldown
handler that can be attached to any typeclass. A cooldown is a lightweight persistent
asynchronous timer that you can query to see if a certain time has yet passed.</p>
<p>Cooldowns are completely asynchronous and must be queried to know their
state. They do not fire callbacks, so are not a good fit for use cases
where something needs to happen on a specific schedule (use delay or
a TickerHandler for that instead).</p>
<p>See also the evennia documentation for command cooldowns
(<a class="reference external" href="https://github.com/evennia/evennia/wiki/Command-Cooldown">https://github.com/evennia/evennia/wiki/Command-Cooldown</a>) for more information
about the concept.</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>To use, simply add the following property to the typeclass definition of any
object type that you want to support cooldowns. It will expose a new <code class="docutils literal notranslate"><span class="pre">cooldowns</span></code>
property that persists data to the objects attribute storage. You can set this
on your base <code class="docutils literal notranslate"><span class="pre">Object</span></code> typeclass to enable cooldown tracking on every kind of
object, or just put it on your <code class="docutils literal notranslate"><span class="pre">Character</span></code> typeclass.</p>
<p>By default the CooldownHandler will use the <code class="docutils literal notranslate"><span class="pre">cooldowns</span></code> property, but you can
customize this if desired by passing a different value for the <code class="docutils literal notranslate"><span class="pre">db_attribute</span></code>
parameter.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.game_systems.contrib.cooldowns</span> <span class="kn">import</span> <span class="n">Cooldownhandler</span>
<span class="kn">from</span> <span class="nn">evennia.utils.utils</span> <span class="kn">import</span> <span class="n">lazy_property</span>
<span class="nd">@lazy_property</span>
<span class="k">def</span> <span class="nf">cooldowns</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="n">CooldownHandler</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">db_attribute</span><span class="o">=</span><span class="s2">&quot;cooldowns&quot;</span><span class="p">)</span>
</pre></div>
</div>
</section>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="example">
<h1>Example<a class="headerlink" href="#example" title="Permalink to this headline"></a></h1>
<p>Assuming youve installed cooldowns on your Character typeclasses, you can use a
cooldown to limit how often you can perform a command. The following code
snippet will limit the use of a Power Attack command to once every 10 seconds
per character.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">PowerAttack</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">caller</span><span class="o">.</span><span class="n">cooldowns</span><span class="o">.</span><span class="n">ready</span><span class="p">(</span><span class="s2">&quot;power attack&quot;</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">do_power_attack</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">caller</span><span class="o">.</span><span class="n">cooldowns</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">&quot;power attack&quot;</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">caller</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;That&#39;s not ready yet!&quot;</span><span class="p">)</span>
</pre></div>
</div>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/game_systems/cooldowns/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Cooldowns</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
</ul>
</li>
<li><a class="reference internal" href="#example">Example</a></li>
</ul>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Cooldowns.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="Contrib-Cooldowns.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Cooldowns</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -6,7 +6,7 @@
<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>Crafting system contrib &#8212; Evennia 1.0-dev documentation</title>
<title>Crafting system &#8212; 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>
@ -18,9 +18,7 @@
<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" />
<link rel="next" title="evennia.contrib.crafting.crafting" href="../api/evennia.contrib.crafting.crafting.html" />
<link rel="prev" title="Contrib modules" href="Contrib-Overview.html" />
<link rel="search" title="Search" href="../search.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
@ -31,15 +29,8 @@
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="../api/evennia.contrib.crafting.crafting.html" title="evennia.contrib.crafting.crafting"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Overview.html" title="Contrib modules"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" accesskey="U">Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Crafting system contrib</a></li>
<li class="nav-item nav-item-this"><a href="">Crafting system</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
@ -49,59 +40,130 @@
<div class="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="crafting-system-contrib">
<h1>Crafting system contrib<a class="headerlink" href="#crafting-system-contrib" title="Permalink to this headline"></a></h1>
<p><em>Contrib by Griatch 2020</em></p>
<div class="versionadded">
<p><span class="versionmodified added">New in version 1.0.</span></p>
</div>
<p>This contrib implements a full Crafting system that can be expanded and modified to fit your game.</p>
<ul class="simple">
<li><p>See the <a class="reference internal" href="../api/evennia.contrib.crafting.crafting.html#evennia-contrib-crafting-crafting"><span class="std std-ref">evennia/contrib/crafting/crafting.py API</span></a> for installation
instructrions.</p></li>
<li><p>See the <a class="reference internal" href="../api/evennia.contrib.crafting.example_recipes.html#evennia-contrib-crafting-example-recipes"><span class="std std-ref">sword example</span></a> for an example of how to design
a crafting tree for crafting a sword from base elements.</p></li>
</ul>
<p>From in-game it uses the new <code class="docutils literal notranslate"><span class="pre">craft</span></code> command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>&gt; craft bread from flour, eggs, salt, water, yeast using oven, roller
&gt; craft bandage from cloth using scissors
<section class="tex2jax_ignore mathjax_ignore" id="crafting-system">
<h1>Crafting system<a class="headerlink" href="#crafting-system" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch 2020</p>
<p>This implements a full crafting system. The principle is that of a recipe,
where you combine items (tagged as ingredients) create something new. The recipe can also
require certain (non-consumed) tools. An example would be to use the bread recipe to
combine flour, water and yeast with an oven to bake a loaf of bread.</p>
<p>The recipe process can be understood like this:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>ingredient(s) + tool(s) + recipe -&gt; object(s)
</pre></div>
</div>
<p>The syntax is <code class="docutils literal notranslate"><span class="pre">craft</span> <span class="pre">&lt;recipe&gt;</span> <span class="pre">[from</span> <span class="pre">&lt;ingredient&gt;,...][</span> <span class="pre">using</span> <span class="pre">&lt;tool&gt;,...]</span></code>.</p>
<p>The above example uses the <code class="docutils literal notranslate"><span class="pre">bread</span></code> <em>recipe</em> and requires <code class="docutils literal notranslate"><span class="pre">flour</span></code>, <code class="docutils literal notranslate"><span class="pre">eggs</span></code>, <code class="docutils literal notranslate"><span class="pre">salt</span></code>, <code class="docutils literal notranslate"><span class="pre">water</span></code> and <code class="docutils literal notranslate"><span class="pre">yeast</span></code> objects
to be in your inventory. These will be consumed as part of crafting (baking) the bread.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">oven</span></code> and <code class="docutils literal notranslate"><span class="pre">roller</span></code> are “tools” that can be either in your inventory or in your current location (you are not carrying an oven
around with you after all). Tools are <em>not</em> consumed in the crafting. If the added ingredients/tools matches
the requirements of the recipe, a new <code class="docutils literal notranslate"><span class="pre">bread</span></code> object will appear in the crafters inventory.</p>
<p>If you wanted, you could also picture recipes without any consumables:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span> <span class="n">craft</span> <span class="n">fireball</span> <span class="n">using</span> <span class="n">wand</span><span class="p">,</span> <span class="n">spellbook</span>
<p>Here, ingredients are consumed by the crafting process, whereas tools are
necessary for the process but will not be destroyed by it.</p>
<p>The included <code class="docutils literal notranslate"><span class="pre">craft</span></code> command works like this:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>craft &lt;recipe&gt; [from &lt;ingredient&gt;,...] [using &lt;tool&gt;, ...]
</pre></div>
</div>
<p>With a little creativity, the recipe concept could be adopted to all sorts of things, like puzzles or
magic systems.</p>
<p>In code, you can craft using the <code class="docutils literal notranslate"><span class="pre">evennia.contrib.crafting.crafting.craft</span></code> function:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.crafting.crafting</span> <span class="kn">import</span> <span class="n">craft</span>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h2>
<p>Using the <code class="docutils literal notranslate"><span class="pre">craft</span></code> command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>craft toy car from plank, wooden wheels, nails using saw, hammer
</pre></div>
</div>
<p>A recipe does not have to use tools or even multiple ingredients:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>snow + snowball_recipe -&gt; snowball
</pre></div>
</div>
<p>Conversely one could also imagine using tools without consumables, like</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>spell_book + wand + fireball_recipe -&gt; fireball
</pre></div>
</div>
<p>The system is generic enough to be used also for adventure-like puzzles (but
one would need to change the command and determine the recipe on based on what
is being combined instead):</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>stick + string + hook -&gt; makeshift_fishing_rod
makeshift_fishing_rod + storm_drain -&gt; key
</pre></div>
</div>
<p>See the <a class="reference internal" href="../api/evennia.contrib.game_systems.crafting.example_recipes.html#evennia-contrib-game-systems-crafting-example-recipes"><span class="std std-ref">sword example</span></a> for an example
of how to design a recipe tree for crafting a sword from base elements.</p>
</section>
<section id="intallation-and-usage">
<h2>Intallation and Usage<a class="headerlink" href="#intallation-and-usage" title="Permalink to this headline"></a></h2>
<p>Import the <code class="docutils literal notranslate"><span class="pre">CmdCraft</span></code> command from evennia/contrib/crafting/crafting.py and
add it to your Character cmdset. Reload and the <code class="docutils literal notranslate"><span class="pre">craft</span></code> command will be
available to you:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>craft &lt;recipe&gt; [from &lt;ingredient&gt;,...] [using &lt;tool&gt;, ...]
</pre></div>
</div>
<p>In code, you can craft using the
<code class="docutils literal notranslate"><span class="pre">evennia.contrib.game_systems.crafting.craft</span></code> function:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.game_systems.crafting</span> <span class="kn">import</span> <span class="n">craft</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">craft</span><span class="p">(</span><span class="n">caller</span><span class="p">,</span> <span class="s2">&quot;recipename&quot;</span><span class="p">,</span> <span class="o">*</span><span class="n">inputs</span><span class="p">)</span>
</pre></div>
</div>
<p>Here, <code class="docutils literal notranslate"><span class="pre">caller</span></code> is the one doing the crafting and <code class="docutils literal notranslate"><span class="pre">*inputs</span></code> is any combination of consumables and/or tool
Objects. The system will identify which is which by the <a class="reference internal" href="../Components/Tags.html"><span class="doc std std-doc">Tags</span></a> on them (see below)
The <code class="docutils literal notranslate"><span class="pre">result</span></code> is always a list.</p>
<p>Here, <code class="docutils literal notranslate"><span class="pre">caller</span></code> is the one doing the crafting and <code class="docutils literal notranslate"><span class="pre">*inputs</span></code> is any combination of
consumables and/or tool Objects. The system will identify which is which by the
<a class="reference internal" href="../Components/Tags.html"><span class="doc std std-doc">Tags</span></a> on them (see below) The <code class="docutils literal notranslate"><span class="pre">result</span></code> is always a list.</p>
<p>To use crafting you need recipes. Add a new variable to
<code class="docutils literal notranslate"><span class="pre">mygame/server/conf/settings.py</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>CRAFT_RECIPE_MODULES = [&#39;world.recipes&#39;]
</pre></div>
</div>
<p>All top-level classes in these modules (whose name does not start with <code class="docutils literal notranslate"><span class="pre">_</span></code>) will
be parsed by Evennia as recipes to make available to the crafting system. Using
the above example, create <code class="docutils literal notranslate"><span class="pre">mygame/world/recipes.py</span></code> and add your recipies in
there:</p>
<p>A quick example (read on for more details):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>
<span class="kn">from</span> <span class="nn">evennia.contrib.game_systems.crafting</span> <span class="kn">import</span> <span class="n">CraftingRecipe</span><span class="p">,</span> <span class="n">CraftingValidationError</span>
<span class="k">class</span> <span class="nc">RecipeBread</span><span class="p">(</span><span class="n">CraftingRecipe</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Bread is good for making sandwitches!</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">name</span> <span class="o">=</span> <span class="s2">&quot;bread&quot;</span> <span class="c1"># used to identify this recipe in &#39;craft&#39; command</span>
<span class="n">tool_tags</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;bowl&quot;</span><span class="p">,</span> <span class="s2">&quot;oven&quot;</span><span class="p">]</span>
<span class="n">consumable_tags</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;flour&quot;</span><span class="p">,</span> <span class="s2">&quot;salt&quot;</span><span class="p">,</span> <span class="s2">&quot;yeast&quot;</span><span class="p">,</span> <span class="s2">&quot;water&quot;</span><span class="p">]</span>
<span class="n">output_prototypes</span> <span class="o">=</span> <span class="p">[</span>
<span class="p">{</span><span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="s2">&quot;Loaf of Bread&quot;</span><span class="p">,</span>
<span class="s2">&quot;aliases&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s2">&quot;bread&quot;</span><span class="p">],</span>
<span class="s2">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;A nice load of bread.&quot;</span><span class="p">,</span>
<span class="s2">&quot;typeclass&quot;</span><span class="p">:</span> <span class="s2">&quot;typeclasses.objects.Food&quot;</span><span class="p">,</span> <span class="c1"># assuming this exists</span>
<span class="s2">&quot;tags&quot;</span><span class="p">:</span> <span class="p">[(</span><span class="s2">&quot;bread&quot;</span><span class="p">,</span> <span class="s2">&quot;crafting_material&quot;</span><span class="p">)]</span> <span class="c1"># this makes it usable in other recipes ...</span>
<span class="p">}</span>
<span class="p">]</span>
<span class="k">def</span> <span class="nf">pre_craft</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="c1"># validates inputs etc. Raise `CraftingValidationError` if fails</span>
<span class="k">def</span> <span class="nf">do_craft</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="c1"># performs the craft - report errors directly to user and return None (if</span>
<span class="c1"># failed) and the created object(s) if successful.</span>
<span class="k">def</span> <span class="nf">post_craft</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="c1"># any post-crafting effects. Always called, even if do_craft failed (the</span>
<span class="c1"># result would be None then)</span>
</pre></div>
</div>
</section>
<section id="adding-new-recipes">
<h2>Adding new recipes<a class="headerlink" href="#adding-new-recipes" title="Permalink to this headline"></a></h2>
<p>A <em>recipe</em> is a class inheriting from <code class="docutils literal notranslate"><span class="pre">evennia.contrib.crafting.crafting.CraftingRecipe</span></code>. This class
implements the most common form of crafting - that using in-game objects. Each recipe is a separate class
which gets initialized with the consumables/tools you provide.</p>
<p>For the <code class="docutils literal notranslate"><span class="pre">craft</span></code> command to find your custom recipes, you need to tell Evennia where they are. Add a new
line to your <code class="docutils literal notranslate"><span class="pre">mygame/server/conf/settings.py</span></code> file, with a list to any new modules with recipe classes.</p>
<p>A <em>recipe</em> is a class inheriting from
<code class="docutils literal notranslate"><span class="pre">evennia.contrib.crafting.crafting.CraftingRecipe</span></code>. This class implements the
most common form of crafting - that using in-game objects. Each recipe is a
separate class which gets initialized with the consumables/tools you provide.</p>
<p>For the <code class="docutils literal notranslate"><span class="pre">craft</span></code> command to find your custom recipes, you need to tell Evennia
where they are. Add a new line to your <code class="docutils literal notranslate"><span class="pre">mygame/server/conf/settings.py</span></code> file,
with a list to any new modules with recipe classes.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">CRAFT_RECIPE_MODULES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;world.myrecipes&quot;</span><span class="p">]</span>
</pre></div>
</div>
<p>(You need to reload after adding this). All global-level classes in these modules (whose names dont start
with underscore) are considered by the system as viable recipes.</p>
<p>Here we assume you created <code class="docutils literal notranslate"><span class="pre">mygame/world/myrecipes.py</span></code> to match the above example setting:</p>
<p>(You need to reload after adding this). All global-level classes in these
modules (whose names dont start with underscore) are considered by the system
as viable recipes.</p>
<p>Here we assume you created <code class="docutils literal notranslate"><span class="pre">mygame/world/myrecipes.py</span></code> to match the above
example setting:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/world/myrecipes.py</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.crafting.crafting</span> <span class="kn">import</span> <span class="n">CraftingRecipe</span>
@ -119,33 +181,38 @@ with underscore) are considered by the system as viable recipes.</p>
</pre></div>
</div>
<p>This specifies which tags to look for in the inputs. It defines a <a class="reference internal" href="../Components/Prototypes.html"><span class="doc std std-doc">Prototype</span></a>
for the recipe to use to spawn the result on the fly (a recipe could spawn more than one result if needed).
Instead of specifying the full prototype-dict, you could also just provide a list of <code class="docutils literal notranslate"><span class="pre">prototype_key</span></code>s to
existing prototypes you have.</p>
<p>After reloading the server, this recipe would now be available to use. To try it we should
create materials and tools to insert into the recipe.</p>
<p>The recipe analyzes inputs, looking for <a class="reference internal" href="../Components/Tags.html"><span class="doc std std-doc">Tags</span></a> with specific tag-categories.
The tag-category used can be set per-recipe using the (<code class="docutils literal notranslate"><span class="pre">.consumable_tag_category</span></code> and
<code class="docutils literal notranslate"><span class="pre">.tool_tag_category</span></code> respectively). The defaults are <code class="docutils literal notranslate"><span class="pre">crafting_material</span></code> and <code class="docutils literal notranslate"><span class="pre">crafting_tool</span></code>. For
the puppet we need one object with the <code class="docutils literal notranslate"><span class="pre">wood</span></code> tag and another with the <code class="docutils literal notranslate"><span class="pre">knife</span></code> tag:</p>
<p>This specifies which tags to look for in the inputs. It defines a
<a class="reference internal" href="../Components/Prototypes.html"><span class="doc std std-doc">Prototype</span></a> for the recipe to use to spawn the
result on the fly (a recipe could spawn more than one result if needed).
Instead of specifying the full prototype-dict, you could also just provide a
list of <code class="docutils literal notranslate"><span class="pre">prototype_key</span></code>s to existing prototypes you have.</p>
<p>After reloading the server, this recipe would now be available to use. To try it
we should create materials and tools to insert into the recipe.</p>
<p>The recipe analyzes inputs, looking for <a class="reference internal" href="../Components/Tags.html"><span class="doc std std-doc">Tags</span></a> with
specific tag-categories. The tag-category used can be set per-recipe using the
(<code class="docutils literal notranslate"><span class="pre">.consumable_tag_category</span></code> and <code class="docutils literal notranslate"><span class="pre">.tool_tag_category</span></code> respectively). The defaults
are <code class="docutils literal notranslate"><span class="pre">crafting_material</span></code> and <code class="docutils literal notranslate"><span class="pre">crafting_tool</span></code>. For
the puppet we need one object with the <code class="docutils literal notranslate"><span class="pre">wood</span></code> tag and another with the <code class="docutils literal notranslate"><span class="pre">knife</span></code>
tag:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">create_object</span>
<span class="n">knife</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">key</span><span class="o">=</span><span class="s2">&quot;Hobby knife&quot;</span><span class="p">,</span> <span class="n">tags</span><span class="o">=</span><span class="p">[(</span><span class="s2">&quot;knife&quot;</span><span class="p">,</span> <span class="s2">&quot;crafting_tool&quot;</span><span class="p">)])</span>
<span class="n">wood</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">key</span><span class="o">=</span><span class="s2">&quot;Piece of wood&quot;</span><span class="p">,</span> <span class="n">tags</span><span class="p">[(</span><span class="s2">&quot;wood&quot;</span><span class="p">,</span> <span class="s2">&quot;crafting_material&quot;</span><span class="p">)])</span>
</pre></div>
</div>
<p>Note that the objects can have any name, all that matters is the tag/tag-category. This means if a
“bayonet” also had the “knife” crafting tag, it could also be used to carve a puppet. This is also
potentially interesting for use in puzzles and to allow users to experiment and find alternatives to
<p>Note that the objects can have any name, all that matters is the
tag/tag-category. This means if a “bayonet” also had the “knife” crafting tag,
it could also be used to carve a puppet. This is also potentially interesting
for use in puzzles and to allow users to experiment and find alternatives to
know ingredients.</p>
<p>By the way, there is also a simple shortcut for doing this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">tools</span><span class="p">,</span> <span class="n">consumables</span> <span class="o">=</span> <span class="n">WoodenPuppetRecipe</span><span class="o">.</span><span class="n">seed</span><span class="p">()</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">seed</span></code> class-method will create simple dummy objects that fulfills the recipes requirements. This
is great for testing.</p>
<p>Assuming these objects were put in our inventory, we could now craft using the in-game command:</p>
<p>The <code class="docutils literal notranslate"><span class="pre">seed</span></code> class-method will create simple dummy objects that fulfills the
recipes requirements. This is great for testing.</p>
<p>Assuming these objects were put in our inventory, we could now craft using the
in-game command:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>&gt; craft wooden puppet from wood using hobby knife
</pre></div>
</div>
@ -155,12 +222,13 @@ is great for testing.</p>
</pre></div>
</div>
<p>In the call to <code class="docutils literal notranslate"><span class="pre">craft</span></code>, the order of <code class="docutils literal notranslate"><span class="pre">knife</span></code> and <code class="docutils literal notranslate"><span class="pre">wood</span></code> doesnt matter - the recipe will sort out which
is which based on their tags.</p>
<p>In the call to <code class="docutils literal notranslate"><span class="pre">craft</span></code>, the order of <code class="docutils literal notranslate"><span class="pre">knife</span></code> and <code class="docutils literal notranslate"><span class="pre">wood</span></code> doesnt matter - the
recipe will sort out which is which based on their tags.</p>
</section>
<section id="deeper-customization-of-recipes">
<h2>Deeper customization of recipes<a class="headerlink" href="#deeper-customization-of-recipes" title="Permalink to this headline"></a></h2>
<p>For customizing recipes further, it helps to understand how to use the recipe-class directly:</p>
<p>For customizing recipes further, it helps to understand how to use the
recipe-class directly:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyRecipe</span><span class="p">(</span><span class="n">CraftingRecipe</span><span class="p">):</span>
<span class="c1"># ...</span>
@ -170,13 +238,15 @@ is which based on their tags.</p>
</pre></div>
</div>
<p>This is useful for testing and allows you to use the class directly without adding it to a module
in <code class="docutils literal notranslate"><span class="pre">settings.CRAFTING_RECIPE_MODULES</span></code>.</p>
<p>Even without modifying more than the class properties, there are a lot of options to set on
the <code class="docutils literal notranslate"><span class="pre">CraftingRecipe</span></code> class. Easiest is to refer to the
<a class="reference internal" href="../api/evennia.contrib.crafting.crafting.html#evennia.contrib.crafting.crafting.CraftingRecipe" title="evennia.contrib.crafting.crafting.CraftingRecipe"><span class="xref myst py py-class">CraftingRecipe api documentation</span></a>.
For example, you can customize the validation-error messages, decide if the ingredients have
to be exactly right, if a failure still consumes the ingredients or not, and much more.</p>
<p>This is useful for testing and allows you to use the class directly without
adding it to a module in <code class="docutils literal notranslate"><span class="pre">settings.CRAFTING_RECIPE_MODULES</span></code>.</p>
<p>Even without modifying more than the class properties, there are a lot of
options to set on the <code class="docutils literal notranslate"><span class="pre">CraftingRecipe</span></code> class. Easiest is to refer to the
<a class="reference internal" href="../api/evennia.contrib.game_systems.crafting.crafting.html#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe" title="evennia.contrib.game_systems.crafting.crafting.CraftingRecipe"><span class="xref myst py py-class">CraftingRecipe api
documentation</span></a>. For example,
you can customize the validation-error messages, decide if the ingredients have
to be exactly right, if a failure still consumes the ingredients or not, and
much more.</p>
<p>For even more control you can override hooks in your own class:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">pre_craft</span></code> - this should handle input validation and store its data in <code class="docutils literal notranslate"><span class="pre">.validated_consumables</span></code> and
@ -195,9 +265,10 @@ crafter. Centralizing this means you can also easily modify the sending style in
into each crafting hook. These are unused by default but could be used to customize things per-call.</p>
<section id="skilled-crafters">
<h3>Skilled crafters<a class="headerlink" href="#skilled-crafters" title="Permalink to this headline"></a></h3>
<p>What the crafting system does not have out of the box is a skill system - the notion of being able
to fail the craft if you are not skilled enough. Just how skills work is game-dependent, so to add
this you need to make your own recipe parent class and have your recipes inherit from this.</p>
<p>What the crafting system does not have out of the box is a skill system - the
notion of being able to fail the craft if you are not skilled enough. Just how
skills work is game-dependent, so to add this you need to make your own recipe
parent class and have your recipes inherit from this.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">random</span> <span class="kn">import</span> <span class="n">randint</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.crafting.crafting</span> <span class="kn">import</span> <span class="n">CraftingRecipe</span>
@ -228,7 +299,7 @@ this you need to make your own recipe parent class and have your recipes inherit
if we succed. We would of course make this a lot more immersive and detailed in a full game. In
principle you could customize each recipe just the way you want it, but you could also inherit from
a central parent like this to cut down on work.</p>
<p>The <a class="reference internal" href="../api/evennia.contrib.crafting.example_recipes.html#evennia-contrib-crafting-example-recipes"><span class="std std-ref">sword recipe example module</span></a> also shows an example
<p>The <a class="reference internal" href="../api/evennia.contrib.game_systems.crafting.example_recipes.html#evennia-contrib-game-systems-crafting-example-recipes"><span class="std std-ref">sword recipe example module</span></a> also shows an example
of a random skill-check being implemented in a parent and then inherited for multiple use.</p>
</section>
</section>
@ -238,6 +309,9 @@ of a random skill-check being implemented in a parent and then inherited for mul
you could also look at the <code class="docutils literal notranslate"><span class="pre">CraftingRecipe</span></code> parent class <code class="docutils literal notranslate"><span class="pre">CraftingRecipeBase</span></code>.
It implements just the minimum needed to be a recipe and for big changes you may be better off starting
from this rather than the more opinionated <code class="docutils literal notranslate"><span class="pre">CraftingRecipe</span></code>.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/game_systems/crafting/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</section>
</section>
@ -263,7 +337,9 @@ from this rather than the more opinionated <code class="docutils literal notrans
<script>$('#searchbox').show(0);</script>
<p><h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Crafting system contrib</a><ul>
<li><a class="reference internal" href="#">Crafting system</a><ul>
<li><a class="reference internal" href="#examples">Examples</a></li>
<li><a class="reference internal" href="#intallation-and-usage">Intallation and Usage</a></li>
<li><a class="reference internal" href="#adding-new-recipes">Adding new recipes</a></li>
<li><a class="reference internal" href="#deeper-customization-of-recipes">Deeper customization of recipes</a><ul>
<li><a class="reference internal" href="#skilled-crafters">Skilled crafters</a></li>
@ -274,16 +350,10 @@ from this rather than the more opinionated <code class="docutils literal notrans
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Overview.html"
title="previous chapter">Contrib modules</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="../api/evennia.contrib.crafting.crafting.html"
title="next chapter">evennia.contrib.crafting.crafting</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Crafting.md.txt"
<li><a href="../_sources/Contribs/Contrib-Crafting.md.txt"
rel="nofollow">Show Page Source</a></li>
</ul>
</div><h3>Links</h3>
@ -299,7 +369,7 @@ from this rather than the more opinionated <code class="docutils literal notrans
</ul>
<h3>Versions</h3>
<ul>
<li><a href="Crafting.html">1.0-dev (develop branch)</a></li>
<li><a href="Contrib-Crafting.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>
@ -316,15 +386,8 @@ from this rather than the more opinionated <code class="docutils literal notrans
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="../api/evennia.contrib.crafting.crafting.html" title="evennia.contrib.crafting.crafting"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Overview.html" title="Contrib modules"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" >Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Crafting system contrib</a></li>
<li class="nav-item nav-item-this"><a href="">Crafting system</a></li>
</ul>
<div class="develop">develop branch</div>
</div>

View file

@ -0,0 +1,167 @@
<!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>Custom gameime &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Custom gameime</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 class="tex2jax_ignore mathjax_ignore" id="custom-gameime">
<h1>Custom gameime<a class="headerlink" href="#custom-gameime" title="Permalink to this headline"></a></h1>
<p>Contrib by vlgeoff, 2017 - based on Griatchs core original</p>
<p>This reimplements the <code class="docutils literal notranslate"><span class="pre">evennia.utils.gametime</span></code> module but with a <em>custom</em>
calendar (unusual number of days per week/month/year etc) for your game world.
Like the original, it allows for scheduling events to happen at given
in-game times, but now taking this custom calendar into account.</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Import and use this in the same way as you would the normal
<code class="docutils literal notranslate"><span class="pre">evennia.utils.gametime</span></code> module.</p>
<p>Customize the calendar by adding a <code class="docutils literal notranslate"><span class="pre">TIME_UNITS</span></code> dict to your settings (see
example below).</p>
</section>
<section id="usage">
<h2>Usage:<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="kn">from</span> <span class="nn">evennia.contrib.base_systems</span> <span class="kn">import</span> <span class="n">custom_gametime</span>
<span class="n">gametime</span> <span class="o">=</span> <span class="n">custom_gametime</span><span class="o">.</span><span class="n">realtime_to_gametime</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">23</span><span class="p">)</span>
<span class="c1"># scedule an event to fire every in-game 10 hours</span>
<span class="n">custom_gametime</span><span class="o">.</span><span class="n">schedule</span><span class="p">(</span><span class="n">callback</span><span class="p">,</span> <span class="n">repeat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">hour</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
</pre></div>
</div>
<p>The calendar can be customized by adding the <code class="docutils literal notranslate"><span class="pre">TIME_UNITS</span></code> dictionary to your
settings file. This maps unit names to their length, expressed in the smallest
unit. Heres the default as an example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>TIME_UNITS = {
&quot;sec&quot;: 1,
&quot;min&quot;: 60,
&quot;hr&quot;: 60 * 60,
&quot;hour&quot;: 60 * 60,
&quot;day&quot;: 60 * 60 * 24,
&quot;week&quot;: 60 * 60 * 24 * 7,
&quot;month&quot;: 60 * 60 * 24 * 7 * 4,
&quot;yr&quot;: 60 * 60 * 24 * 7 * 4 * 12,
&quot;year&quot;: 60 * 60 * 24 * 7 * 4 * 12, }
</pre></div>
</div>
<p>When using a custom calendar, these time unit names are used as kwargs to
the converter functions in this module. Even if your calendar uses other names
for months/weeks etc the system needs the default names internally.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/base_systems/custom_gametime/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Custom gameime</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#usage">Usage:</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/Contribs/Contrib-Custom-Gametime.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="Contrib-Custom-Gametime.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Custom gameime</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,184 @@
<!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>Dice &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Dice</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 class="tex2jax_ignore mathjax_ignore" id="dice">
<h1>Dice<a class="headerlink" href="#dice" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch, 2012</p>
<p>A dice roller for any number and side of dice. Adds in-game dice rolling
(<code class="docutils literal notranslate"><span class="pre">roll</span> <span class="pre">2d10</span> <span class="pre">+</span> <span class="pre">1</span></code>) as well as conditionals (roll under/over/equal to a target)
and functions for rolling dice in code. Command also supports hidden or secret
rolls for use by a human game master.</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="installation">
<h1>Installation:<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h1>
<p>Add the <code class="docutils literal notranslate"><span class="pre">CmdDice</span></code> command from this module to your characters cmdset
(and then restart the server):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/commands/default_cmdsets.py</span>
<span class="c1"># ...</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.rpg</span> <span class="kn">import</span> <span class="n">dice</span> <span class="o">&lt;---</span>
<span class="k">class</span> <span class="nc">CharacterCmdSet</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">CharacterCmdSet</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="k">def</span> <span class="nf">at_object_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">dice</span><span class="o">.</span><span class="n">CmdDice</span><span class="p">())</span> <span class="c1"># &lt;---</span>
</pre></div>
</div>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="usage">
<h1>Usage:<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h1>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&gt; roll 1d100 + 2
&gt; roll 1d20
&gt; roll 1d20 - 4
</pre></div>
</div>
<p>The result of the roll will be echoed to the room</p>
<p>One can also specify a standard Python operator in order to specify
eventual target numbers and get results in a fair and guaranteed
unbiased way. For example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&gt; roll 2d6 + 2 &lt; 8
</pre></div>
</div>
<p>Rolling this will inform all parties if roll was indeed below 8 or not.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&gt; roll/hidden
</pre></div>
</div>
<p>Informs the room that the roll is being made without telling what the result
was.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&gt; roll/secret
</pre></div>
</div>
<p>Is a hidden roll that does not inform the room it happened.</p>
<section id="rolling-dice-from-code">
<h2>Rolling dice from code<a class="headerlink" href="#rolling-dice-from-code" title="Permalink to this headline"></a></h2>
<p>To roll dice in code, use the <code class="docutils literal notranslate"><span class="pre">roll</span></code> function from this module:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>
<span class="kn">from</span> <span class="nn">evennia.contrib.rpg</span> <span class="kn">import</span> <span class="n">dice</span>
<span class="n">dice</span><span class="o">.</span><span class="n">roll</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="p">(</span><span class="s2">&quot;+&quot;</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span> <span class="c1"># 3d10 + 2</span>
</pre></div>
</div>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/rpg/dice/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Dice</a></li>
<li><a class="reference internal" href="#installation">Installation:</a></li>
<li><a class="reference internal" href="#usage">Usage:</a><ul>
<li><a class="reference internal" href="#rolling-dice-from-code">Rolling dice from code</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/Contribs/Contrib-Dice.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="Contrib-Dice.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Dice</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,150 @@
<!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>Email-based login system &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Email-based login system</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 class="tex2jax_ignore mathjax_ignore" id="email-based-login-system">
<h1>Email-based login system<a class="headerlink" href="#email-based-login-system" title="Permalink to this headline"></a></h1>
<p>Contrib by Griatch, 2012</p>
<p>This is a variant of the login system that asks for an email-address
instead of a username to login. Note that it does not verify the email,
it just uses it as the identifier rather than a username.</p>
<p>This used to be the default Evennia login before replacing it with a
more standard username + password system (having to supply an email
for some reason caused a lot of confusion when people wanted to expand
on it. The email is not strictly needed internally, nor is any
confirmation email sent out anyway).</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>To your settings file, add/edit the line:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">CMDSET_UNLOGGEDIN</span> <span class="o">=</span> <span class="s2">&quot;contrib.base_systems.email_login.UnloggedinCmdSet&quot;</span>
<span class="n">CONNECTION_SCREEN_MODULE</span> <span class="o">=</span> <span class="s2">&quot;contrib.base_systems.email_login.connection_screens&quot;</span>
</pre></div>
</div>
<p>Thats it. Reload the server and reconnect to see it.</p>
</section>
<section id="notes">
<h2>Notes:<a class="headerlink" href="#notes" title="Permalink to this headline"></a></h2>
<p>If you want to modify the way the connection screen looks, point
<code class="docutils literal notranslate"><span class="pre">CONNECTION_SCREEN_MODULE</span></code> to your own module. Use the default as a
guide (see also Evennia docs).</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/base_systems/email_login/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Email-based login system</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#notes">Notes:</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/Contribs/Contrib-Email-Login.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="Contrib-Email-Login.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Email-based login system</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,240 @@
<!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>EvscapeRoom &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">EvscapeRoom</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 class="tex2jax_ignore mathjax_ignore" id="evscaperoom">
<h1>EvscapeRoom<a class="headerlink" href="#evscaperoom" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch, 2019</p>
<p>A full engine for creating multiplayer escape-rooms in Evennia. Allows players to
spawn and join puzzle rooms that track their state independently. Any number of players
can join to solve a room together. This is the engine created for EvscapeRoom, which won
the MUD Coders Guild “One Room” Game Jam in April-May, 2019. The contrib has no game
content but contains the utilities and base classes and an empty example room.</p>
<p>The original code for the contest is found at
<a class="reference external" href="https://github.com/Griatch/evscaperoom">https://github.com/Griatch/evscaperoom</a> but the version on the public Evennia
demo is more updated, so if you really want the latest bug fixes etc you should
rather look at <a class="reference external" href="https://github.com/evennia/evdemo/tree/master/evdemo/evscaperoom">https://github.com/evennia/evdemo/tree/master/evdemo/evscaperoom</a>
instead. A copy of the full game can also be played on the Evennia demo server
at <a class="reference external" href="https://demo.evennia.com">https://demo.evennia.com</a> - just connect to the server and write <code class="docutils literal notranslate"><span class="pre">evscaperoom</span></code>
in the first room to start!</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="introduction">
<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h1>
<p>Evscaperoom is, as it sounds, an escaperoom in text form. You start locked into
a room and have to figure out how to get out. This engine contains everything
needed to make a fully-featured puzzle game of this type!</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h1>
<p>The Evscaperoom is installed by adding the <code class="docutils literal notranslate"><span class="pre">evscaperoom</span></code> command to your
character cmdset. When you run that command in-game youre ready to play!</p>
<p>In <code class="docutils literal notranslate"><span class="pre">mygame/commands/default_cmdsets.py</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>
<span class="kn">from</span> <span class="nn">evennia.contrib.full_systems.evscaperoom.commands</span> <span class="kn">import</span> <span class="n">CmdEvscapeRoomStart</span>
<span class="k">class</span> <span class="nc">CharacterCmdSet</span><span class="p">(</span><span class="o">...</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">CmdEvscapeRoomStart</span><span class="p">())</span>
</pre></div>
</div>
<p>Reload the server and the <code class="docutils literal notranslate"><span class="pre">evscaperoom</span></code> command will be available. The contrib
comes with a small (very small) escape room as an example.</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="making-your-own-evscaperoom">
<h1>Making your own evscaperoom<a class="headerlink" href="#making-your-own-evscaperoom" title="Permalink to this headline"></a></h1>
<p>To do this, you need to make your own states. First make sure you can play the
simple example room installed above.</p>
<p>Copy <code class="docutils literal notranslate"><span class="pre">evennia/contrib/full_systems/evscaperoom/states</span></code> to somewhere in your game folder (lets
assume you put it under <code class="docutils literal notranslate"><span class="pre">mygame/world/</span></code>).</p>
<p>Next you need to re-point Evennia to look for states in this new location. Add
the following to your <code class="docutils literal notranslate"><span class="pre">mygame/server/conf/settings.py</span></code> file:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="n">EVSCAPEROOM_STATE_PACKAGE</span> <span class="o">=</span> <span class="s2">&quot;world.states&quot;</span>
</pre></div>
</div>
<p>Reload and the example evscaperoom should still work, but you can now modify and
expand it from your game dir!</p>
<section id="other-useful-settings">
<h2>Other useful settings<a class="headerlink" href="#other-useful-settings" title="Permalink to this headline"></a></h2>
<p>There are a few other settings that may be useful:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">EVSCAPEROOM_START_STATE</span></code> - default is <code class="docutils literal notranslate"><span class="pre">state_001_start</span></code> and is the name of
the state-module to start from (without <code class="docutils literal notranslate"><span class="pre">.py</span></code>). You can change this if you
want some other naming scheme.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">HELP_SUMMARY_TEXT</span></code> - this is the help blurb shown when entering <code class="docutils literal notranslate"><span class="pre">help</span></code> in
the room without an argument. The original is found at the top of
<code class="docutils literal notranslate"><span class="pre">evennia/contrib/full_systems/evscaperoom/commands.py</span></code>.</p></li>
</ul>
</section>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="playing-the-game">
<h1>Playing the game<a class="headerlink" href="#playing-the-game" title="Permalink to this headline"></a></h1>
<p>You should start by <code class="docutils literal notranslate"><span class="pre">look</span></code>ing around and at objects.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">examine</span> <span class="pre">&lt;object&gt;</span></code> command allows you to focus on an object. When you do
youll learn actions you could try for the object you are focusing on, such as
turning it around, read text on it or use it with some other object. Note that
more than one player can focus on the same object, so you wont block anyone
when you focus. Focusing on another object or use <code class="docutils literal notranslate"><span class="pre">examine</span></code> again will remove
focus.</p>
<p>There is also a full hint system.</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="technical">
<h1>Technical<a class="headerlink" href="#technical" title="Permalink to this headline"></a></h1>
<p>When connecting to the game, the user has the option to join an existing room
(which may already be in some state of ongoing progress), or may create a fresh
room for them to start solving on their own (but anyone may still join them later).</p>
<p>The room will go through a series of states as the players progress through
its challenges. These states are describes as modules in .states/ and the
room will load and execute the State-object within each module to set up
and transition between states as the players progress. This allows for isolating
the states from each other and will hopefully make it easier to track
the logic and (in principle) inject new puzzles later.</p>
<p>Once no players remain in the room, the room and its state will be wiped.</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="design-philosophy">
<h1>Design Philosophy<a class="headerlink" href="#design-philosophy" title="Permalink to this headline"></a></h1>
<p>Some basic premises inspired the design of this.</p>
<ul class="simple">
<li><p>You should be able to resolve the room alone. So no puzzles should require the
collaboration of multiple players. This is simply because there is no telling
if others will actually be online at a given time (or stay online throughout).</p></li>
<li><p>You should never be held up by the actions/inactions of other players. This
is why you cannot pick up anything (no inventory system) but only
focus/operate on items. This avoids the annoying case of a player picking up
a critical piece of a puzzle and then logging off.</p></li>
<li><p>A rooms state changes for everyone at once. My first idea was to have a given
room have different states depending on who looked (so a chest could be open
and closed to two different players at the same time). But not only does this
add a lot of extra complexity, it also defeats the purpose of having multiple
players. This way people can help each other and collaborate like in a real
escape room. For people that want to do it all themselves I instead made it
easy to start “fresh” rooms for them to take on.</p></li>
</ul>
<p>All other design decisions flowed from these.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/full_systems/evscaperoom/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">EvscapeRoom</a></li>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#making-your-own-evscaperoom">Making your own evscaperoom</a><ul>
<li><a class="reference internal" href="#other-useful-settings">Other useful settings</a></li>
</ul>
</li>
<li><a class="reference internal" href="#playing-the-game">Playing the game</a></li>
<li><a class="reference internal" href="#technical">Technical</a></li>
<li><a class="reference internal" href="#design-philosophy">Design Philosophy</a></li>
</ul>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Evscaperoom.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="Contrib-Evscaperoom.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">EvscapeRoom</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,201 @@
<!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>Extended Room &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Extended Room</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 class="tex2jax_ignore mathjax_ignore" id="extended-room">
<h1>Extended Room<a class="headerlink" href="#extended-room" title="Permalink to this headline"></a></h1>
<p>Contribution - Griatch 2012, vincent-lg 2019</p>
<p>This extends the normal <code class="docutils literal notranslate"><span class="pre">Room</span></code> typeclass to allow its description to change
with time-of-day and/or season. It also adds details for the player to look at
in the room (without having to create a new in-game object for each). The room is
supported by new <code class="docutils literal notranslate"><span class="pre">look</span></code> and <code class="docutils literal notranslate"><span class="pre">desc</span></code> commands.</p>
<section id="installation-testing">
<h2>Installation/testing:<a class="headerlink" href="#installation-testing" title="Permalink to this headline"></a></h2>
<p>Adding the <code class="docutils literal notranslate"><span class="pre">ExtendedRoomCmdset</span></code> to the default character cmdset will add all
new commands for use.</p>
<p>In more detail, in <code class="docutils literal notranslate"><span class="pre">mygame/commands/default_cmdsets.py</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="o">...</span>
<span class="kn">from</span> <span class="nn">evennia.contrib</span> <span class="kn">import</span> <span class="n">extended_room</span> <span class="c1"># &lt;---</span>
<span class="k">class</span> <span class="nc">CharacterCmdset</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">Character_CmdSet</span><span class="p">):</span>
<span class="o">...</span>
<span class="k">def</span> <span class="nf">at_cmdset_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="o">...</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">extended_room</span><span class="o">.</span><span class="n">ExtendedRoomCmdSet</span><span class="p">)</span> <span class="c1"># &lt;---</span>
</pre></div>
</div>
<p>Then reload to make the bew commands available. Note that they only work
on rooms with the typeclass <code class="docutils literal notranslate"><span class="pre">ExtendedRoom</span></code>. Create new rooms with the right
typeclass or use the <code class="docutils literal notranslate"><span class="pre">typeclass</span></code> command to swap existing rooms.</p>
</section>
<section id="features">
<h2>Features<a class="headerlink" href="#features" title="Permalink to this headline"></a></h2>
<section id="time-changing-description-slots">
<h3>Time-changing description slots<a class="headerlink" href="#time-changing-description-slots" title="Permalink to this headline"></a></h3>
<p>This allows to change the full description text the room shows
depending on larger time variations. Four seasons (spring, summer,
autumn and winter) are used by default. The season is calculated
on-demand (no Script or timer needed) and updates the full text block.</p>
<p>There is also a general description which is used as fallback if
one or more of the seasonal descriptions are not set when their
time comes.</p>
<p>An updated <code class="docutils literal notranslate"><span class="pre">desc</span></code> command allows for setting seasonal descriptions.</p>
<p>The room uses the <code class="docutils literal notranslate"><span class="pre">evennia.utils.gametime.GameTime</span></code> global script. This is
started by default, but if you have deactivated it, you need to
supply your own time keeping mechanism.</p>
</section>
<section id="in-description-changing-tags">
<h3>In-description changing tags<a class="headerlink" href="#in-description-changing-tags" title="Permalink to this headline"></a></h3>
<p>Within each seasonal (or general) description text, you can also embed
time-of-day dependent sections. Text inside such a tag will only show
during that particular time of day. The tags looks like <code class="docutils literal notranslate"><span class="pre">&lt;timeslot&gt;</span> <span class="pre">...</span> <span class="pre">&lt;/timeslot&gt;</span></code>. By default there are four timeslots per day - morning,
afternoon, evening and night.</p>
</section>
<section id="details">
<h3>Details<a class="headerlink" href="#details" title="Permalink to this headline"></a></h3>
<p>The Extended Room can be “detailed” with special keywords. This makes
use of a special <code class="docutils literal notranslate"><span class="pre">Look</span></code> command. Details are “virtual” targets to look
at, without there having to be a database object created for it. The
Details are simply stored in a dictionary on the room and if the look
command cannot find an object match for a <code class="docutils literal notranslate"><span class="pre">look</span> <span class="pre">&lt;target&gt;</span></code> command it
will also look through the available details at the current location
if applicable. The <code class="docutils literal notranslate"><span class="pre">detail</span></code> command is used to change details.</p>
</section>
<section id="extra-commands">
<h3>Extra commands<a class="headerlink" href="#extra-commands" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">CmdExtendedRoomLook</span></code> - look command supporting room details</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">CmdExtendedRoomDesc</span></code> - desc command allowing to add seasonal descs,</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">CmdExtendedRoomDetail</span></code> - command allowing to manipulate details in this room
as well as listing them</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">CmdExtendedRoomGameTime</span></code> - A simple <code class="docutils literal notranslate"><span class="pre">time</span></code> command, displaying the current
time and season.</p></li>
</ul>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/grid/extended_room/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</section>
</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="#">Extended Room</a><ul>
<li><a class="reference internal" href="#installation-testing">Installation/testing:</a></li>
<li><a class="reference internal" href="#features">Features</a><ul>
<li><a class="reference internal" href="#time-changing-description-slots">Time-changing description slots</a></li>
<li><a class="reference internal" href="#in-description-changing-tags">In-description changing tags</a></li>
<li><a class="reference internal" href="#details">Details</a></li>
<li><a class="reference internal" href="#extra-commands">Extra commands</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Extended-Room.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="Contrib-Extended-Room.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Extended Room</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,271 @@
<!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>Easy fillable form &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Easy fillable form</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 class="tex2jax_ignore mathjax_ignore" id="easy-fillable-form">
<h1>Easy fillable form<a class="headerlink" href="#easy-fillable-form" title="Permalink to this headline"></a></h1>
<p>Contribution by Tim Ashley Jenkins, 2018</p>
<p>This module contains a function that generates an <code class="docutils literal notranslate"><span class="pre">EvMenu</span></code> for you - this
menu presents the player with a form of fields that can be filled
out in any order (e.g. for character generation or building). Each fields value can
be verified, with the function allowing easy checks for text and integer input,
minimum and maximum values / character lengths, or can even be verified by a custom
function. Once the form is submitted, the forms data is submitted as a dictionary
to any callable of your choice.</p>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<p>The function that initializes the fillable form menu is fairly simple, and
includes the caller, the template for the form, and the callback(caller, result)
to which the form data will be sent to upon submission.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>init_fill_field(formtemplate, caller, formcallback)
</pre></div>
</div>
<p>Form templates are defined as a list of dictionaries - each dictionary
represents a field in the form, and contains the data for the fields name and
behavior. For example, this basic form template will allow a player to fill out
a brief character profile:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>PROFILE_TEMPLATE = [
{&quot;fieldname&quot;:&quot;Name&quot;, &quot;fieldtype&quot;:&quot;text&quot;},
{&quot;fieldname&quot;:&quot;Age&quot;, &quot;fieldtype&quot;:&quot;number&quot;},
{&quot;fieldname&quot;:&quot;History&quot;, &quot;fieldtype&quot;:&quot;text&quot;},
]
</pre></div>
</div>
<p>This will present the player with an EvMenu showing this basic form:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">Name</span><span class="p">:</span>
<span class="n">Age</span><span class="p">:</span>
<span class="n">History</span><span class="p">:</span>
</pre></div>
</div>
<p>While in this menu, the player can assign a new value to any field with the
syntax <field> = <new value>, like so:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="o">&gt;</span> <span class="n">name</span> <span class="o">=</span> <span class="n">Ashley</span>
<span class="n">Field</span> <span class="s1">&#39;Name&#39;</span> <span class="nb">set</span> <span class="n">to</span><span class="p">:</span> <span class="n">Ashley</span>
</pre></div>
</div>
<p>Typing look by itself will show the form and its current values.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="o">&gt;</span> <span class="n">look</span>
<span class="n">Name</span><span class="p">:</span> <span class="n">Ashley</span>
<span class="n">Age</span><span class="p">:</span>
<span class="n">History</span><span class="p">:</span>
</pre></div>
</div>
<p>Number fields require an integer input, and will reject any text that cant
be converted into an integer.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="o">&gt;</span> <span class="n">age</span> <span class="o">=</span> <span class="n">youthful</span>
<span class="n">Field</span> <span class="s1">&#39;Age&#39;</span> <span class="n">requires</span> <span class="n">a</span> <span class="n">number</span><span class="o">.</span>
<span class="o">&gt;</span> <span class="n">age</span> <span class="o">=</span> <span class="mi">31</span>
<span class="n">Field</span> <span class="s1">&#39;Age&#39;</span> <span class="nb">set</span> <span class="n">to</span><span class="p">:</span> <span class="mi">31</span>
</pre></div>
</div>
<p>Form data is presented as an EvTable, so text of any length will wrap cleanly.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="o">&gt;</span> <span class="n">history</span> <span class="o">=</span> <span class="n">EVERY</span> <span class="n">MORNING</span> <span class="n">I</span> <span class="n">WAKE</span> <span class="n">UP</span> <span class="n">AND</span> <span class="n">OPEN</span> <span class="n">PALM</span> <span class="n">SLAM</span><span class="p">[</span><span class="o">...</span><span class="p">]</span>
<span class="n">Field</span> <span class="s1">&#39;History&#39;</span> <span class="nb">set</span> <span class="n">to</span><span class="p">:</span> <span class="n">EVERY</span> <span class="n">MORNING</span> <span class="n">I</span> <span class="n">WAKE</span> <span class="n">UP</span> <span class="n">AND</span><span class="p">[</span><span class="o">...</span><span class="p">]</span>
<span class="o">&gt;</span> <span class="n">look</span>
<span class="n">Name</span><span class="p">:</span> <span class="n">Ashley</span>
<span class="n">Age</span><span class="p">:</span> <span class="mi">31</span>
<span class="n">History</span><span class="p">:</span> <span class="n">EVERY</span> <span class="n">MORNING</span> <span class="n">I</span> <span class="n">WAKE</span> <span class="n">UP</span> <span class="n">AND</span> <span class="n">OPEN</span> <span class="n">PALM</span> <span class="n">SLAM</span> <span class="n">A</span> <span class="n">VHS</span> <span class="n">INTO</span> <span class="n">THE</span> <span class="n">SLOT</span><span class="o">.</span>
<span class="n">IT</span><span class="s1">&#39;S CHRONICLES OF RIDDICK AND RIGHT THEN AND THERE I START DOING</span>
<span class="n">THE</span> <span class="n">MOVES</span> <span class="n">ALONGSIDE</span> <span class="n">WITH</span> <span class="n">THE</span> <span class="n">MAIN</span> <span class="n">CHARACTER</span><span class="p">,</span> <span class="n">RIDDICK</span><span class="o">.</span> <span class="n">I</span> <span class="n">DO</span> <span class="n">EVERY</span>
<span class="n">MOVE</span> <span class="n">AND</span> <span class="n">I</span> <span class="n">DO</span> <span class="n">EVERY</span> <span class="n">MOVE</span> <span class="n">HARD</span><span class="o">.</span>
</pre></div>
</div>
<p>When the player types submit (or your specified submit command), the menu
quits and the forms data is passed to your specified function as a dictionary,
like so:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>formdata = {&quot;Name&quot;:&quot;Ashley&quot;, &quot;Age&quot;:31, &quot;History&quot;:&quot;EVERY MORNING I[...]&quot;}
</pre></div>
</div>
<p>You can do whatever you like with this data in your function - forms can be used
to set data on a character, to help builders create objects, or for players to
craft items or perform other complicated actions with many variables involved.</p>
<p>The data that your form will accept can also be specified in your form template -
lets say, for example, that you wont accept ages under 18 or over 100. You can
do this by specifying “min” and “max” values in your fields dictionary:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">PROFILE_TEMPLATE</span> <span class="o">=</span> <span class="p">[</span>
<span class="p">{</span><span class="s2">&quot;fieldname&quot;</span><span class="p">:</span><span class="s2">&quot;Name&quot;</span><span class="p">,</span> <span class="s2">&quot;fieldtype&quot;</span><span class="p">:</span><span class="s2">&quot;text&quot;</span><span class="p">},</span>
<span class="p">{</span><span class="s2">&quot;fieldname&quot;</span><span class="p">:</span><span class="s2">&quot;Age&quot;</span><span class="p">,</span> <span class="s2">&quot;fieldtype&quot;</span><span class="p">:</span><span class="s2">&quot;number&quot;</span><span class="p">,</span> <span class="s2">&quot;min&quot;</span><span class="p">:</span><span class="mi">18</span><span class="p">,</span> <span class="s2">&quot;max&quot;</span><span class="p">:</span><span class="mi">100</span><span class="p">},</span>
<span class="p">{</span><span class="s2">&quot;fieldname&quot;</span><span class="p">:</span><span class="s2">&quot;History&quot;</span><span class="p">,</span> <span class="s2">&quot;fieldtype&quot;</span><span class="p">:</span><span class="s2">&quot;text&quot;</span><span class="p">}</span>
<span class="p">]</span>
</pre></div>
</div>
<p>Now if the player tries to enter a value out of range, the form will not acept the
given value.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="o">&gt;</span> <span class="n">age</span> <span class="o">=</span> <span class="mi">10</span>
<span class="n">Field</span> <span class="s1">&#39;Age&#39;</span> <span class="n">reqiures</span> <span class="n">a</span> <span class="n">minimum</span> <span class="n">value</span> <span class="n">of</span> <span class="mf">18.</span>
<span class="o">&gt;</span> <span class="n">age</span> <span class="o">=</span> <span class="mi">900</span>
<span class="n">Field</span> <span class="s1">&#39;Age&#39;</span> <span class="n">has</span> <span class="n">a</span> <span class="n">maximum</span> <span class="n">value</span> <span class="n">of</span> <span class="mf">100.</span>
</pre></div>
</div>
<p>Setting min and max for a text field will instead act as a minimum or
maximum character length for the players input.</p>
<p>There are lots of ways to present the form to the player - fields can have default
values or show a custom message in place of a blank value, and player input can be
verified by a custom function, allowing for a great deal of flexibility. There
is also an option for bool fields, which accept only a True / False input and
can be customized to represent the choice to the player however you like (E.G.
Yes/No, On/Off, Enabled/Disabled, etc.)</p>
<p>This module contains a simple example form that demonstrates all of the included
functionality - a command that allows a player to compose a message to another
online character and have it send after a custom delay. You can test it by
importing this module in your games <code class="docutils literal notranslate"><span class="pre">default_cmdsets.py</span></code> module and adding
CmdTestMenu to your default characters command set.</p>
</section>
<section id="field-template-keys">
<h2>FIELD TEMPLATE KEYS:<a class="headerlink" href="#field-template-keys" title="Permalink to this headline"></a></h2>
<section id="required">
<h3>Required:<a class="headerlink" href="#required" title="Permalink to this headline"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">fieldname</span> <span class="p">(</span><span class="nb">str</span><span class="p">):</span> <span class="n">Name</span> <span class="n">of</span> <span class="n">the</span> <span class="n">field</span><span class="p">,</span> <span class="k">as</span> <span class="n">presented</span> <span class="n">to</span> <span class="n">the</span> <span class="n">player</span><span class="o">.</span>
<span class="n">fieldtype</span> <span class="p">(</span><span class="nb">str</span><span class="p">):</span> <span class="n">Type</span> <span class="n">of</span> <span class="n">value</span> <span class="n">required</span><span class="p">:</span> <span class="s1">&#39;text&#39;</span><span class="p">,</span> <span class="s1">&#39;number&#39;</span><span class="p">,</span> <span class="ow">or</span> <span class="s1">&#39;bool&#39;</span><span class="o">.</span>
</pre></div>
</div>
</section>
<section id="optional">
<h3>Optional:<a class="headerlink" href="#optional" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>max (int): Maximum character length (if text) or value (if number).</p></li>
<li><p>min (int): Minimum charater length (if text) or value (if number).</p></li>
<li><p>truestr (str): String for a True value in a bool field.
(E.G. On, Enabled, Yes)</p></li>
<li><p>falsestr (str): String for a False value in a bool field.
(E.G. Off, Disabled, No)</p></li>
<li><p>default (str): Initial value (blank if not given).</p></li>
<li><p>blankmsg (str): Message to show in place of value when field is blank.</p></li>
<li><p>cantclear (bool): Field cant be cleared if True.</p></li>
<li><p>required (bool): If True, form cannot be submitted while field is blank.</p></li>
<li><p>verifyfunc (callable): Name of a callable used to verify input - takes
(caller, value) as arguments. If the function returns True,
the players input is considered valid - if it returns False,
the input is rejected. Any other value returned will act as
the fields new value, replacing the players input. This
allows for values that arent strings or integers (such as
object dbrefs). For boolean fields, return 0 or 1 to set
the field to False or True.</p></li>
</ul>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/utils/fieldfill/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</section>
</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="#">Easy fillable form</a><ul>
<li><a class="reference internal" href="#usage">Usage</a></li>
<li><a class="reference internal" href="#field-template-keys">FIELD TEMPLATE KEYS:</a><ul>
<li><a class="reference internal" href="#required">Required:</a></li>
<li><a class="reference internal" href="#optional">Optional:</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Fieldfill.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="Contrib-Fieldfill.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Easy fillable form</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,164 @@
<!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>Gendersub &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Gendersub</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 class="tex2jax_ignore mathjax_ignore" id="gendersub">
<h1>Gendersub<a class="headerlink" href="#gendersub" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch 2015</p>
<p>This is a simple gender-aware Character class for allowing users to
insert custom markers in their text to indicate gender-aware
messaging. It relies on a modified msg() and is meant as an
inspiration and starting point to how to do stuff like this.</p>
<p>An object can have the following genders:</p>
<ul class="simple">
<li><p>male (he/his)</p></li>
<li><p>female (her/hers)</p></li>
<li><p>neutral (it/its)</p></li>
<li><p>ambiguous (they/them/their/theirs)</p></li>
</ul>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Import and add the <code class="docutils literal notranslate"><span class="pre">SetGender</span></code> command to your default cmdset in
<code class="docutils literal notranslate"><span class="pre">mygame/commands/default_cmdset.py</span></code></p>
<p>Make your <code class="docutils literal notranslate"><span class="pre">Character</span></code> inherit from <code class="docutils literal notranslate"><span class="pre">GenderCharacter</span></code>.</p>
</section>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<p>When in use, messages can contain special tags to indicate pronouns gendered
based on the one being addressed. Capitalization will be retained.</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">|s</span></code>, <code class="docutils literal notranslate"><span class="pre">|S</span></code>: Subjective form: he, she, it, He, She, It, They</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">|o</span></code>, <code class="docutils literal notranslate"><span class="pre">|O</span></code>: Objective form: him, her, it, Him, Her, It, Them</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">|p</span></code>, <code class="docutils literal notranslate"><span class="pre">|P</span></code>: Possessive form: his, her, its, His, Her, Its, Their</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">|a</span></code>, <code class="docutils literal notranslate"><span class="pre">|A</span></code>: Absolute Possessive form: his, hers, its, His, Hers, Its, Theirs</p></li>
</ul>
<p>For example,</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">char</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2"> falls on |p face with a thud.&quot;</span> <span class="o">%</span> <span class="n">char</span><span class="o">.</span><span class="n">key</span><span class="p">)</span>
<span class="s2">&quot;Tom falls on his face with a thud&quot;</span>
</pre></div>
</div>
<p>The default gender is “ambiguous” (they/them/their/theirs).</p>
<p>To use, have DefaultCharacter inherit from this, or change
setting.DEFAULT_CHARACTER to point to this class.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">gender</span></code> command is used to set the gender. It needs to be added to the
default cmdset before it becomes available.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/game_systems/gendersub/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Gendersub</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#usage">Usage</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/Contribs/Contrib-Gendersub.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="Contrib-Gendersub.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Gendersub</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,153 @@
<!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>Health Bar &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Health Bar</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 class="tex2jax_ignore mathjax_ignore" id="health-bar">
<h1>Health Bar<a class="headerlink" href="#health-bar" title="Permalink to this headline"></a></h1>
<p>Contribution by Tim Ashley Jenkins, 2017</p>
<p>The function provided in this module lets you easily display visual
bars or meters as a colorful bar instead of just a number. A “health bar”
is merely the most obvious use for this, but the bar is highly customizable
and can be used for any sort of appropriate data besides player health.</p>
<p>Todays players may be more used to seeing statistics like health,
stamina, magic, and etc. displayed as bars rather than bare numerical
values, so using this module to present this data this way may make it
more accessible. Keep in mind, however, that players may also be using
a screen reader to connect to your game, which will not be able to
represent the colors of the bar in any way. By default, the values
represented are rendered as text inside the bar which can be read by
screen readers.</p>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<p>No installation, just import and use <code class="docutils literal notranslate"><span class="pre">display_meter</span></code> from this
module:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="kn">from</span> <span class="nn">evennia.contrib.rpg.health_bar</span> <span class="kn">import</span> <span class="n">display_meter</span>
<span class="c1"># health is 23/100</span>
<span class="n">health_bar</span> <span class="o">=</span> <span class="n">display_meter</span><span class="p">(</span><span class="mi">23</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>
<span class="n">caller</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="n">prompt</span><span class="o">=</span><span class="n">health_bar</span><span class="p">)</span>
</pre></div>
</div>
<p>The health bar will account for current values above the maximum or
below 0, rendering them as a completely full or empty bar with the
values displayed within.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/rpg/health_bar/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Health Bar</a><ul>
<li><a class="reference internal" href="#usage">Usage</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/Contribs/Contrib-Health-Bar.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="Contrib-Health-Bar.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Health Bar</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -18,9 +18,7 @@
<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" />
<link rel="next" title="Dynamic In Game Map" href="Dynamic-In-Game-Map.html" />
<link rel="prev" title="A voice operated elevator using events" href="A-voice-operated-elevator-using-events.html" />
<link rel="search" title="Search" href="../search.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
@ -31,14 +29,7 @@
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="Dynamic-In-Game-Map.html" title="Dynamic In Game Map"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="A-voice-operated-elevator-using-events.html" title="A voice operated elevator using events"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" accesskey="U">Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Dialogues in events</a></li>
</ul>
<div class="develop">develop branch</div>
@ -51,23 +42,19 @@
<section class="tex2jax_ignore mathjax_ignore" id="dialogues-in-events">
<h1>Dialogues in events<a class="headerlink" href="#dialogues-in-events" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p>Next tutorial: [adding a voice-operated elevator with events](A-voice-operated-elevator-using-
events).</p></li>
</ul>
<p>This tutorial will walk you through the steps to create several dialogues with characters, using the
<a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia/contrib/ingame_python/README.md">in-game Python
system</a>.
This tutorial assumes the in-game Python system is installed in your game. If it isnt, you can
follow the installation steps given in <a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia/contrib/ingame_python/README.md">the documentation on in-game
Python</a>, and
come back on this tutorial once the system is installed. <strong>You do not need to read</strong> the entire
documentation, its a good reference, but not the easiest way to learn about it. Hence these
<p>This tutorial will walk you through the steps to create several dialogues with
characters, using the Ingame-Python system. This tutorial assumes the in-game
Python system is installed in your game. If it isnt, you can follow the
installation steps given in <a class="reference internal" href="Contrib-Ingame-Python.html"><span class="doc std std-doc">The main In-game Python
docs</span></a> and come back on this tutorial once the
system is installed. <strong>You do not need to read</strong> the entire documentation, its
a good reference, but not the easiest way to learn about it. Hence these
tutorials.</p>
<p>The in-game Python system allows to run code on individual objects in some situations. You dont
have to modify the source code to add these features, past the installation. The entire system
makes it easy to add specific features to some objects, but not all. This is why it can be very
useful to create a dialogue system taking advantage of the in-game Python system.</p>
<p>The in-game Python system allows to run code on individual objects in some
situations. You dont have to modify the source code to add these features,
past the installation. The entire system makes it easy to add specific features
to some objects, but not all. This is why it can be very useful to create a
dialogue system taking advantage of the in-game Python system.</p>
<blockquote>
<div><p>What will we try to do?</p>
</div></blockquote>
@ -157,7 +144,7 @@ parameters in a function: they can be used inside of the function body because t
when the function was called.</p>
<p>This command has opened an editor where we can type our Python code.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">----------</span><span class="n">Line</span> <span class="n">Editor</span> <span class="p">[</span><span class="n">Callback</span> <span class="n">say</span> <span class="n">of</span> <span class="n">a</span> <span class="n">merchant</span><span class="p">]</span><span class="o">--------------------------------</span>
<span class="mi">01</span><span class="o">|</span>
<span class="mi">01</span><span class="o">|</span>
<span class="o">----------</span><span class="p">[</span><span class="n">l</span><span class="p">:</span><span class="mi">01</span> <span class="n">w</span><span class="p">:</span><span class="mi">000</span> <span class="n">c</span><span class="p">:</span><span class="mi">0000</span><span class="p">]</span><span class="o">------------</span><span class="p">(:</span><span class="n">h</span> <span class="k">for</span> <span class="n">help</span><span class="p">)</span><span class="o">----------------------------</span>
</pre></div>
</div>
@ -311,16 +298,10 @@ events).</p></li>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="A-voice-operated-elevator-using-events.html"
title="previous chapter">A voice operated elevator using events</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Dynamic-In-Game-Map.html"
title="next chapter">Dynamic In Game Map</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Dialogues-in-events.md.txt"
<li><a href="../_sources/Contribs/Contrib-Ingame-Python-Tutorial-Dialogue.md.txt"
rel="nofollow">Show Page Source</a></li>
</ul>
</div><h3>Links</h3>
@ -336,7 +317,7 @@ events).</p></li>
</ul>
<h3>Versions</h3>
<ul>
<li><a href="Dialogues-in-events.html">1.0-dev (develop branch)</a></li>
<li><a href="Contrib-Ingame-Python-Tutorial-Dialogue.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>
@ -353,14 +334,7 @@ events).</p></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="Dynamic-In-Game-Map.html" title="Dynamic In Game Map"
>next</a> |</li>
<li class="right" >
<a href="A-voice-operated-elevator-using-events.html" title="A voice operated elevator using events"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" >Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Dialogues in events</a></li>
</ul>
<div class="develop">develop branch</div>

View file

@ -18,9 +18,7 @@
<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" />
<link rel="next" title="Dialogues in events" href="Dialogues-in-events.html" />
<link rel="prev" title="evennia.contrib.crafting.example_recipes" href="../api/evennia.contrib.crafting.example_recipes.html" />
<link rel="search" title="Search" href="../search.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
@ -31,14 +29,7 @@
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="Dialogues-in-events.html" title="Dialogues in events"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="../api/evennia.contrib.crafting.example_recipes.html" title="evennia.contrib.crafting.example_recipes"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" accesskey="U">Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">A voice operated elevator using events</a></li>
</ul>
<div class="develop">develop branch</div>
@ -51,16 +42,9 @@
<section class="tex2jax_ignore mathjax_ignore" id="a-voice-operated-elevator-using-events">
<h1>A voice operated elevator using events<a class="headerlink" href="#a-voice-operated-elevator-using-events" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p>Previous tutorial: <a class="reference internal" href="Dialogues-in-events.html"><span class="doc std std-doc">Adding dialogues in events</span></a></p></li>
</ul>
<p>This tutorial will walk you through the steps to create a voice-operated elevator, using the <a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia/contrib/ingame_python/README.md">in-
game Python
system</a>.
This tutorial assumes the in-game Python system is installed in your game. If it isnt, you can
follow the installation steps given in <a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia/contrib/ingame_python/README.md">the documentation on in-game
Python</a>, and
come back on this tutorial once the system is installed. <strong>You do not need to read</strong> the entire
<p>This tutorial will walk you through the steps to create a voice-operated elevator, using the <a class="reference internal" href="Contrib-Ingame-Python.html"><span class="doc std std-doc">in-
game Python system</span></a>. This tutorial assumes the in-game Python
system is installed per the instructions in that doc. <strong>You do not need to read</strong> the entire
documentation, its a good reference, but not the easiest way to learn about it. Hence these
tutorials.</p>
<p>The in-game Python system allows to run code on individual objects in some situations. You dont
@ -142,7 +126,8 @@ Created room The third floor(#7) of type typeclasses.rooms.Room.
things to decorate it a bit.</p>
<p>But what we want now is to be able to say “1”, “2” or “3” and have the elevator move in that
direction.</p>
<p>If you have read <a class="reference internal" href="Dialogues-in-events.html"><span class="doc std std-doc">the previous tutorial about adding dialogues in events</span></a>, you
<p>If you have read
<a class="reference internal" href="Contrib-Ingame-Python-Tutorial-Dialogue.html"><span class="doc std std-doc">the other in-game Python tutorial about adding dialogues in events</span></a>, you
may remember what we need to do. If not, heres a summary: we need to run some code when somebody
speaks in the room. So we need to create a callback (the callback will contain our lines of code).
We just need to know on which event this should be set. You can enter <code class="docutils literal notranslate"><span class="pre">call</span> <span class="pre">here</span></code> to see the
@ -175,7 +160,7 @@ all, the list of variables that are available in this callback:</p>
<span class="n">message</span><span class="p">:</span> <span class="n">the</span> <span class="n">text</span> <span class="n">having</span> <span class="n">been</span> <span class="n">spoken</span> <span class="n">by</span> <span class="n">the</span> <span class="n">character</span><span class="o">.</span>
<span class="o">----------</span><span class="n">Line</span> <span class="n">Editor</span> <span class="p">[</span><span class="n">Callback</span> <span class="n">say</span> <span class="n">of</span> <span class="n">Inside</span> <span class="n">of</span> <span class="n">an</span> <span class="n">elevator</span><span class="p">]</span><span class="o">---------------------</span>
<span class="mi">01</span><span class="o">|</span>
<span class="mi">01</span><span class="o">|</span>
<span class="o">----------</span><span class="p">[</span><span class="n">l</span><span class="p">:</span><span class="mi">01</span> <span class="n">w</span><span class="p">:</span><span class="mi">000</span> <span class="n">c</span><span class="p">:</span><span class="mi">0000</span><span class="p">]</span><span class="o">------------</span><span class="p">(:</span><span class="n">h</span> <span class="k">for</span> <span class="n">help</span><span class="p">)</span><span class="o">----------------------------</span>
</pre></div>
</div>
@ -285,7 +270,7 @@ better to have a pause of several seconds. More logical.</p>
pauses. Contrary to the events we have seen so far, chained events arent called automatically.
They must be called by you, and can be called after some time.</p>
<ul class="simple">
<li><p>Chained events always have the name “chain_X”. Usually, X is a number, but you can give the
<li><p>Chained events always have the name <code class="docutils literal notranslate"><span class="pre">&quot;chain_X&quot;</span></code>. Usually, X is a number, but you can give the
chained event a more explicit name.</p></li>
<li><p>In our original callback, we will call our chained events in, say, 15 seconds.</p></li>
<li><p>Well also have to make sure the elevator isnt already moving.</p></li>
@ -295,7 +280,7 @@ event in our elevator, that will only contain the code necessary to open the doo
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>call/add here = chain_1
</pre></div>
</div>
<p>The callback is added to the “chain_1” event, an event that will not be automatically called by the
<p>The callback is added to the <code class="docutils literal notranslate"><span class="pre">&quot;chain_1&quot;</span></code> event, an event that will not be automatically called by the
system when something happens. Inside this event, you can paste the code to open the doors at the
new floor. You can notice a few differences:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">TO_EXIT</span><span class="o">.</span><span class="n">location</span> <span class="o">=</span> <span class="n">floor</span>
@ -311,7 +296,7 @@ new floor. You can notice a few differences:</p>
<ul class="simple">
<li><p>The callback will have to check the elevator isnt already moving.</p></li>
<li><p>It must change the exits when the elevator move.</p></li>
<li><p>It has to call the “chain_1” event we have defined. It should call it 15 seconds later.</p></li>
<li><p>It has to call the <code class="docutils literal notranslate"><span class="pre">&quot;chain_1&quot;</span></code> event we have defined. It should call it 15 seconds later.</p></li>
</ul>
<p>Lets see the code in our callback.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>call/edit here = say
@ -446,8 +431,8 @@ constraints on persistent attributes. A callback will not be stored in this way
This variable will not be available in your chained event.</p></li>
<li><p><strong>Q:</strong> when you say I can call my chained events something else than “chain_1”, “chain_2” and
such, what is the naming convention?</p></li>
<li><p><strong>A:</strong> chained events have names beginning by “chain_”. This is useful for you and for the
system. But after the underscore, you can give a more useful name, like “chain_open_doors” in our
<li><p><strong>A:</strong> chained events have names beginning by <code class="docutils literal notranslate"><span class="pre">&quot;chain_&quot;</span></code>. This is useful for you and for the
system. But after the underscore, you can give a more useful name, like <code class="docutils literal notranslate"><span class="pre">&quot;chain_open_doors&quot;</span></code> in our
case.</p></li>
<li><p><strong>Q:</strong> do I have to pause several seconds to call a chained event?</p></li>
<li><p><strong>A:</strong> no, you can call it right away. Just leave the third parameter of <code class="docutils literal notranslate"><span class="pre">call_event</span></code> out (it
@ -455,15 +440,14 @@ will default to 0, meaning the chained event will be called right away). This w
task.</p></li>
<li><p><strong>Q:</strong> can I have chained events calling themselves?</p></li>
<li><p><strong>A:</strong> you can. Theres no limitation. Just be careful, a callback that calls itself,
particularly without delay, might be a good recipe for an infinite loop. However, in some cases, it
particularly without delay, might be a good recipe for an infinite loop. However, in some cases, it
is useful to have chained events calling themselves, to do the same repeated action every X seconds
for instance.</p></li>
<li><p><strong>Q:</strong> what if I need several elevators, do I need to copy/paste these callbacks each time?</p></li>
<li><p><strong>A:</strong> not advisable. There are definitely better ways to handle this situation. One of them is
to consider adding the code in the source itself. Another possibility is to call chained events
with the expected behavior, which makes porting code very easy. This side of chained events will be
with the expected behavior, which makes porting code very easy. This side of chained events will be
shown in the next tutorial.</p></li>
<li><p>Previous tutorial: <a class="reference internal" href="Dialogues-in-events.html"><span class="doc std std-doc">Adding dialogues in events</span></a></p></li>
</ul>
</section>
</section>
@ -502,16 +486,10 @@ shown in the next tutorial.</p></li>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="../api/evennia.contrib.crafting.example_recipes.html"
title="previous chapter">evennia.contrib.crafting.example_recipes</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Dialogues-in-events.html"
title="next chapter">Dialogues in events</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/A-voice-operated-elevator-using-events.md.txt"
<li><a href="../_sources/Contribs/Contrib-Ingame-Python-Tutorial-Elevator.md.txt"
rel="nofollow">Show Page Source</a></li>
</ul>
</div><h3>Links</h3>
@ -527,7 +505,7 @@ shown in the next tutorial.</p></li>
</ul>
<h3>Versions</h3>
<ul>
<li><a href="A-voice-operated-elevator-using-events.html">1.0-dev (develop branch)</a></li>
<li><a href="Contrib-Ingame-Python-Tutorial-Elevator.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>
@ -544,14 +522,7 @@ shown in the next tutorial.</p></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="Dialogues-in-events.html" title="Dialogues in events"
>next</a> |</li>
<li class="right" >
<a href="../api/evennia.contrib.crafting.example_recipes.html" title="evennia.contrib.crafting.example_recipes"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" >Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">A voice operated elevator using events</a></li>
</ul>
<div class="develop">develop branch</div>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,172 @@
<!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>In-Game Mail system &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">In-Game Mail system</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 class="tex2jax_ignore mathjax_ignore" id="in-game-mail-system">
<h1>In-Game Mail system<a class="headerlink" href="#in-game-mail-system" title="Permalink to this headline"></a></h1>
<p>Contribution by grungies1138 2016</p>
<p>A simple Brandymail style mail system that uses the <code class="docutils literal notranslate"><span class="pre">Msg</span></code> class from Evennia
Core. It has two Commands for either sending mails between Accounts (out of game)
or between Characters (in-game). The two types of mails can be used together or
on their own.</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">CmdMail</span></code> - this should sit on the Account cmdset and makes the <code class="docutils literal notranslate"><span class="pre">mail</span></code> command
available both IC and OOC. Mails will always go to Accounts (other players).</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">CmdMailCharacter</span></code> - this should sit on the Character cmdset and makes the <code class="docutils literal notranslate"><span class="pre">mail</span></code>
command ONLY available when puppeting a character. Mails will be sent to other
Characters only and will not be available when OOC.</p></li>
<li><p>If adding <em>both</em> commands to their respective cmdsets, youll get two separate
IC and OOC mailing systems, with different lists of mail for IC and OOC modes.</p></li>
</ul>
<section id="installation">
<h2>Installation:<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Install one or both of the following (see above):</p>
<ul class="simple">
<li><p>CmdMail (IC + OOC mail, sent between players)</p></li>
<li><p>CmdMailCharacter (optional, IC only mail, sent between characters)</p></li>
</ul>
<p>Once installed, use <code class="docutils literal notranslate"><span class="pre">help</span> <span class="pre">mail</span></code> in game for help with the mail command. Use
ic/ooc to switch in and out of IC/OOC modes.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/game_systems/mail/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</section>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="mygame-commands-default-cmds-py">
<h1>mygame/commands/default_cmds.py<a class="headerlink" href="#mygame-commands-default-cmds-py" title="Permalink to this headline"></a></h1>
<p>from evennia.contrib.game_systems import mail</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="in-accountcmdset-at-cmdset-creation">
<h1>in AccountCmdSet.at_cmdset_creation:<a class="headerlink" href="#in-accountcmdset-at-cmdset-creation" title="Permalink to this headline"></a></h1>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> self.add(mail.CmdMail())
</pre></div>
</div>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="id1">
<h1>mygame/commands/default_cmds.py<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h1>
<p>from evennia.contrib.game_systems import mail</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="in-charactercmdset-at-cmdset-creation">
<h1>in CharacterCmdSet.at_cmdset_creation:<a class="headerlink" href="#in-charactercmdset-at-cmdset-creation" title="Permalink to this headline"></a></h1>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> self.add(mail.CmdMailCharacter())
</pre></div>
</div>
</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="#">In-Game Mail system</a><ul>
<li><a class="reference internal" href="#installation">Installation:</a></li>
</ul>
</li>
<li><a class="reference internal" href="#mygame-commands-default-cmds-py">mygame/commands/default_cmds.py</a></li>
<li><a class="reference internal" href="#in-accountcmdset-at-cmdset-creation">in AccountCmdSet.at_cmdset_creation:</a></li>
<li><a class="reference internal" href="#id1">mygame/commands/default_cmds.py</a></li>
<li><a class="reference internal" href="#in-charactercmdset-at-cmdset-creation">in CharacterCmdSet.at_cmdset_creation:</a></li>
</ul>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Mail.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="Contrib-Mail.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">In-Game Mail system</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,401 @@
<!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>Map Builder &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Map Builder</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 class="tex2jax_ignore mathjax_ignore" id="map-builder">
<h1>Map Builder<a class="headerlink" href="#map-builder" title="Permalink to this headline"></a></h1>
<p>Contribution by Cloud_Keeper 2016</p>
<p>Build a game map from the drawing of a 2D ASCII map.</p>
<p>This is a command which takes two inputs:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>≈≈≈≈≈
≈♣n♣≈ MAP_LEGEND = {(&quot;&quot;, &quot;&quot;): build_forest,
≈∩▲∩≈ (&quot;&quot;, &quot;n&quot;): build_mountains,
≈♠n♠≈ (&quot;&quot;): build_temple}
≈≈≈≈≈
</pre></div>
</div>
<p>A string of ASCII characters representing a map and a dictionary of functions
containing build instructions. The characters of the map are iterated over and
compared to a list of trigger characters. When a match is found the
corresponding function is executed generating the rooms, exits and objects as
defined by the users build instructions. If a character is not a match to
a provided trigger character (including spaces) it is simply skipped and the
process continues.</p>
<p>For instance, the above map represents a temple (▲) amongst mountains (n,∩)
in a forest (♣,♠) on an island surrounded by water (≈). Each character on the
first line is iterated over but as there is no match with our <code class="docutils literal notranslate"><span class="pre">MAP_LEGEND</span></code>, it
is skipped. On the second line it finds “♣” which is a match and so the
<code class="docutils literal notranslate"><span class="pre">build_forest</span></code> function is called. Next the <code class="docutils literal notranslate"><span class="pre">build_mountains</span></code> function is
called and so on until the map is completed. Building instructions are passed
the following arguments:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>x - The rooms position on the maps x axis
y - The rooms position on the maps y axis
caller - The account calling the command
iteration - The current iterations number (0, 1 or 2)
room_dict - A dictionary containing room references returned by build
functions where tuple coordinates are the keys (x, y).
ie room_dict[(2, 2)] will return the temple room above.
</pre></div>
</div>
<p>Building functions should return the room they create. By default these rooms
are used to create exits between valid adjacent rooms to the north, south,
east and west directions. This behaviour can turned off with the use of switch
arguments. In addition to turning off automatic exit generation the switches
allow the map to be iterated over a number of times. This is important for
something like custom exit building. Exits require a reference to both the
exits location and the exits destination. During the first iteration it is
possible that an exit is created pointing towards a destination that
has not yet been created resulting in error. By iterating over the map twice
the rooms can be created on the first iteration and room reliant code can be
be used on the second iteration. The iteration number and a dictionary of
references to rooms previously created is passed to the build commands.</p>
<p>You then call the command in-game using the path to the MAP and MAP_LEGEND vars
The path you provide is relative to the evennia or mygame folder.</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h1>
<p>Use by importing and including the command in your default_cmdsets module.
For example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="c1"># mygame/commands/default_cmdsets.py</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.grid</span> <span class="kn">import</span> <span class="n">mapbuilder</span>
<span class="o">...</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">mapbuilder</span><span class="o">.</span><span class="n">CmdMapBuilder</span><span class="p">())</span>
</pre></div>
</div>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="usage">
<h1>Usage:<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h1>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>mapbuilder[/switch] &lt;path.to.file.MAPNAME&gt; &lt;path.to.file.MAP_LEGEND&gt;
one - execute build instructions once without automatic exit creation.
two - execute build instructions twice without automatic exit creation.
</pre></div>
</div>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="examples">
<h1>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h1>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>mapbuilder world.gamemap.MAP world.maplegend.MAP_LEGEND
mapbuilder evennia.contrib.grid.mapbuilder.EXAMPLE1_MAP EXAMPLE1_LEGEND
mapbuilder/two evennia.contrib.grid.mapbuilder.EXAMPLE2_MAP EXAMPLE2_LEGEND
(Legend path defaults to map path)
</pre></div>
</div>
<p>Below are two examples showcasing the use of automatic exit generation and
custom exit generation. Whilst located, and can be used, from this module for
convenience The below example code should be in <a class="reference external" href="http://mymap.py">mymap.py</a> in mygame/world.</p>
<section id="example-one">
<h2>Example One<a class="headerlink" href="#example-one" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>
<span class="kn">from</span> <span class="nn">django.conf</span> <span class="kn">import</span> <span class="n">settings</span>
<span class="kn">from</span> <span class="nn">evennia.utils</span> <span class="kn">import</span> <span class="n">utils</span>
<span class="c1"># mapbuilder evennia.contrib.grid.mapbuilder.EXAMPLE1_MAP EXAMPLE1_LEGEND</span>
<span class="c1"># -*- coding: utf-8 -*-</span>
<span class="c1"># Add the necessary imports for your instructions here.</span>
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">create_object</span>
<span class="kn">from</span> <span class="nn">typeclasses</span> <span class="kn">import</span> <span class="n">rooms</span><span class="p">,</span> <span class="n">exits</span>
<span class="kn">from</span> <span class="nn">random</span> <span class="kn">import</span> <span class="n">randint</span>
<span class="kn">import</span> <span class="nn">random</span>
<span class="c1"># A map with a temple (▲) amongst mountains (n,∩) in a forest (♣,♠) on an</span>
<span class="c1"># island surrounded by water (≈). By giving no instructions for the water</span>
<span class="c1"># characters we effectively skip it and create no rooms for those squares.</span>
<span class="n">EXAMPLE1_MAP</span> <span class="o">=</span> <span class="s1">&#39;&#39;&#39;</span>
<span class="s1">≈≈≈≈≈</span>
<span class="s1">≈♣n♣≈</span>
<span class="s1">≈∩▲∩≈</span>
<span class="s1">≈♠n♠≈</span>
<span class="s1">≈≈≈≈≈</span>
<span class="s1">&#39;&#39;&#39;</span>
<span class="k">def</span> <span class="nf">example1_build_forest</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;A basic example of build instructions. Make sure to include **kwargs</span>
<span class="sd"> in the arguments and return an instance of the room for exit generation.&#39;&#39;&#39;</span>
<span class="c1"># Create a room and provide a basic description.</span>
<span class="n">room</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">rooms</span><span class="o">.</span><span class="n">Room</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;forest&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">y</span><span class="p">))</span>
<span class="n">room</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="s2">&quot;Basic forest room.&quot;</span>
<span class="c1"># Send a message to the account</span>
<span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;caller&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="n">room</span><span class="o">.</span><span class="n">key</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="n">room</span><span class="o">.</span><span class="n">dbref</span><span class="p">)</span>
<span class="c1"># This is generally mandatory.</span>
<span class="k">return</span> <span class="n">room</span>
<span class="k">def</span> <span class="nf">example1_build_mountains</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;A room that is a little more advanced&#39;&#39;&#39;</span>
<span class="c1"># Create the room.</span>
<span class="n">room</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">rooms</span><span class="o">.</span><span class="n">Room</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;mountains&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">y</span><span class="p">))</span>
<span class="c1"># Generate a description by randomly selecting an entry from a list.</span>
<span class="n">room_desc</span> <span class="o">=</span> <span class="p">[</span>
<span class="s2">&quot;Mountains as far as the eye can see&quot;</span><span class="p">,</span>
<span class="s2">&quot;Your path is surrounded by sheer cliffs&quot;</span><span class="p">,</span>
<span class="s2">&quot;Haven&#39;t you seen that rock before?&quot;</span><span class="p">,</span>
<span class="p">]</span>
<span class="n">room</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">choice</span><span class="p">(</span><span class="n">room_desc</span><span class="p">)</span>
<span class="c1"># Create a random number of objects to populate the room.</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">randint</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">3</span><span class="p">)):</span>
<span class="n">rock</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">key</span><span class="o">=</span><span class="s2">&quot;Rock&quot;</span><span class="p">,</span> <span class="n">location</span><span class="o">=</span><span class="n">room</span><span class="p">)</span>
<span class="n">rock</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="s2">&quot;An ordinary rock.&quot;</span>
<span class="c1"># Send a message to the account</span>
<span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;caller&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="n">room</span><span class="o">.</span><span class="n">key</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="n">room</span><span class="o">.</span><span class="n">dbref</span><span class="p">)</span>
<span class="c1"># This is generally mandatory.</span>
<span class="k">return</span> <span class="n">room</span>
<span class="k">def</span> <span class="nf">example1_build_temple</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;A unique room that does not need to be as general&#39;&#39;&#39;</span>
<span class="c1"># Create the room.</span>
<span class="n">room</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">rooms</span><span class="o">.</span><span class="n">Room</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;temple&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">y</span><span class="p">))</span>
<span class="c1"># Set the description.</span>
<span class="n">room</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="p">(</span>
<span class="s2">&quot;In what, from the outside, appeared to be a grand and &quot;</span>
<span class="s2">&quot;ancient temple you&#39;ve somehow found yourself in the the &quot;</span>
<span class="s2">&quot;Evennia Inn! It consists of one large room filled with &quot;</span>
<span class="s2">&quot;tables. The bardisk extends along the east wall, where &quot;</span>
<span class="s2">&quot;multiple barrels and bottles line the shelves. The &quot;</span>
<span class="s2">&quot;barkeep seems busy handing out ale and chatting with &quot;</span>
<span class="s2">&quot;the patrons, which are a rowdy and cheerful lot, &quot;</span>
<span class="s2">&quot;keeping the sound level only just below thunderous. &quot;</span>
<span class="s2">&quot;This is a rare spot of mirth on this dread moor.&quot;</span>
<span class="p">)</span>
<span class="c1"># Send a message to the account</span>
<span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;caller&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="n">room</span><span class="o">.</span><span class="n">key</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="n">room</span><span class="o">.</span><span class="n">dbref</span><span class="p">)</span>
<span class="c1"># This is generally mandatory.</span>
<span class="k">return</span> <span class="n">room</span>
<span class="c1"># Include your trigger characters and build functions in a legend dict.</span>
<span class="n">EXAMPLE1_LEGEND</span> <span class="o">=</span> <span class="p">{</span>
<span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">):</span> <span class="n">example1_build_forest</span><span class="p">,</span>
<span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="s2">&quot;n&quot;</span><span class="p">):</span> <span class="n">example1_build_mountains</span><span class="p">,</span>
<span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">):</span> <span class="n">example1_build_temple</span><span class="p">,</span>
<span class="p">}</span>
</pre></div>
</div>
</section>
<section id="example-two">
<h2>Example Two<a class="headerlink" href="#example-two" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># @mapbuilder/two evennia.contrib.grid.mapbuilder.EXAMPLE2_MAP EXAMPLE2_LEGEND</span>
<span class="c1"># -*- coding: utf-8 -*-</span>
<span class="c1"># Add the necessary imports for your instructions here.</span>
<span class="c1"># from evennia import create_object</span>
<span class="c1"># from typeclasses import rooms, exits</span>
<span class="c1"># from evennia.utils import utils</span>
<span class="c1"># from random import randint</span>
<span class="c1"># import random</span>
<span class="c1"># This is the same layout as Example 1 but included are characters for exits.</span>
<span class="c1"># We can use these characters to determine which rooms should be connected.</span>
<span class="n">EXAMPLE2_MAP</span> <span class="o">=</span> <span class="s1">&#39;&#39;&#39;</span>
<span class="s1">≈ ≈ ≈ ≈ ≈</span>
<span class="s1">≈ ♣-♣-♣ ≈</span>
<span class="s1"> | |</span>
<span class="s1">≈ ♣ ♣ ♣ ≈</span>
<span class="s1"> | | |</span>
<span class="s1">≈ ♣-♣-♣ ≈</span>
<span class="s1">≈ ≈ ≈ ≈ ≈</span>
<span class="s1">&#39;&#39;&#39;</span>
<span class="k">def</span> <span class="nf">example2_build_forest</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;A basic room&#39;&#39;&#39;</span>
<span class="c1"># If on anything other than the first iteration - Do nothing.</span>
<span class="k">if</span> <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;iteration&quot;</span><span class="p">]</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">None</span>
<span class="n">room</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">rooms</span><span class="o">.</span><span class="n">Room</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;forest&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">y</span><span class="p">))</span>
<span class="n">room</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="s2">&quot;Basic forest room.&quot;</span>
<span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;caller&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="n">room</span><span class="o">.</span><span class="n">key</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="n">room</span><span class="o">.</span><span class="n">dbref</span><span class="p">)</span>
<span class="k">return</span> <span class="n">room</span>
<span class="k">def</span> <span class="nf">example2_build_verticle_exit</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;Creates two exits to and from the two rooms north and south.&#39;&#39;&#39;</span>
<span class="c1"># If on the first iteration - Do nothing.</span>
<span class="k">if</span> <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;iteration&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">return</span>
<span class="n">north_room</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;room_dict&quot;</span><span class="p">][(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)]</span>
<span class="n">south_room</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;room_dict&quot;</span><span class="p">][(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)]</span>
<span class="c1"># create exits in the rooms</span>
<span class="n">create_object</span><span class="p">(</span>
<span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;south&quot;</span><span class="p">,</span> <span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;s&quot;</span><span class="p">],</span> <span class="n">location</span><span class="o">=</span><span class="n">north_room</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">south_room</span>
<span class="p">)</span>
<span class="n">create_object</span><span class="p">(</span>
<span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;north&quot;</span><span class="p">,</span> <span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;n&quot;</span><span class="p">],</span> <span class="n">location</span><span class="o">=</span><span class="n">south_room</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">north_room</span>
<span class="p">)</span>
<span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;caller&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;Connected: &quot;</span> <span class="o">+</span> <span class="n">north_room</span><span class="o">.</span><span class="n">key</span> <span class="o">+</span> <span class="s2">&quot; &amp; &quot;</span> <span class="o">+</span> <span class="n">south_room</span><span class="o">.</span><span class="n">key</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">example2_build_horizontal_exit</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;Creates two exits to and from the two rooms east and west.&#39;&#39;&#39;</span>
<span class="c1"># If on the first iteration - Do nothing.</span>
<span class="k">if</span> <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;iteration&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">return</span>
<span class="n">west_room</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;room_dict&quot;</span><span class="p">][(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">y</span><span class="p">)]</span>
<span class="n">east_room</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;room_dict&quot;</span><span class="p">][(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">y</span><span class="p">)]</span>
<span class="n">create_object</span><span class="p">(</span><span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;east&quot;</span><span class="p">,</span> <span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;e&quot;</span><span class="p">],</span> <span class="n">location</span><span class="o">=</span><span class="n">west_room</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">east_room</span><span class="p">)</span>
<span class="n">create_object</span><span class="p">(</span><span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;west&quot;</span><span class="p">,</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> <span class="n">location</span><span class="o">=</span><span class="n">east_room</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">west_room</span><span class="p">)</span>
<span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;caller&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;Connected: &quot;</span> <span class="o">+</span> <span class="n">west_room</span><span class="o">.</span><span class="n">key</span> <span class="o">+</span> <span class="s2">&quot; &amp; &quot;</span> <span class="o">+</span> <span class="n">east_room</span><span class="o">.</span><span class="n">key</span><span class="p">)</span>
<span class="c1"># Include your trigger characters and build functions in a legend dict.</span>
<span class="n">EXAMPLE2_LEGEND</span> <span class="o">=</span> <span class="p">{</span>
<span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">):</span> <span class="n">example2_build_forest</span><span class="p">,</span>
<span class="p">(</span><span class="s2">&quot;|&quot;</span><span class="p">):</span> <span class="n">example2_build_verticle_exit</span><span class="p">,</span>
<span class="p">(</span><span class="s2">&quot;-&quot;</span><span class="p">):</span> <span class="n">example2_build_horizontal_exit</span><span class="p">,</span>
<span class="p">}</span>
</pre></div>
</div>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/grid/mapbuilder/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Map Builder</a></li>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#usage">Usage:</a></li>
<li><a class="reference internal" href="#examples">Examples</a><ul>
<li><a class="reference internal" href="#example-one">Example One</a></li>
<li><a class="reference internal" href="#example-two">Example Two</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/Contribs/Contrib-Mapbuilder.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="Contrib-Mapbuilder.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Map Builder</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,144 @@
<!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>Menu-based login system &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Menu-based login system</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 class="tex2jax_ignore mathjax_ignore" id="menu-based-login-system">
<h1>Menu-based login system<a class="headerlink" href="#menu-based-login-system" title="Permalink to this headline"></a></h1>
<p>Contribution by Vincent-lg 2016. Reworked for modern EvMenu by Griatch, 2019.</p>
<p>This changes the Evennia login to ask for the account name and password as a series
of questions instead of requiring you to enter both at once. It uses Evennias
menu system <code class="docutils literal notranslate"><span class="pre">EvMenu</span></code> under the hood.</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>To install, add this to <code class="docutils literal notranslate"><span class="pre">mygame/server/conf/settings.py</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>CMDSET_UNLOGGEDIN = &quot;evennia.contrib.base_systems.menu_login.UnloggedinCmdSet&quot;
CONNECTION_SCREEN_MODULE = &quot;contrib.base_systems.menu_login.connection_screens&quot;
</pre></div>
</div>
<p>Reload the server and reconnect to see the changes.</p>
</section>
<section id="notes">
<h2>Notes<a class="headerlink" href="#notes" title="Permalink to this headline"></a></h2>
<p>If you want to modify the way the connection screen looks, point
<code class="docutils literal notranslate"><span class="pre">CONNECTION_SCREEN_MODULE</span></code> to your own module. Use the default as a
guide (see also Evennia docs).</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/base_systems/menu_login/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Menu-based login system</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#notes">Notes</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/Contribs/Contrib-Menu-Login.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="Contrib-Menu-Login.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Menu-based login system</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,139 @@
<!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>TutorialMirror &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">TutorialMirror</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 class="tex2jax_ignore mathjax_ignore" id="tutorialmirror">
<h1>TutorialMirror<a class="headerlink" href="#tutorialmirror" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch, 2017</p>
<p>A simple mirror object to experiment with. It will respond to being looked at.</p>
<ul class="simple">
<li><p>echoes back the description of the object looking at it</p></li>
<li><p>echoes back whatever is being sent to its .msg - to the
sender, if given, otherwise to the location of the mirror.</p></li>
</ul>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Create the mirror with</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>create/drop mirror:contrib.tutorials.mirror.TutorialMirror
</pre></div>
</div>
<p>Then look at it.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/tutorials/mirror/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">TutorialMirror</a><ul>
<li><a class="reference internal" href="#installation">Installation</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/Contribs/Contrib-Mirror.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="Contrib-Mirror.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">TutorialMirror</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,143 @@
<!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>Evennia Multidescer &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Evennia Multidescer</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 class="tex2jax_ignore mathjax_ignore" id="evennia-multidescer">
<h1>Evennia Multidescer<a class="headerlink" href="#evennia-multidescer" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch 2016</p>
<p>A “multidescer” is a concept from the MUSH world. It allows for
creating, managing and switching between multiple character
descriptions and is a way for quickly managing your look (such as when
changing clothes) in more free-form roleplaying systems. This will also
work well together with the <code class="docutils literal notranslate"><span class="pre">rpsystem</span></code> contrib.</p>
<p>This multidescer will not
require any changes to the Character class, rather it will use the <code class="docutils literal notranslate"><span class="pre">multidescs</span></code>
Attribute (a list) and create it if it does not exist.</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Edit <code class="docutils literal notranslate"><span class="pre">mygame/commands/default_cmdsets.py</span></code> and add
<code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">evennia.contrib.game_systems.multidescer</span> <span class="pre">import</span> <span class="pre">CmdMultiDesc</span></code> to the top.</p>
<p>Next, look up the <code class="docutils literal notranslate"><span class="pre">at_cmdset_create</span></code> method of the <code class="docutils literal notranslate"><span class="pre">CharacterCmdSet</span></code>
class and add a line <code class="docutils literal notranslate"><span class="pre">self.add(CmdMultiDesc())</span></code> to the end
of it.</p>
<p>Reload the server and you should have the +desc command available (it
will replace the default <code class="docutils literal notranslate"><span class="pre">desc</span></code> command).</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/game_systems/multidescer/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Evennia Multidescer</a><ul>
<li><a class="reference internal" href="#installation">Installation</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/Contribs/Contrib-Multidescer.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="Contrib-Multidescer.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Evennia Multidescer</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,189 @@
<!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>Legacy Comms-commands &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Legacy Comms-commands</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 class="tex2jax_ignore mathjax_ignore" id="legacy-comms-commands">
<h1>Legacy Comms-commands<a class="headerlink" href="#legacy-comms-commands" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch 2021</p>
<p>In Evennia 1.0+, the old Channel commands (originally inspired by MUX) were
replaced by the single <code class="docutils literal notranslate"><span class="pre">channel</span></code> command that performs all these functions.
This contrib (extracted from Evennia 0.9.5) breaks out the functionality into
separate Commands more familiar to MU* users. This is just for show though, the
main <code class="docutils literal notranslate"><span class="pre">channel</span></code> command is still called under the hood.</p>
<table class="colwidths-auto docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Contrib syntax</p></th>
<th class="head"><p>Default <code class="docutils literal notranslate"><span class="pre">channel</span></code> syntax</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">allcom</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">channel/all</span></code> and <code class="docutils literal notranslate"><span class="pre">channel</span></code></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">addcom</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">channel/alias</span></code>, <code class="docutils literal notranslate"><span class="pre">channel/sub</span></code> and <code class="docutils literal notranslate"><span class="pre">channel/unmute</span></code></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">delcom</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">channel/unalias</span></code>, <code class="docutils literal notranslate"><span class="pre">alias/unsub</span></code> and <code class="docutils literal notranslate"><span class="pre">channel/mute</span></code></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">cboot</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">channel/boot</span></code> (<code class="docutils literal notranslate"><span class="pre">channel/ban</span></code> and <code class="docutils literal notranslate"><span class="pre">/unban</span></code> not supported)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">cwho</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">channel/who</span></code></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">ccreate</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">channel/create</span></code></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">cdestroy</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">channel/destroy</span></code></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">clock</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">channel/lock</span></code></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">cdesc</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">channel/desc</span></code></p></td>
</tr>
</tbody>
</table>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Import the <code class="docutils literal notranslate"><span class="pre">CmdSetLegacyComms</span></code> cmdset from this module into <code class="docutils literal notranslate"><span class="pre">mygame/commands/default_cmdsets.py</span></code></p></li>
<li><p>Add it to the CharacterCmdSets <code class="docutils literal notranslate"><span class="pre">at_cmdset_creation</span></code> method (see below).</p></li>
<li><p>Reload the server.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/commands/default_cmdsets.py</span>
<span class="c1"># ..</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.base_systems.mux_comms_cmds</span> <span class="kn">import</span> <span class="n">CmdSetLegacyComms</span> <span class="c1"># &lt;----</span>
<span class="k">class</span> <span class="nc">CharacterCmdSet</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">CharacterCmdSet</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="k">def</span> <span class="nf">at_cmdset_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">CmdSetLegacyComms</span><span class="p">)</span> <span class="c1"># &lt;----</span>
</pre></div>
</div>
<p>Note that you will still be able to use the <code class="docutils literal notranslate"><span class="pre">channel</span></code> command; this is actually
still used under the hood by these commands.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/base_systems/mux_comms_cmds/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Legacy Comms-commands</a><ul>
<li><a class="reference internal" href="#installation">Installation</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/Contribs/Contrib-Mux-Comms-Cmds.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="Contrib-Mux-Comms-Cmds.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Legacy Comms-commands</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -6,7 +6,7 @@
<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>Contrib modules &#8212; Evennia 1.0-dev documentation</title>
<title>Contribs &#8212; 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>
@ -19,7 +19,7 @@
<link rel="shortcut 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="Crafting system contrib" href="Crafting.html" />
<link rel="next" title="Links" href="../Links.html" />
<link rel="prev" title="Coding and development help" href="../Coding/Coding-Overview.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
@ -32,13 +32,13 @@
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="Crafting.html" title="Crafting system contrib"
<a href="../Links.html" title="Links"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="../Coding/Coding-Overview.html" title="Coding and development help"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Contrib modules</a></li>
<li class="nav-item nav-item-this"><a href="">Contribs</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
@ -48,290 +48,427 @@
<div class="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="contrib-modules">
<h1>Contrib modules<a class="headerlink" href="#contrib-modules" title="Permalink to this headline"></a></h1>
<p>Contribs are found in <a class="reference internal" href="../api/evennia.contrib.html#evennia-contrib"><span class="std std-ref">evennia/contrib/</span></a> and are optional game-specific code-snippets
or even full systems you can use for your game. They are contributed by the Evennia community and
released under the same license as Evennia itself. Each contrib has its own installation instructions.
Bugs are reported to the Evennia <a class="reference external" href="https://github.com/evennia/evennia/issues/new/choose">issue tracker</a> as usual.</p>
<section id="character-related">
<h2>Character-related<a class="headerlink" href="#character-related" title="Permalink to this headline"></a></h2>
<p>Contribs related to characters and character displays.</p>
<section id="chargen">
<h3>CharGen<a class="headerlink" href="#chargen" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2011</em></p>
<p>A simple Character creator for OOC mode. Meant as a starting point for a more fleshed-out system.</p>
<section class="tex2jax_ignore mathjax_ignore" id="contribs">
<h1>Contribs<a class="headerlink" href="#contribs" title="Permalink to this headline"></a></h1>
<p><em>Contribs</em> are optional code snippets and systems contributed by
the Evennia community. They vary in size and complexity and
may be more specific about game types and styles than core Evennia.
This page is auto-generated and summarizes all contribs currently included.</p>
<p>All contrib categories are imported from <code class="docutils literal notranslate"><span class="pre">evennia.contrib</span></code>, such as</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>from evennia.contrib.base_systems import building_menu
</pre></div>
</div>
<p>Each contrib contains installation instructions for how to integrate it
with your other code. If you want to tweak the code of a contrib, just
copy its entire folder to your game directory and modify/use it from there.</p>
<blockquote>
<div><p>Hint: Additional (potentially un-maintained) code snippets from the community can be found
in our discussion forums <a class="reference external" href="https://github.com/evennia/evennia/discussions/categories/community-contribs-snippets">Community Contribs &amp; Snippets</a> category.</p>
</div></blockquote>
<p>If you want to contribute yourself, see <a class="reference internal" href="../Contributing.html"><span class="doc std std-doc">here</span></a>!</p>
<section id="base-systems">
<h2>base_systems<a class="headerlink" href="#base-systems" title="Permalink to this headline"></a></h2>
<p><em>This category contains systems that are not necessarily tied to a specific
in-game mechanic but is useful for the game as a whole. Examples include
login systems, new command syntaxes, and build helpers.</em></p>
<section id="contrib-awsstorage">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">awsstorage</span></code><a class="headerlink" href="#contrib-awsstorage" title="Permalink to this headline"></a></h3>
<p><em>Contrib by The Right Honourable Reverend (trhr), 2020</em></p>
<p>This plugin migrates the Web-based portion of Evennia, namely images,
javascript, and other items located inside staticfiles into Amazon AWS (S3)
cloud hosting. Great for those serving media with the game.</p>
<p><a class="reference internal" href="Contrib-AWSStorage.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.base_systems.awsstorage.html#evennia-contrib-base-systems-awsstorage"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="clothing">
<h3>Clothing<a class="headerlink" href="#clothing" title="Permalink to this headline"></a></h3>
<p><em>FlutterSprite 2017</em></p>
<p>A layered clothing system with slots for different types of garments auto-showing in description.</p>
<section id="contrib-building-menu">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">building_menu</span></code><a class="headerlink" href="#contrib-building-menu" title="Permalink to this headline"></a></h3>
<p><em>Contrib by vincent-lg, 2018</em></p>
<p>Building menus are in-game menus, not unlike <code class="docutils literal notranslate"><span class="pre">EvMenu</span></code> though using a
different approach. Building menus have been specifically designed to edit
information as a builder. Creating a building menu in a command allows
builders quick-editing of a given object, like a room. If you follow the
steps to add the contrib, you will have access to an <code class="docutils literal notranslate"><span class="pre">edit</span></code> command
that will edit any default object, offering to change its key and description.</p>
<p><a class="reference internal" href="Contrib-Building-Menu.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.base_systems.building_menu.html#evennia-contrib-base-systems-building-menu"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="health-bar">
<h3>Health Bar<a class="headerlink" href="#health-bar" title="Permalink to this headline"></a></h3>
<p><em>Tim Ashley Jenkins 2017</em></p>
<p>Tool to create colorful bars/meters.</p>
<section id="contrib-color-markups">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">color_markups</span></code><a class="headerlink" href="#contrib-color-markups" title="Permalink to this headline"></a></h3>
<p><em>Contrib by Griatch, 2017</em></p>
<p>Additional color markup styles for Evennia (extending or replacing the default
<code class="docutils literal notranslate"><span class="pre">|r</span></code>, <code class="docutils literal notranslate"><span class="pre">|234</span></code>). Adds support for MUSH-style (<code class="docutils literal notranslate"><span class="pre">%cr</span></code>, <code class="docutils literal notranslate"><span class="pre">%c123</span></code>) and/or legacy-Evennia
(<code class="docutils literal notranslate"><span class="pre">{r</span></code>, <code class="docutils literal notranslate"><span class="pre">{123</span></code>).</p>
<p><a class="reference internal" href="Contrib-Color-Markups.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.base_systems.color_markups.html#evennia-contrib-base-systems-color-markups"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="multidescer">
<h3>Multidescer<a class="headerlink" href="#multidescer" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2016</em></p>
<p>Advanced descriptions combined from many separate description components, inspired by MUSH.</p>
<section id="contrib-custom-gametime">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">custom_gametime</span></code><a class="headerlink" href="#contrib-custom-gametime" title="Permalink to this headline"></a></h3>
<p><em>Contrib by vlgeoff, 2017 - based on Griatchs core original</em></p>
<p>This reimplements the <code class="docutils literal notranslate"><span class="pre">evennia.utils.gametime</span></code> module but with a <em>custom</em>
calendar (unusual number of days per week/month/year etc) for your game world.
Like the original, it allows for scheduling events to happen at given
in-game times, but now taking this custom calendar into account.</p>
<p><a class="reference internal" href="Contrib-Custom-Gametime.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.base_systems.custom_gametime.html#evennia-contrib-base-systems-custom-gametime"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="contrib-email-login">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">email_login</span></code><a class="headerlink" href="#contrib-email-login" title="Permalink to this headline"></a></h3>
<p><em>Contrib by Griatch, 2012</em></p>
<p>This is a variant of the login system that asks for an email-address
instead of a username to login. Note that it does not verify the email,
it just uses it as the identifier rather than a username.</p>
<p><a class="reference internal" href="Contrib-Email-Login.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.base_systems.email_login.html#evennia-contrib-base-systems-email-login"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="contrib-ingame-python">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">ingame_python</span></code><a class="headerlink" href="#contrib-ingame-python" title="Permalink to this headline"></a></h3>
<p><em>Contrib by Vincent Le Goff 2017</em></p>
<p>This contrib adds the ability to script with Python in-game. It allows trusted
staff/builders to dynamically add features and triggers to individual objects
without needing to do it in external Python modules. Using custom Python in-game,
specific rooms, exits, characters, objects etc can be made to behave differently from
its “cousins”. This is similar to how softcode works for MU or MudProgs for DIKU.
Keep in mind, however, that allowing Python in-game comes with <em>severe</em>
security concerns (you must trust your builders deeply), so read the warnings in
this module carefully before continuing.</p>
<p><a class="reference internal" href="Contrib-Ingame-Python.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.base_systems.ingame_python.html#evennia-contrib-base-systems-ingame-python"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="contrib-menu-login">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">menu_login</span></code><a class="headerlink" href="#contrib-menu-login" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Vincent-lg 2016. Reworked for modern EvMenu by Griatch, 2019.</em></p>
<p>This changes the Evennia login to ask for the account name and password as a series
of questions instead of requiring you to enter both at once. It uses Evennias
menu system <code class="docutils literal notranslate"><span class="pre">EvMenu</span></code> under the hood.</p>
<p><a class="reference internal" href="Contrib-Menu-Login.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.base_systems.menu_login.html#evennia-contrib-base-systems-menu-login"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="contrib-mux-comms-cmds">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">mux_comms_cmds</span></code><a class="headerlink" href="#contrib-mux-comms-cmds" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch 2021</em></p>
<p>In Evennia 1.0+, the old Channel commands (originally inspired by MUX) were
replaced by the single <code class="docutils literal notranslate"><span class="pre">channel</span></code> command that performs all these functions.
This contrib (extracted from Evennia 0.9.5) breaks out the functionality into
separate Commands more familiar to MU* users. This is just for show though, the
main <code class="docutils literal notranslate"><span class="pre">channel</span></code> command is still called under the hood.</p>
<p><a class="reference internal" href="Contrib-Mux-Comms-Cmds.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.base_systems.mux_comms_cmds.html#evennia-contrib-base-systems-mux-comms-cmds"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="contrib-unixcommand">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">unixcommand</span></code><a class="headerlink" href="#contrib-unixcommand" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Vincent Le Geoff (vlgeoff), 2017</em></p>
<p>This module contains a command class with an alternate syntax parser implementing
Unix-style command syntax in-game. This means <code class="docutils literal notranslate"><span class="pre">--options</span></code>, positional arguments
and stuff like <code class="docutils literal notranslate"><span class="pre">-n</span> <span class="pre">10</span></code>. It might not the best syntax for the average player
but can be really useful for builders when they need to have a single command do
many things with many options. It uses the <code class="docutils literal notranslate"><span class="pre">ArgumentParser</span></code> from Pythons standard
library under the hood.</p>
<p><a class="reference internal" href="Contrib-Unixcommand.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.base_systems.unixcommand.html#evennia-contrib-base-systems-unixcommand"><span class="std std-ref">Browse the Code</span></a></p>
</section>
</section>
<hr class="docutils" />
<section id="rooms-movement-and-grid">
<h2>Rooms, movement and grid<a class="headerlink" href="#rooms-movement-and-grid" title="Permalink to this headline"></a></h2>
<p>Contribs modifying locations, movement or helping to creating rooms.</p>
<section id="xyzgrid">
<h3>XYZGrid<a class="headerlink" href="#xyzgrid" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2021</em></p>
<p>Adds an XYZgrid to Evennia, with map-display and pathfinding. Created via map
strings and maintained outside of the game via Evennia launch commands.</p>
<ul class="simple">
<li><p><a class="reference internal" href="XYZGrid.html"><span class="doc std std-doc">XYZGrid documentation</span></a></p></li>
</ul>
</section>
<section id="extended-room">
<h3>Extended Room<a class="headerlink" href="#extended-room" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2012</em></p>
<p>An expanded Room typeclass with multiple descriptions for time and season as well as details.</p>
</section>
<section id="map-builder">
<h3>Map Builder<a class="headerlink" href="#map-builder" title="Permalink to this headline"></a></h3>
<p><em>CloudKeeper 2016</em></p>
<p>Build a game area based on a 2D “graphical” unicode map. Supports asymmetric exits.</p>
<ul class="simple">
<li><p><a class="reference internal" href="Static-In-Game-Map.html"><span class="doc std std-doc">Static in-game map</span></a></p></li>
</ul>
</section>
<section id="simple-door">
<h3>Simple Door<a class="headerlink" href="#simple-door" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2014</em></p>
<p>Example of an exit that can be opened and closed from both sides.</p>
</section>
<section id="slow-exit">
<h3>Slow exit<a class="headerlink" href="#slow-exit" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2014</em></p>
<p>Custom Exit class that takes different time to pass depending on if you are walking/running etc.</p>
</section>
<section id="wilderness">
<h3>Wilderness<a class="headerlink" href="#wilderness" title="Permalink to this headline"></a></h3>
<p><em>titeuf87 2017</em></p>
<p>Make infinitely large wilderness areas with dynamically created locations.</p>
<ul class="simple">
<li><p><a class="reference internal" href="Dynamic-In-Game-Map.html"><span class="doc std std-doc">Dynamic in-game map</span></a></p></li>
</ul>
<section id="full-systems">
<h2>full_systems<a class="headerlink" href="#full-systems" title="Permalink to this headline"></a></h2>
<p><em>This category contains complete game engines that can be used directly
to start creating content without no further additions (unless you want to).</em></p>
<section id="contrib-evscaperoom">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">evscaperoom</span></code><a class="headerlink" href="#contrib-evscaperoom" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch, 2019</em></p>
<p>A full engine for creating multiplayer escape-rooms in Evennia. Allows players to
spawn and join puzzle rooms that track their state independently. Any number of players
can join to solve a room together. This is the engine created for EvscapeRoom, which won
the MUD Coders Guild “One Room” Game Jam in April-May, 2019. The contrib has no game
content but contains the utilities and base classes and an empty example room.</p>
<p><a class="reference internal" href="Contrib-Evscaperoom.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.full_systems.evscaperoom.html#evennia-contrib-full-systems-evscaperoom"><span class="std std-ref">Browse the Code</span></a></p>
</section>
</section>
<hr class="docutils" />
<section id="roleplaying-and-rules">
<h2>Roleplaying and rules<a class="headerlink" href="#roleplaying-and-rules" title="Permalink to this headline"></a></h2>
<p>Contribs supporting roleplay and in-game roleplaying actions.</p>
<section id="barter-system">
<h3>Barter system<a class="headerlink" href="#barter-system" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2012</em></p>
<p>A safe and effective barter-system for any game. Allows safe trading of any goods (including coin).</p>
<section id="game-systems">
<h2>game_systems<a class="headerlink" href="#game-systems" title="Permalink to this headline"></a></h2>
<p><em>This category holds code implementing in-game gameplay systems like
crafting, mail, combat and more. Each system is meant to be adopted
piecemeal and adopted for your game. This does not include
roleplaying-specific systems, those are found in the <code class="docutils literal notranslate"><span class="pre">rpg</span></code> folder.</em></p>
<section id="contrib-barter">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">barter</span></code><a class="headerlink" href="#contrib-barter" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch, 2012</em></p>
<p>This implements a full barter system - a way for players to safely
trade items between each other in code rather than simple <code class="docutils literal notranslate"><span class="pre">give/get</span></code>
commands. This increases both safety (at no time will one player have
both goods and payment in-hand) and speed, since agreed goods will
be moved automatically). By just replacing one side with coin objects,
(or a mix of coins and goods), this also works fine for regular money
transactions.</p>
<p><a class="reference internal" href="Contrib-Barter.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.game_systems.barter.html#evennia-contrib-game-systems-barter"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="crafting">
<h3>Crafting<a class="headerlink" href="#crafting" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2020</em></p>
<p>A full, extendable crafting system.</p>
<ul class="simple">
<li><p><a class="reference internal" href="Crafting.html"><span class="doc std std-doc">Crafting overview</span></a></p></li>
<li><p><a class="reference internal" href="../api/evennia.contrib.crafting.crafting.html#evennia-contrib-crafting-crafting"><span class="std std-ref">Crafting API documentation</span></a></p></li>
<li><p><a class="reference internal" href="../api/evennia.contrib.crafting.example_recipes.html#evennia-contrib-crafting-example-recipes"><span class="std std-ref">Example of a sword crafting tree</span></a></p></li>
</ul>
<section id="contrib-clothing">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">clothing</span></code><a class="headerlink" href="#contrib-clothing" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Tim Ashley Jenkins, 2017</em></p>
<p>Provides a typeclass and commands for wearable clothing. These
look of these clothes are appended to the characters description when worn.</p>
<p><a class="reference internal" href="Contrib-Clothing.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.game_systems.clothing.html#evennia-contrib-game-systems-clothing"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="dice">
<h3>Dice<a class="headerlink" href="#dice" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2012</em></p>
<p>A fully featured dice rolling system.</p>
<section id="contrib-cooldowns">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">cooldowns</span></code><a class="headerlink" href="#contrib-cooldowns" title="Permalink to this headline"></a></h3>
<p><em>Contribution by owllex, 2021</em></p>
<p>Cooldowns are used modelling rate-limited actions, like how often a
character can perform a given action; until a certain time has passed their
command can not be used again. This contrib provides a simple cooldown
handler that can be attached to any typeclass. A cooldown is a lightweight persistent
asynchronous timer that you can query to see if a certain time has yet passed.</p>
<p><a class="reference internal" href="Contrib-Cooldowns.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.game_systems.cooldowns.html#evennia-contrib-game-systems-cooldowns"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="mail">
<h3>Mail<a class="headerlink" href="#mail" title="Permalink to this headline"></a></h3>
<p><em>grungies1138 2016</em></p>
<p>An in-game mail system for communication.</p>
<section id="contrib-crafting">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">crafting</span></code><a class="headerlink" href="#contrib-crafting" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch 2020</em></p>
<p>This implements a full crafting system. The principle is that of a recipe,
where you combine items (tagged as ingredients) create something new. The recipe can also
require certain (non-consumed) tools. An example would be to use the bread recipe to
combine flour, water and yeast with an oven to bake a loaf of bread.</p>
<p><a class="reference internal" href="Contrib-Crafting.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.game_systems.crafting.html#evennia-contrib-game-systems-crafting"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="puzzles">
<h3>Puzzles<a class="headerlink" href="#puzzles" title="Permalink to this headline"></a></h3>
<p><em>Hendher 2019</em></p>
<p>Combine objects to create new items, adventure-game style</p>
<section id="contrib-gendersub">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">gendersub</span></code><a class="headerlink" href="#contrib-gendersub" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch 2015</em></p>
<p>This is a simple gender-aware Character class for allowing users to
insert custom markers in their text to indicate gender-aware
messaging. It relies on a modified msg() and is meant as an
inspiration and starting point to how to do stuff like this.</p>
<p><a class="reference internal" href="Contrib-Gendersub.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.game_systems.gendersub.html#evennia-contrib-game-systems-gendersub"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="rp-system">
<h3>RP System<a class="headerlink" href="#rp-system" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2015</em></p>
<p>Full director-style emoting system replacing names with sdescs/recogs. Supports wearing masks.</p>
<section id="contrib-mail">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">mail</span></code><a class="headerlink" href="#contrib-mail" title="Permalink to this headline"></a></h3>
<p><em>Contribution by grungies1138 2016</em></p>
<p>A simple Brandymail style mail system that uses the <code class="docutils literal notranslate"><span class="pre">Msg</span></code> class from Evennia
Core. It has two Commands for either sending mails between Accounts (out of game)
or between Characters (in-game). The two types of mails can be used together or
on their own.</p>
<p><a class="reference internal" href="Contrib-Mail.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.game_systems.mail.html#evennia-contrib-game-systems-mail"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="rp-language">
<h3>RP Language<a class="headerlink" href="#rp-language" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2015</em></p>
<p>Dynamic obfuscation of emotes when speaking unfamiliar languages. Also obfuscates whispers.</p>
<section id="contrib-multidescer">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">multidescer</span></code><a class="headerlink" href="#contrib-multidescer" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch 2016</em></p>
<p>A “multidescer” is a concept from the MUSH world. It allows for
creating, managing and switching between multiple character
descriptions and is a way for quickly managing your look (such as when
changing clothes) in more free-form roleplaying systems. This will also
work well together with the <code class="docutils literal notranslate"><span class="pre">rpsystem</span></code> contrib.</p>
<p><a class="reference internal" href="Contrib-Multidescer.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.game_systems.multidescer.html#evennia-contrib-game-systems-multidescer"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="traits">
<h3>Traits<a class="headerlink" href="#traits" title="Permalink to this headline"></a></h3>
<p><em>Whitenoise 2014, Griatch2021</em></p>
<p>Powerful on-object properties (very extended Attributes) for representing
health, mana, skill-levels etc, with automatic min/max value, base, modifiers
and named tiers for different values. Also include timed rate increase/decrease
to have values change over a period of time.</p>
<section id="contrib-puzzles">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">puzzles</span></code><a class="headerlink" href="#contrib-puzzles" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Henddher 2018</em></p>
<p>Intended for adventure-game style combination puzzles, such as combining fruits
and a blender to create a smoothie. Provides a typeclass and commands for objects
that can be combined (i.e. used together). Unlike the <code class="docutils literal notranslate"><span class="pre">crafting</span></code> contrib, each
puzzle is built from unique objects rather than using tags and a builder can create
the puzzle entirely from in-game.</p>
<p><a class="reference internal" href="Contrib-Puzzles.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.game_systems.puzzles.html#evennia-contrib-game-systems-puzzles"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="turnbattle">
<h3>Turnbattle<a class="headerlink" href="#turnbattle" title="Permalink to this headline"></a></h3>
<p><em>FlutterSprite 2017</em></p>
<p>A turn-based combat engine meant as a start to build from. Has attack/disengage and turn timeouts,
and includes optional expansions for equipment and combat movement, magic and ranged combat.</p>
<section id="contrib-turnbattle">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">turnbattle</span></code><a class="headerlink" href="#contrib-turnbattle" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Tim Ashley Jenkins, 2017</em></p>
<p>This is a framework for a simple turn-based combat system, similar
to those used in D&amp;D-style tabletop role playing games. It allows
any character to start a fight in a room, at which point initiative
is rolled and a turn order is established. Each participant in combat
has a limited time to decide their action for that turn (30 seconds by
default), and combat progresses through the turn order, looping through
the participants until the fight ends.</p>
<p><a class="reference internal" href="Contrib-Turnbattle.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.game_systems.turnbattle.html#evennia-contrib-game-systems-turnbattle"><span class="std std-ref">Browse the Code</span></a></p>
</section>
</section>
<hr class="docutils" />
<section id="building-and-server-systems">
<h2>Building and server systems<a class="headerlink" href="#building-and-server-systems" title="Permalink to this headline"></a></h2>
<section id="building-menu">
<h3>Building menu<a class="headerlink" href="#building-menu" title="Permalink to this headline"></a></h3>
<p><em>vincent-lg 2018</em></p>
<p>An <code class="docutils literal notranslate"><span class="pre">&#64;edit</span></code> command for modifying objects using a generated menu. Customizable for different games.</p>
<section id="grid">
<h2>grid<a class="headerlink" href="#grid" title="Permalink to this headline"></a></h2>
<p><em>Systems related to the game worlds topology and structure. This has
contribs related to rooms, exits and map building.</em></p>
<section id="contrib-extended-room">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">extended_room</span></code><a class="headerlink" href="#contrib-extended-room" title="Permalink to this headline"></a></h3>
<p><em>Contribution - Griatch 2012, vincent-lg 2019</em></p>
<p>This extends the normal <code class="docutils literal notranslate"><span class="pre">Room</span></code> typeclass to allow its description to change
with time-of-day and/or season. It also adds details for the player to look at
in the room (without having to create a new in-game object for each). The room is
supported by new <code class="docutils literal notranslate"><span class="pre">look</span></code> and <code class="docutils literal notranslate"><span class="pre">desc</span></code> commands.</p>
<p><a class="reference internal" href="Contrib-Extended-Room.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.grid.extended_room.html#evennia-contrib-grid-extended-room"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="field-fill">
<h3>Field Fill<a class="headerlink" href="#field-fill" title="Permalink to this headline"></a></h3>
<p><em>FlutterSprite 2018</em></p>
<p>A simple system for creating an EvMenu that presents a player with a highly customizable fillable form</p>
<section id="contrib-mapbuilder">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">mapbuilder</span></code><a class="headerlink" href="#contrib-mapbuilder" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Cloud_Keeper 2016</em></p>
<p>Build a game map from the drawing of a 2D ASCII map.</p>
<p><a class="reference internal" href="Contrib-Mapbuilder.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.grid.mapbuilder.html#evennia-contrib-grid-mapbuilder"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="in-game-python">
<h3>In-Game-Python<a class="headerlink" href="#in-game-python" title="Permalink to this headline"></a></h3>
<p><em>Vincent Le Geoff 2017</em></p>
<p>Allow Builders to add Python-scripted events to their objects (OBS-not for untrusted users!)</p>
<ul class="simple">
<li><p><a class="reference internal" href="A-voice-operated-elevator-using-events.html"><span class="doc std std-doc">A voice-operated elevator using events</span></a></p></li>
<li><p><a class="reference internal" href="Dialogues-in-events.html"><span class="doc std std-doc">Dialogues using events</span></a></p></li>
</ul>
<section id="contrib-simpledoor">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">simpledoor</span></code><a class="headerlink" href="#contrib-simpledoor" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch, 2016</em></p>
<p>A simple two-way exit that represents a door that can be opened and
closed from both sides. Can easily be expanded to make it lockable,
destroyable etc.</p>
<p><a class="reference internal" href="Contrib-Simpledoor.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.grid.simpledoor.html#evennia-contrib-grid-simpledoor"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="menu-builder">
<h3>Menu-builder<a class="headerlink" href="#menu-builder" title="Permalink to this headline"></a></h3>
<p>A tool for building using an in-game menu instead of the normal build commands. Meant to
be expanded for the needs of your game.</p>
<ul class="simple">
<li><p><a class="reference internal" href="Building-menus.html"><span class="doc std std-doc">Building Menus</span></a></p></li>
</ul>
<section id="contrib-slow-exit">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">slow_exit</span></code><a class="headerlink" href="#contrib-slow-exit" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch 2014</em></p>
<p>An example of an Exit-type that delays its traversal. This simulates
slow movement, common in many games. The contrib also
contains two commands, <code class="docutils literal notranslate"><span class="pre">setspeed</span></code> and <code class="docutils literal notranslate"><span class="pre">stop</span></code> for changing the movement speed
and abort an ongoing traversal, respectively.</p>
<p><a class="reference internal" href="Contrib-Slow-Exit.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.grid.slow_exit.html#evennia-contrib-grid-slow-exit"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="security-auditing">
<h3>Security/Auditing<a class="headerlink" href="#security-auditing" title="Permalink to this headline"></a></h3>
<p><em>Johhny 2018</em></p>
<p>Log server input/output for debug/security.</p>
<section id="contrib-wilderness">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">wilderness</span></code><a class="headerlink" href="#contrib-wilderness" title="Permalink to this headline"></a></h3>
<p><em>Contribution by titeuf87, 2017</em></p>
<p>This contrib provides a wilderness map without actually creating a large number
of rooms - as you move, you instead end up back in the same room but its description
changes. This means you can make huge areas with little database use as
long as the rooms are relatively similar (name/desc changing).</p>
<p><a class="reference internal" href="Contrib-Wilderness.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.grid.wilderness.html#evennia-contrib-grid-wilderness"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="tree-select">
<h3>Tree Select<a class="headerlink" href="#tree-select" title="Permalink to this headline"></a></h3>
<p><em>FlutterSprite 2017</em></p>
<p>A simple system for creating a branching EvMenu with selection options sourced from a single
multi-line string.</p>
<section id="contrib-xyzgrid">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">xyzgrid</span></code><a class="headerlink" href="#contrib-xyzgrid" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch 2021</em></p>
<p>Places Evennias game world on an xy (z being different maps) coordinate grid.
Grid is created and maintained externally by drawing and parsing 2D ASCII maps,
including teleports, map transitions and special markers to aid pathfinding.
Supports very fast shortest-route pathfinding on each map. Also includes a
fast view function for seeing only a limited number of steps away from your
current location (useful for displaying the grid as an in-game, updating map).</p>
<p><a class="reference internal" href="Contrib-XYZGrid.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.grid.xyzgrid.html#evennia-contrib-grid-xyzgrid"><span class="std std-ref">Browse the Code</span></a></p>
</section>
</section>
<hr class="docutils" />
<section id="snippets-and-config">
<h2>Snippets and config<a class="headerlink" href="#snippets-and-config" title="Permalink to this headline"></a></h2>
<p>Contribs meant to be used as part of other code, or as replacements for default settings.</p>
<section id="color-markups">
<h3>Color-markups<a class="headerlink" href="#color-markups" title="Permalink to this headline"></a></h3>
<p><em>Griatch, 2017</em></p>
<p>Alternative in-game color markups.</p>
<section id="rpg">
<h2>rpg<a class="headerlink" href="#rpg" title="Permalink to this headline"></a></h2>
<p><em>These are systems specifically related to roleplaying
and rule implementation like character traits, dice rolling and emoting.</em></p>
<section id="contrib-dice">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">dice</span></code><a class="headerlink" href="#contrib-dice" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch, 2012</em></p>
<p>A dice roller for any number and side of dice. Adds in-game dice rolling
(<code class="docutils literal notranslate"><span class="pre">roll</span> <span class="pre">2d10</span> <span class="pre">+</span> <span class="pre">1</span></code>) as well as conditionals (roll under/over/equal to a target)
and functions for rolling dice in code. Command also supports hidden or secret
rolls for use by a human game master.</p>
<p><a class="reference internal" href="Contrib-Dice.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.rpg.dice.html#evennia-contrib-rpg-dice"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="custom-gametime">
<h3>Custom gametime<a class="headerlink" href="#custom-gametime" title="Permalink to this headline"></a></h3>
<p><em>Griatch, vlgeoff 2017</em></p>
<p>Implements Evennias gametime module but for custom game world-specific calendars.</p>
<section id="contrib-health-bar">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">health_bar</span></code><a class="headerlink" href="#contrib-health-bar" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Tim Ashley Jenkins, 2017</em></p>
<p>The function provided in this module lets you easily display visual
bars or meters as a colorful bar instead of just a number. A “health bar”
is merely the most obvious use for this, but the bar is highly customizable
and can be used for any sort of appropriate data besides player health.</p>
<p><a class="reference internal" href="Contrib-Health-Bar.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.rpg.health_bar.html#evennia-contrib-rpg-health-bar"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="logins">
<h3>Logins<a class="headerlink" href="#logins" title="Permalink to this headline"></a></h3>
<section id="email-login">
<h4>Email login<a class="headerlink" href="#email-login" title="Permalink to this headline"></a></h4>
<p><em>Griatch 2012</em></p>
<p>A variant of the standard login system that requires an email to login rather then just name+password.</p>
<section id="contrib-rpsystem">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">rpsystem</span></code><a class="headerlink" href="#contrib-rpsystem" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch, 2015</em></p>
<p>A full roleplaying emote system. Short-descriptions and recognition (only
know people by their looks until you assign a name to them). Room poses. Masks/disguises
(hide your description). Speak directly in emote, with optional language obscuration
(words get garbled if you dont know the language, you can also have different languages
with different sounding garbling). Whispers can be partly overheard from a distance. A
very powerful in-emote reference system, for referencing and differentiate targets
(including objects).</p>
<p><a class="reference internal" href="Contrib-RPSystem.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.rpg.rpsystem.html#evennia-contrib-rpg-rpsystem"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="menu-login">
<h4>Menu login<a class="headerlink" href="#menu-login" title="Permalink to this headline"></a></h4>
<p><em>Griatch 2011, 2019, Vincent-lg 2016</em></p>
<p>A login system using menus asking for name/password rather than giving them as one command.</p>
<section id="contrib-traits">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">traits</span></code><a class="headerlink" href="#contrib-traits" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch 2020, based on code by Whitenoise and Ainneve contribs, 2014</em></p>
<p>A <code class="docutils literal notranslate"><span class="pre">Trait</span></code> represents a modifiable property on (usually) a Character. They can
be used to represent everything from attributes (str, agi etc) to skills
(hunting 10, swords 14 etc) and dynamically changing things like HP, XP etc.
Traits differ from normal Attributes in that they track their changes and limit
themselves to particular value-ranges. One can add/subtract from them easily and
they can even change dynamically at a particular rate (like you being poisoned or
healed).</p>
<p><a class="reference internal" href="Contrib-Traits.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.rpg.traits.html#evennia-contrib-rpg-traits"><span class="std std-ref">Browse the Code</span></a></p>
</section>
</section>
<section id="random-string-generator">
<h3>Random String Generator<a class="headerlink" href="#random-string-generator" title="Permalink to this headline"></a></h3>
<p><em>Vincent Le Goff 2017</em></p>
<p>Simple pseudo-random generator of strings with rules, avoiding repetitions.</p>
<section id="tutorials">
<h2>tutorials<a class="headerlink" href="#tutorials" title="Permalink to this headline"></a></h2>
<p><em>Helper resources specifically meant to teach a development concept or
to exemplify an Evennia system. Any extra resources tied to documentation
tutorials are found here. Also the home of the Tutorial World demo adventure.</em></p>
<section id="contrib-batchprocessor">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">batchprocessor</span></code><a class="headerlink" href="#contrib-batchprocessor" title="Permalink to this headline"></a></h3>
<p><em>Contibution by Griatch, 2012</em></p>
<p>Simple examples for the batch-processor. The batch processor is used for generating
in-game content from one or more static files. Files can be stored with version
control and then applied to the game to create content.</p>
<p><a class="reference internal" href="Contrib-Batchprocessor.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.tutorials.batchprocessor.html#evennia-contrib-tutorials-batchprocessor"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="unixcommand">
<h3>UnixCommand<a class="headerlink" href="#unixcommand" title="Permalink to this headline"></a></h3>
<p><em>Vincent Le Geoff 2017</em></p>
<p>Add commands with UNIX-style syntax.</p>
<section id="contrib-bodyfunctions">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">bodyfunctions</span></code><a class="headerlink" href="#contrib-bodyfunctions" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch, 2012</em></p>
<p>Example script for testing. This adds a simple timer that has your
character make small verbal observations at irregular intervals.</p>
<p><a class="reference internal" href="Contrib-Bodyfunctions.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.tutorials.bodyfunctions.html#evennia-contrib-tutorials-bodyfunctions"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="contrib-mirror">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">mirror</span></code><a class="headerlink" href="#contrib-mirror" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch, 2017</em></p>
<p>A simple mirror object to experiment with. It will respond to being looked at.</p>
<p><a class="reference internal" href="Contrib-Mirror.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.tutorials.mirror.html#evennia-contrib-tutorials-mirror"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="contrib-red-button">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">red_button</span></code><a class="headerlink" href="#contrib-red-button" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch, 2011</em></p>
<p>A red button that you can press to have an effect. This is a more advanced example
object with its own functionality and state tracking.</p>
<p><a class="reference internal" href="Contrib-Red-Button.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.tutorials.red_button.html#evennia-contrib-tutorials-red-button"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="contrib-talking-npc">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">talking_npc</span></code><a class="headerlink" href="#contrib-talking-npc" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch 2011. Updated by grungies1138, 2016</em></p>
<p>This is an example of a static NPC object capable of holding a simple menu-driven
conversation. Suitable for example as a quest giver or merchant.</p>
<p><a class="reference internal" href="Contrib-Talking-Npc.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.tutorials.talking_npc.html#evennia-contrib-tutorials-talking-npc"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="contrib-tutorial-world">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">tutorial_world</span></code><a class="headerlink" href="#contrib-tutorial-world" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Griatch 2011, 2015</em></p>
<p>A stand-alone tutorial area for an unmodified Evennia install.
Think of it as a sort of single-player adventure rather than a
full-fledged multi-player game world. The various rooms and objects
are designed to show off features of Evennia, not to be a
very challenging (nor long) gaming experience. As such its of course
only skimming the surface of what is possible. Taking this apart
is a great way to start learning the system.</p>
<p><a class="reference internal" href="Contrib-Tutorial-World.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.tutorials.tutorial_world.html#evennia-contrib-tutorials-tutorial-world"><span class="std std-ref">Browse the Code</span></a></p>
</section>
</section>
<hr class="docutils" />
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h2>
<p>Contribs not meant to be used as-is, but just as examples to learn from.</p>
<section id="gendersub">
<h3>GenderSub<a class="headerlink" href="#gendersub" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2015</em></p>
<p>Simple example (only) of storing gender on a character and access it in an emote with a custom marker.</p>
<section id="utils">
<h2>utils<a class="headerlink" href="#utils" title="Permalink to this headline"></a></h2>
<p><em>Miscellaneous, optional tools for manipulating text, auditing connections
and more.</em></p>
<section id="contrib-auditing">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">auditing</span></code><a class="headerlink" href="#contrib-auditing" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Johnny, 2017</em></p>
<p>Utility that taps and intercepts all data sent to/from clients and the
server and passes it to a callback of your choosing. This is intended for
quality assurance, post-incident investigations and debugging.</p>
<p><a class="reference internal" href="Contrib-Auditing.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.utils.auditing.html#evennia-contrib-utils-auditing"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="talking-npc">
<h3>Talking NPC<a class="headerlink" href="#talking-npc" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2011</em></p>
<p>A talking NPC object that offers a menu-driven conversation tree.</p>
<section id="contrib-fieldfill">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">fieldfill</span></code><a class="headerlink" href="#contrib-fieldfill" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Tim Ashley Jenkins, 2018</em></p>
<p>This module contains a function that generates an <code class="docutils literal notranslate"><span class="pre">EvMenu</span></code> for you - this
menu presents the player with a form of fields that can be filled
out in any order (e.g. for character generation or building). Each fields value can
be verified, with the function allowing easy checks for text and integer input,
minimum and maximum values / character lengths, or can even be verified by a custom
function. Once the form is submitted, the forms data is submitted as a dictionary
to any callable of your choice.</p>
<p><a class="reference internal" href="Contrib-Fieldfill.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.utils.fieldfill.html#evennia-contrib-utils-fieldfill"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="tutorial-examples">
<h3>Tutorial examples<a class="headerlink" href="#tutorial-examples" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2011, 2015</em></p>
<p>A folder of basic example objects, commands and scripts.</p>
<section id="contrib-random-string-generator">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">random_string_generator</span></code><a class="headerlink" href="#contrib-random-string-generator" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Vincent Le Goff (vlgeoff), 2017</em></p>
<p>This utility can be used to generate pseudo-random strings of information
with specific criteria. You could, for instance, use it to generate
phone numbers, license plate numbers, validation codes, in-game security
passwords and so on. The strings generated will be stored and wont be repeated.</p>
<p><a class="reference internal" href="Contrib-Random-String-Generator.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.utils.random_string_generator.html#evennia-contrib-utils-random-string-generator"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="the-tutorial-world">
<h3>The tutorial-world<a class="headerlink" href="#the-tutorial-world" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2011, 2015</em></p>
<p>The Evennia single-player sole quest. Made to be analyzed to learn.</p>
<ul class="simple">
<li><p><a class="reference internal" href="../Howto/Starting/Part1/Tutorial-World-Introduction.html"><span class="doc std std-doc">The tutorial world introduction</span></a></p></li>
</ul>
</section>
</section>
<hr class="docutils" />
<section id="full-game-systems">
<h2>Full game systems<a class="headerlink" href="#full-game-systems" title="Permalink to this headline"></a></h2>
<p>Full game-dir replacement systems.</p>
<section id="ainneve">
<h3>Ainneve<a class="headerlink" href="#ainneve" title="Permalink to this headline"></a></h3>
<p><em>Evennia community 2015-?</em></p>
<p>This is a community attempt to make an Evennia example game using good practices. It is also a good
place to jump in if you want to help in another project rather than run it alone. Development of this
has stalled a bit so we are looking for enthusiastic people to lead the charge.</p>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/evennia/ainneve">evennia/ainneve repository</a></p></li>
<li><p><a class="reference external" href="https://groups.google.com/g/evennia/c/48PMDirb7go/m/Z9EAuvXZn7UJ">Original discussion thread</a> (external link)</p></li>
</ul>
</section>
<section id="arxcode">
<h3>Arxcode<a class="headerlink" href="#arxcode" title="Permalink to this headline"></a></h3>
<p><em>Tehom 2019</em></p>
<p>Open source code release of the popular Evennia-based <a class="reference external" href="https://play.arxgame.org/">Arx, after the reckoning</a>.
This is a fantasy game with a focus on roleplay and code-supported political intrigue. This code-release
is maintained by Tehom in its own repository so bug reports should be directed there.</p>
<ul class="simple">
<li><p><a class="reference external" href="https://github.com/Arx-Game/arxcode">Arxcode repository on github</a></p></li>
<li><p><a class="reference external" href="https://github.com/Arx-Game/arxcode/issues">Arxcode issue tracker</a></p></li>
<li><p><a class="reference internal" href="Arxcode-installing-help.html"><span class="doc std std-doc">Arxcode installation help</span></a> - this may not always be fully up-to-date with
latest Evennia. Report your findings!</p></li>
</ul>
</section>
<section id="evscaperoom">
<h3>Evscaperoom<a class="headerlink" href="#evscaperoom" title="Permalink to this headline"></a></h3>
<p><em>Griatch 2019</em></p>
<p>A full engine for making multiplayer escape-rooms completely in code.
This is based on the 2019 MUD Game jam winner <em>Evscaperoom</em>.</p>
<ul class="simple">
<li><p><a class="reference internal" href="../api/evennia.contrib.evscaperoom.html#evennia-contrib-evscaperoom"><span class="std std-ref">contrib/evscaperoom</span></a> - game engine to make your own escape rooms.</p></li>
<li><p><a class="reference external" href="https://demo.evennia.com">https://demo.evennia.com</a> - a full installation of the original game can
be played by entering the <em>evscaperoom</em> exit in the first Limbo room.</p></li>
<li><p><a class="reference external" href="https://github.com/Griatch/evscaperoom">https://github.com/Griatch/evscaperoom</a> - the original games source code (warning for spoilers if you
want to solve the puzzles and mystery yourself).</p></li>
</ul>
<section id="contrib-tree-select">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">tree_select</span></code><a class="headerlink" href="#contrib-tree-select" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Tim Ashley Jenkins, 2017</em></p>
<p>This utility allows you to create and initialize an entire branching EvMenu
instance from a multi-line string passed to one function.</p>
<p><a class="reference internal" href="Contrib-Tree-Select.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.utils.tree_select.html#evennia-contrib-utils-tree-select"><span class="std std-ref">Browse the Code</span></a></p>
<div class="toctree-wrapper compound">
</div>
<hr class="docutils" />
<p><small>This document page is auto-generated. Manual changes
will be overwritten.</small></p>
</section>
</section>
</section>
@ -358,67 +495,65 @@ want to solve the puzzles and mystery yourself).</p></li>
<script>$('#searchbox').show(0);</script>
<p><h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Contrib modules</a><ul>
<li><a class="reference internal" href="#character-related">Character-related</a><ul>
<li><a class="reference internal" href="#chargen">CharGen</a></li>
<li><a class="reference internal" href="#clothing">Clothing</a></li>
<li><a class="reference internal" href="#health-bar">Health Bar</a></li>
<li><a class="reference internal" href="#multidescer">Multidescer</a></li>
<li><a class="reference internal" href="#">Contribs</a><ul>
<li><a class="reference internal" href="#base-systems">base_systems</a><ul>
<li><a class="reference internal" href="#contrib-awsstorage">Contrib: <code class="docutils literal notranslate"><span class="pre">awsstorage</span></code></a></li>
<li><a class="reference internal" href="#contrib-building-menu">Contrib: <code class="docutils literal notranslate"><span class="pre">building_menu</span></code></a></li>
<li><a class="reference internal" href="#contrib-color-markups">Contrib: <code class="docutils literal notranslate"><span class="pre">color_markups</span></code></a></li>
<li><a class="reference internal" href="#contrib-custom-gametime">Contrib: <code class="docutils literal notranslate"><span class="pre">custom_gametime</span></code></a></li>
<li><a class="reference internal" href="#contrib-email-login">Contrib: <code class="docutils literal notranslate"><span class="pre">email_login</span></code></a></li>
<li><a class="reference internal" href="#contrib-ingame-python">Contrib: <code class="docutils literal notranslate"><span class="pre">ingame_python</span></code></a></li>
<li><a class="reference internal" href="#contrib-menu-login">Contrib: <code class="docutils literal notranslate"><span class="pre">menu_login</span></code></a></li>
<li><a class="reference internal" href="#contrib-mux-comms-cmds">Contrib: <code class="docutils literal notranslate"><span class="pre">mux_comms_cmds</span></code></a></li>
<li><a class="reference internal" href="#contrib-unixcommand">Contrib: <code class="docutils literal notranslate"><span class="pre">unixcommand</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#rooms-movement-and-grid">Rooms, movement and grid</a><ul>
<li><a class="reference internal" href="#xyzgrid">XYZGrid</a></li>
<li><a class="reference internal" href="#extended-room">Extended Room</a></li>
<li><a class="reference internal" href="#map-builder">Map Builder</a></li>
<li><a class="reference internal" href="#simple-door">Simple Door</a></li>
<li><a class="reference internal" href="#slow-exit">Slow exit</a></li>
<li><a class="reference internal" href="#wilderness">Wilderness</a></li>
<li><a class="reference internal" href="#full-systems">full_systems</a><ul>
<li><a class="reference internal" href="#contrib-evscaperoom">Contrib: <code class="docutils literal notranslate"><span class="pre">evscaperoom</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#roleplaying-and-rules">Roleplaying and rules</a><ul>
<li><a class="reference internal" href="#barter-system">Barter system</a></li>
<li><a class="reference internal" href="#crafting">Crafting</a></li>
<li><a class="reference internal" href="#dice">Dice</a></li>
<li><a class="reference internal" href="#mail">Mail</a></li>
<li><a class="reference internal" href="#puzzles">Puzzles</a></li>
<li><a class="reference internal" href="#rp-system">RP System</a></li>
<li><a class="reference internal" href="#rp-language">RP Language</a></li>
<li><a class="reference internal" href="#traits">Traits</a></li>
<li><a class="reference internal" href="#turnbattle">Turnbattle</a></li>
<li><a class="reference internal" href="#game-systems">game_systems</a><ul>
<li><a class="reference internal" href="#contrib-barter">Contrib: <code class="docutils literal notranslate"><span class="pre">barter</span></code></a></li>
<li><a class="reference internal" href="#contrib-clothing">Contrib: <code class="docutils literal notranslate"><span class="pre">clothing</span></code></a></li>
<li><a class="reference internal" href="#contrib-cooldowns">Contrib: <code class="docutils literal notranslate"><span class="pre">cooldowns</span></code></a></li>
<li><a class="reference internal" href="#contrib-crafting">Contrib: <code class="docutils literal notranslate"><span class="pre">crafting</span></code></a></li>
<li><a class="reference internal" href="#contrib-gendersub">Contrib: <code class="docutils literal notranslate"><span class="pre">gendersub</span></code></a></li>
<li><a class="reference internal" href="#contrib-mail">Contrib: <code class="docutils literal notranslate"><span class="pre">mail</span></code></a></li>
<li><a class="reference internal" href="#contrib-multidescer">Contrib: <code class="docutils literal notranslate"><span class="pre">multidescer</span></code></a></li>
<li><a class="reference internal" href="#contrib-puzzles">Contrib: <code class="docutils literal notranslate"><span class="pre">puzzles</span></code></a></li>
<li><a class="reference internal" href="#contrib-turnbattle">Contrib: <code class="docutils literal notranslate"><span class="pre">turnbattle</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#building-and-server-systems">Building and server systems</a><ul>
<li><a class="reference internal" href="#building-menu">Building menu</a></li>
<li><a class="reference internal" href="#field-fill">Field Fill</a></li>
<li><a class="reference internal" href="#in-game-python">In-Game-Python</a></li>
<li><a class="reference internal" href="#menu-builder">Menu-builder</a></li>
<li><a class="reference internal" href="#security-auditing">Security/Auditing</a></li>
<li><a class="reference internal" href="#tree-select">Tree Select</a></li>
<li><a class="reference internal" href="#grid">grid</a><ul>
<li><a class="reference internal" href="#contrib-extended-room">Contrib: <code class="docutils literal notranslate"><span class="pre">extended_room</span></code></a></li>
<li><a class="reference internal" href="#contrib-mapbuilder">Contrib: <code class="docutils literal notranslate"><span class="pre">mapbuilder</span></code></a></li>
<li><a class="reference internal" href="#contrib-simpledoor">Contrib: <code class="docutils literal notranslate"><span class="pre">simpledoor</span></code></a></li>
<li><a class="reference internal" href="#contrib-slow-exit">Contrib: <code class="docutils literal notranslate"><span class="pre">slow_exit</span></code></a></li>
<li><a class="reference internal" href="#contrib-wilderness">Contrib: <code class="docutils literal notranslate"><span class="pre">wilderness</span></code></a></li>
<li><a class="reference internal" href="#contrib-xyzgrid">Contrib: <code class="docutils literal notranslate"><span class="pre">xyzgrid</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#snippets-and-config">Snippets and config</a><ul>
<li><a class="reference internal" href="#color-markups">Color-markups</a></li>
<li><a class="reference internal" href="#custom-gametime">Custom gametime</a></li>
<li><a class="reference internal" href="#logins">Logins</a><ul>
<li><a class="reference internal" href="#email-login">Email login</a></li>
<li><a class="reference internal" href="#menu-login">Menu login</a></li>
<li><a class="reference internal" href="#rpg">rpg</a><ul>
<li><a class="reference internal" href="#contrib-dice">Contrib: <code class="docutils literal notranslate"><span class="pre">dice</span></code></a></li>
<li><a class="reference internal" href="#contrib-health-bar">Contrib: <code class="docutils literal notranslate"><span class="pre">health_bar</span></code></a></li>
<li><a class="reference internal" href="#contrib-rpsystem">Contrib: <code class="docutils literal notranslate"><span class="pre">rpsystem</span></code></a></li>
<li><a class="reference internal" href="#contrib-traits">Contrib: <code class="docutils literal notranslate"><span class="pre">traits</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#random-string-generator">Random String Generator</a></li>
<li><a class="reference internal" href="#unixcommand">UnixCommand</a></li>
<li><a class="reference internal" href="#tutorials">tutorials</a><ul>
<li><a class="reference internal" href="#contrib-batchprocessor">Contrib: <code class="docutils literal notranslate"><span class="pre">batchprocessor</span></code></a></li>
<li><a class="reference internal" href="#contrib-bodyfunctions">Contrib: <code class="docutils literal notranslate"><span class="pre">bodyfunctions</span></code></a></li>
<li><a class="reference internal" href="#contrib-mirror">Contrib: <code class="docutils literal notranslate"><span class="pre">mirror</span></code></a></li>
<li><a class="reference internal" href="#contrib-red-button">Contrib: <code class="docutils literal notranslate"><span class="pre">red_button</span></code></a></li>
<li><a class="reference internal" href="#contrib-talking-npc">Contrib: <code class="docutils literal notranslate"><span class="pre">talking_npc</span></code></a></li>
<li><a class="reference internal" href="#contrib-tutorial-world">Contrib: <code class="docutils literal notranslate"><span class="pre">tutorial_world</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#examples">Examples</a><ul>
<li><a class="reference internal" href="#gendersub">GenderSub</a></li>
<li><a class="reference internal" href="#talking-npc">Talking NPC</a></li>
<li><a class="reference internal" href="#tutorial-examples">Tutorial examples</a></li>
<li><a class="reference internal" href="#the-tutorial-world">The tutorial-world</a></li>
</ul>
</li>
<li><a class="reference internal" href="#full-game-systems">Full game systems</a><ul>
<li><a class="reference internal" href="#ainneve">Ainneve</a></li>
<li><a class="reference internal" href="#arxcode">Arxcode</a></li>
<li><a class="reference internal" href="#evscaperoom">Evscaperoom</a></li>
<li><a class="reference internal" href="#utils">utils</a><ul>
<li><a class="reference internal" href="#contrib-auditing">Contrib: <code class="docutils literal notranslate"><span class="pre">auditing</span></code></a></li>
<li><a class="reference internal" href="#contrib-fieldfill">Contrib: <code class="docutils literal notranslate"><span class="pre">fieldfill</span></code></a></li>
<li><a class="reference internal" href="#contrib-random-string-generator">Contrib: <code class="docutils literal notranslate"><span class="pre">random_string_generator</span></code></a></li>
<li><a class="reference internal" href="#contrib-tree-select">Contrib: <code class="docutils literal notranslate"><span class="pre">tree_select</span></code></a></li>
</ul>
</li>
</ul>
@ -429,8 +564,8 @@ want to solve the puzzles and mystery yourself).</p></li>
<p class="topless"><a href="../Coding/Coding-Overview.html"
title="previous chapter">Coding and development help</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Crafting.html"
title="next chapter">Crafting system contrib</a></p>
<p class="topless"><a href="../Links.html"
title="next chapter">Links</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
@ -468,13 +603,13 @@ want to solve the puzzles and mystery yourself).</p></li>
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="Crafting.html" title="Crafting system contrib"
<a href="../Links.html" title="Links"
>next</a> |</li>
<li class="right" >
<a href="../Coding/Coding-Overview.html" title="Coding and development help"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Contrib modules</a></li>
<li class="nav-item nav-item-this"><a href="">Contribs</a></li>
</ul>
<div class="develop">develop branch</div>
</div>

View file

@ -0,0 +1,192 @@
<!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>Puzzles System &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Puzzles System</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 class="tex2jax_ignore mathjax_ignore" id="puzzles-system">
<h1>Puzzles System<a class="headerlink" href="#puzzles-system" title="Permalink to this headline"></a></h1>
<p>Contribution by Henddher 2018</p>
<p>Intended for adventure-game style combination puzzles, such as combining fruits
and a blender to create a smoothie. Provides a typeclass and commands for objects
that can be combined (i.e. used together). Unlike the <code class="docutils literal notranslate"><span class="pre">crafting</span></code> contrib, each
puzzle is built from unique objects rather than using tags and a builder can create
the puzzle entirely from in-game.</p>
<p>A <code class="docutils literal notranslate"><span class="pre">Puzzle</span></code> is a recipe of what objects (aka parts) must be combined by a player so
a new set of objects (aka results) are automatically created.</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Add the <code class="docutils literal notranslate"><span class="pre">PuzzleSystemCmdSet</span></code> to all players (e.g. in their Character typeclass).</p>
<p>Alternatively (for quick testing):</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>py self.cmdset.add(&#39;evennia.contrib.game_systems.puzzles.PuzzleSystemCmdSet&#39;)
</pre></div>
</div>
</section>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<p>Consider this simple Puzzle:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>orange, mango, yogurt, blender = fruit smoothie
</pre></div>
</div>
<p>As a Builder:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>create/drop orange
create/drop mango
create/drop yogurt
create/drop blender
create/drop fruit smoothie
puzzle smoothie, orange, mango, yogurt, blender = fruit smoothie
...
Puzzle smoothie(#1234) created successfuly.
destroy/force orange, mango, yogurt, blender, fruit smoothie
armpuzzle #1234
Part orange is spawned at ...
Part mango is spawned at ...
....
Puzzle smoothie(#1234) has been armed successfully
</pre></div>
</div>
<p>As Player:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>use orange, mango, yogurt, blender
...
Genius, you blended all fruits to create a fruit smoothie!
</pre></div>
</div>
</section>
<section id="details">
<h2>Details<a class="headerlink" href="#details" title="Permalink to this headline"></a></h2>
<p>Puzzles are created from existing objects. The given
objects are introspected to create prototypes for the
puzzle parts and results. These prototypes become the
puzzle recipe. (See PuzzleRecipe and <code class="docutils literal notranslate"><span class="pre">puzzle</span></code>
command). Once the recipe is created, all parts and result
can be disposed (i.e. destroyed).</p>
<p>At a later time, a Builder or a Script can arm the puzzle
and spawn all puzzle parts in their respective
locations (See armpuzzle).</p>
<p>A regular player can collect the puzzle parts and combine
them (See use command). If player has specified
all pieces, the puzzle is considered solved and all
its puzzle parts are destroyed while the puzzle results
are spawened on their corresponding location.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/game_systems/puzzles/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Puzzles System</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#usage">Usage</a></li>
<li><a class="reference internal" href="#details">Details</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/Contribs/Contrib-Puzzles.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="Contrib-Puzzles.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Puzzles System</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,379 @@
<!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>Roleplaying base system for Evennia &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Roleplaying base system for Evennia</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 class="tex2jax_ignore mathjax_ignore" id="roleplaying-base-system-for-evennia">
<h1>Roleplaying base system for Evennia<a class="headerlink" href="#roleplaying-base-system-for-evennia" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch, 2015</p>
<p>A full roleplaying emote system. Short-descriptions and recognition (only
know people by their looks until you assign a name to them). Room poses. Masks/disguises
(hide your description). Speak directly in emote, with optional language obscuration
(words get garbled if you dont know the language, you can also have different languages
with different sounding garbling). Whispers can be partly overheard from a distance. A
very powerful in-emote reference system, for referencing and differentiate targets
(including objects).</p>
<p>The system contains of two main modules - the roleplaying emote system and the language
obscuration module.</p>
<section id="roleplaying-emotes">
<h2>Roleplaying emotes<a class="headerlink" href="#roleplaying-emotes" title="Permalink to this headline"></a></h2>
<p>This module contains the ContribRPObject, ContribRPRoom and
ContribRPCharacter typeclasses. If you inherit your
objects/rooms/character from these (or make them the defaults) from
these you will get the following features:</p>
<ul class="simple">
<li><p>Objects/Rooms will get the ability to have poses and will report
the poses of items inside them (the latter most useful for Rooms).</p></li>
<li><p>Characters will get poses and also sdescs (short descriptions)
that will be used instead of their keys. They will gain commands
for managing recognition (custom sdesc-replacement), masking
themselves as well as an advanced free-form emote command.</p></li>
</ul>
<p>In more detail, This RP base system introduces the following features
to a game, common to many RP-centric games:</p>
<ul class="simple">
<li><p>emote system using director stance emoting (names/sdescs).
This uses a customizable replacement noun (/me, &#64; etc) to
represent you in the emote. You can use /sdesc, /nick, /key or
/alias to reference objects in the room. You can use any
number of sdesc sub-parts to differentiate a local sdesc, or
use /1-sdesc etc to differentiate them. The emote also
identifies nested says and separates case.</p></li>
<li><p>sdesc obscuration of real character names for use in emotes
and in any referencing such as object.search(). This relies
on an SdescHandler <code class="docutils literal notranslate"><span class="pre">sdesc</span></code> being set on the Character and
makes use of a custom Character.get_display_name hook. If
sdesc is not set, the characters <code class="docutils literal notranslate"><span class="pre">key</span></code> is used instead. This
is particularly used in the emoting system.</p></li>
<li><p>recog system to assign your own nicknames to characters, can then
be used for referencing. The user may recog a user and assign
any personal nick to them. This will be shown in descriptions
and used to reference them. This is making use of the nick
functionality of Evennia.</p></li>
<li><p>masks to hide your identity (using a simple lock).</p></li>
<li><p>pose system to set room-persistent poses, visible in room
descriptions and when looking at the person/object. This is a
simple Attribute that modifies how the characters is viewed when
in a room as sdesc + pose.</p></li>
<li><p>in-emote says, including seamless integration with language
obscuration routine (such as contrib/rplanguage.py)</p></li>
</ul>
<section id="installation">
<h3>Installation:<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h3>
<p>Add <code class="docutils literal notranslate"><span class="pre">RPSystemCmdSet</span></code> from this module to your CharacterCmdSet:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># mygame/commands/default_cmdsets.py</span>
<span class="c1"># ...</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.rpg.rpsystem</span> <span class="kn">import</span> <span class="n">RPSystemCmdSet</span> <span class="o">&lt;---</span>
<span class="k">class</span> <span class="nc">CharacterCmdSet</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">CharacterCmdset</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="k">def</span> <span class="nf">at_cmdset_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">RPSystemCmdSet</span><span class="p">())</span> <span class="c1"># &lt;---</span>
</pre></div>
</div>
<p>You also need to make your Characters/Objects/Rooms inherit from
the typeclasses in this module:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/typeclasses/characters.py</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.rpg</span> <span class="kn">import</span> <span class="n">ContribRPCharacter</span>
<span class="k">class</span> <span class="nc">Character</span><span class="p">(</span><span class="n">ContribRPCharacter</span><span class="p">):</span>
<span class="c1"># ...</span>
</pre></div>
</div>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/typeclasses/objects.py</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.rpg</span> <span class="kn">import</span> <span class="n">ContribRPObject</span>
<span class="k">class</span> <span class="nc">Object</span><span class="p">(</span><span class="n">ContribRPObject</span><span class="p">):</span>
<span class="c1"># ...</span>
</pre></div>
</div>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/typeclasses/rooms.py</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.rpg</span> <span class="kn">import</span> <span class="n">ContribRPRoom</span>
<span class="k">class</span> <span class="nc">Room</span><span class="p">(</span><span class="n">ContribRPRoom</span><span class="p">):</span>
<span class="c1"># ...</span>
</pre></div>
</div>
<p>You will then need to reload the server and potentially force-reload
your objects, if you originally created them without this.</p>
<p>Example for your character:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&gt; type/reset/force me = typeclasses.characters.Character
</pre></div>
</div>
<p>Examples:</p>
<blockquote>
<div><p>look
Tavern
The tavern is full of nice people</p>
</div></blockquote>
<p><em>A tall man</em> is standing by the bar.</p>
<p>Above is an example of a player with an sdesc “a tall man”. It is also
an example of a static <em>pose</em>: The “standing by the bar” has been set
by the player of the tall man, so that people looking at him can tell
at a glance what is going on.</p>
<blockquote>
<div><p>emote /me looks at /Tall and says “Hello!”</p>
</div></blockquote>
<p>I see:
Griatch looks at Tall man and says “Hello”.
Tall man (assuming his name is Tom) sees:
The godlike figure looks at Tom and says “Hello”.</p>
<p>Note that by default, the case of the tag matters, so <code class="docutils literal notranslate"><span class="pre">/tall</span></code> will
lead to tall man while <code class="docutils literal notranslate"><span class="pre">/Tall</span></code> will become Tall man and /TALL
becomes /TALL MAN. If you dont want this behavior, you can pass
case_sensitive=False to the <code class="docutils literal notranslate"><span class="pre">send_emote</span></code> function.</p>
</section>
</section>
<section id="language-and-whisper-obfuscation-system">
<h2>Language and whisper obfuscation system<a class="headerlink" href="#language-and-whisper-obfuscation-system" title="Permalink to this headline"></a></h2>
<p>This module is intented to be used with an emoting system (such as
<code class="docutils literal notranslate"><span class="pre">contrib/rpg/rpsystem.py</span></code>). It offers the ability to obfuscate spoken words
in the game in various ways:</p>
<ul class="simple">
<li><p>Language: The language functionality defines a pseudo-language map
to any number of languages. The string will be obfuscated depending
on a scaling that (most likely) will be input as a weighted average of
the language skill of the speaker and listener.</p></li>
<li><p>Whisper: The whisper functionality will gradually “fade out” a
whisper along as scale 0-1, where the fading is based on gradually
removing sections of the whisper that is (supposedly) easier to
overhear (for example “s” sounds tend to be audible even when no other
meaning can be determined).</p></li>
</ul>
<section id="id1">
<h3>Installation<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h3>
<p>This module adds no new commands; embed it in your say/emote/whisper commands.</p>
</section>
<section id="usage">
<h3>Usage:<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h3>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib</span> <span class="kn">import</span> <span class="n">rplanguage</span>
<span class="c1"># need to be done once, here we create the &quot;default&quot; lang</span>
<span class="n">rplanguage</span><span class="o">.</span><span class="n">add_language</span><span class="p">()</span>
<span class="n">say</span> <span class="o">=</span> <span class="s2">&quot;This is me talking.&quot;</span>
<span class="n">whisper</span> <span class="o">=</span> <span class="s2">&quot;This is me whispering.</span>
<span class="nb">print</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_language</span><span class="p">(</span><span class="n">say</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
<span class="o">&lt;&lt;&lt;</span> <span class="s2">&quot;This is me talking.&quot;</span>
<span class="nb">print</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_language</span><span class="p">(</span><span class="n">say</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="o">&lt;&lt;&lt;</span> <span class="s2">&quot;This is me byngyry.&quot;</span>
<span class="nb">print</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_language</span><span class="p">(</span><span class="n">say</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
<span class="o">&lt;&lt;&lt;</span> <span class="s2">&quot;Daly ly sy byngyry.&quot;</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_whisper</span><span class="p">(</span><span class="n">whisper</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
<span class="o">&lt;&lt;&lt;</span> <span class="s2">&quot;This is me whispering&quot;</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_whisper</span><span class="p">(</span><span class="n">whisper</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.2</span><span class="p">)</span>
<span class="o">&lt;&lt;&lt;</span> <span class="s2">&quot;This is m- whisp-ring&quot;</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_whisper</span><span class="p">(</span><span class="n">whisper</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="o">&lt;&lt;&lt;</span> <span class="s2">&quot;---s -s -- ---s------&quot;</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_whisper</span><span class="p">(</span><span class="n">whisper</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.7</span><span class="p">)</span>
<span class="o">&lt;&lt;&lt;</span> <span class="s2">&quot;---- -- -- ----------&quot;</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_whisper</span><span class="p">(</span><span class="n">whisper</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
<span class="o">&lt;&lt;&lt;</span> <span class="s2">&quot;...&quot;</span>
</pre></div>
</div>
<p>To set up new languages, import and use the <code class="docutils literal notranslate"><span class="pre">add_language()</span></code>
helper method in this module. This allows you to customize the
“feel” of the semi-random language you are creating. Especially
the <code class="docutils literal notranslate"><span class="pre">word_length_variance</span></code> helps vary the length of translated
words compared to the original and can help change the “feel” for
the language you are creating. You can also add your own
dictionary and “fix” random words for a list of input words.</p>
<p>Below is an example of “elvish”, using “rounder” vowels and sounds:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># vowel/consonant grammar possibilities</span>
<span class="n">grammar</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;v vv vvc vcc vvcc cvvc vccv vvccv vcvccv vcvcvcc vvccvvcc &quot;</span>
<span class="s2">&quot;vcvvccvvc cvcvvcvvcc vcvcvvccvcvv&quot;</span><span class="p">)</span>
<span class="c1"># all not in this group is considered a consonant</span>
<span class="n">vowels</span> <span class="o">=</span> <span class="s2">&quot;eaoiuy&quot;</span>
<span class="c1"># you need a representative of all of the minimal grammars here, so if a</span>
<span class="c1"># grammar v exists, there must be atleast one phoneme available with only</span>
<span class="c1"># one vowel in it</span>
<span class="n">phonemes</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;oi oh ee ae aa eh ah ao aw ay er ey ow ia ih iy &quot;</span>
<span class="s2">&quot;oy ua uh uw y p b t d f v t dh s z sh zh ch jh k &quot;</span>
<span class="s2">&quot;ng g m n l r w&quot;</span><span class="p">)</span>
<span class="c1"># how much the translation varies in length compared to the original. 0 is</span>
<span class="c1"># smallest, higher values give ever bigger randomness (including removing</span>
<span class="c1"># short words entirely)</span>
<span class="n">word_length_variance</span> <span class="o">=</span> <span class="mi">1</span>
<span class="c1"># if a proper noun (word starting with capitalized letter) should be</span>
<span class="c1"># translated or not. If not (default) it means e.g. names will remain</span>
<span class="c1"># unchanged across languages.</span>
<span class="n">noun_translate</span> <span class="o">=</span> <span class="kc">False</span>
<span class="c1"># all proper nouns (words starting with a capital letter not at the beginning</span>
<span class="c1"># of a sentence) can have either a postfix or -prefix added at all times</span>
<span class="n">noun_postfix</span> <span class="o">=</span> <span class="s2">&quot;&#39;la&quot;</span>
<span class="c1"># words in dict will always be translated this way. The &#39;auto_translations&#39;</span>
<span class="c1"># is instead a list or filename to file with words to use to help build a</span>
<span class="c1"># bigger dictionary by creating random translations of each word in the</span>
<span class="c1"># list *once* and saving the result for subsequent use.</span>
<span class="n">manual_translations</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;the&quot;</span><span class="p">:</span><span class="s2">&quot;y&#39;e&quot;</span><span class="p">,</span> <span class="s2">&quot;we&quot;</span><span class="p">:</span><span class="s2">&quot;uyi&quot;</span><span class="p">,</span> <span class="s2">&quot;she&quot;</span><span class="p">:</span><span class="s2">&quot;semi&quot;</span><span class="p">,</span> <span class="s2">&quot;he&quot;</span><span class="p">:</span><span class="s2">&quot;emi&quot;</span><span class="p">,</span>
<span class="s2">&quot;you&quot;</span><span class="p">:</span> <span class="s2">&quot;do&quot;</span><span class="p">,</span> <span class="s1">&#39;me&#39;</span><span class="p">:</span><span class="s1">&#39;mi&#39;</span><span class="p">,</span><span class="s1">&#39;i&#39;</span><span class="p">:</span><span class="s1">&#39;me&#39;</span><span class="p">,</span> <span class="s1">&#39;be&#39;</span><span class="p">:</span><span class="s2">&quot;hy&#39;e&quot;</span><span class="p">,</span> <span class="s1">&#39;and&#39;</span><span class="p">:</span><span class="s1">&#39;y&#39;</span><span class="p">}</span>
<span class="n">rplanguage</span><span class="o">.</span><span class="n">add_language</span><span class="p">(</span><span class="n">key</span><span class="o">=</span><span class="s2">&quot;elvish&quot;</span><span class="p">,</span> <span class="n">phonemes</span><span class="o">=</span><span class="n">phonemes</span><span class="p">,</span> <span class="n">grammar</span><span class="o">=</span><span class="n">grammar</span><span class="p">,</span>
<span class="n">word_length_variance</span><span class="o">=</span><span class="n">word_length_variance</span><span class="p">,</span>
<span class="n">noun_translate</span><span class="o">=</span><span class="n">noun_translate</span><span class="p">,</span>
<span class="n">noun_postfix</span><span class="o">=</span><span class="n">noun_postfix</span><span class="p">,</span> <span class="n">vowels</span><span class="o">=</span><span class="n">vowels</span><span class="p">,</span>
<span class="n">manual_translations</span><span class="o">=</span><span class="n">manual_translations</span><span class="p">,</span>
<span class="n">auto_translations</span><span class="o">=</span><span class="s2">&quot;my_word_file.txt&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>This will produce a decicively more “rounded” and “soft” language than the
default one. The few <code class="docutils literal notranslate"><span class="pre">manual_translations</span></code> also make sure to make it at least
look superficially “reasonable”.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">auto_translations</span></code> keyword is useful, this accepts either a
list or a path to a text-file (with one word per line). This listing
of words is used to fix translations for those words according to the
grammatical rules. These translations are stored persistently as long as the
language exists.</p>
<p>This allows to quickly build a large corpus of translated words
that never change. This produces a language that seem moderately
consistent, since words like the will always be translated to the same thing.
The disadvantage (or advantage, depending on your game) is that players can
end up learn what words mean even if their characters dont know the
langauge.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/rpg/rpsystem/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</section>
</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="#">Roleplaying base system for Evennia</a><ul>
<li><a class="reference internal" href="#roleplaying-emotes">Roleplaying emotes</a><ul>
<li><a class="reference internal" href="#installation">Installation:</a></li>
</ul>
</li>
<li><a class="reference internal" href="#language-and-whisper-obfuscation-system">Language and whisper obfuscation system</a><ul>
<li><a class="reference internal" href="#id1">Installation</a></li>
<li><a class="reference internal" href="#usage">Usage:</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-RPSystem.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="Contrib-RPSystem.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Roleplaying base system for Evennia</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,179 @@
<!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>Pseudo-random generator and registry &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Pseudo-random generator and registry</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 class="tex2jax_ignore mathjax_ignore" id="pseudo-random-generator-and-registry">
<h1>Pseudo-random generator and registry<a class="headerlink" href="#pseudo-random-generator-and-registry" title="Permalink to this headline"></a></h1>
<p>Contribution by Vincent Le Goff (vlgeoff), 2017</p>
<p>This utility can be used to generate pseudo-random strings of information
with specific criteria. You could, for instance, use it to generate
phone numbers, license plate numbers, validation codes, in-game security
passwords and so on. The strings generated will be stored and wont be repeated.</p>
<section id="usage-example">
<h2>Usage Example<a class="headerlink" href="#usage-example" title="Permalink to this headline"></a></h2>
<p>Heres a very simple example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>
<span class="kn">from</span> <span class="nn">evennia.contrib.utils.random_string_generator</span> <span class="kn">import</span> <span class="n">RandomStringGenerator</span>
<span class="c1"># Create a generator for phone numbers</span>
<span class="n">phone_generator</span> <span class="o">=</span> <span class="n">RandomStringGenerator</span><span class="p">(</span><span class="s2">&quot;phone number&quot;</span><span class="p">,</span> <span class="sa">r</span><span class="s2">&quot;555-[0-9]</span><span class="si">{3}</span><span class="s2">-[0-9]</span><span class="si">{4}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="c1"># Generate a phone number (555-XXX-XXXX with X as numbers)</span>
<span class="n">number</span> <span class="o">=</span> <span class="n">phone_generator</span><span class="o">.</span><span class="n">get</span><span class="p">()</span>
<span class="c1"># `number` will contain something like: &quot;555-981-2207&quot;</span>
<span class="c1"># If you call `phone_generator.get`, it won&#39;t give the same anymore.phone_generator.all()</span>
<span class="c1"># Will return a list of all currently-used phone numbers</span>
<span class="n">phone_generator</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="s2">&quot;555-981-2207&quot;</span><span class="p">)</span>
<span class="c1"># The number can be generated again</span>
</pre></div>
</div>
</section>
<section id="importing">
<h2>Importing<a class="headerlink" href="#importing" title="Permalink to this headline"></a></h2>
<ol class="simple">
<li><p>Import the <code class="docutils literal notranslate"><span class="pre">RandomStringGenerator</span></code> class from the contrib.</p></li>
<li><p>Create an instance of this class taking two arguments:</p>
<ul class="simple">
<li><p>The name of the gemerator (like “phone number”, “license plate”…).</p></li>
<li><p>The regular expression representing the expected results.</p></li>
</ul>
</li>
<li><p>Use the generators <code class="docutils literal notranslate"><span class="pre">all</span></code>, <code class="docutils literal notranslate"><span class="pre">get</span></code> and <code class="docutils literal notranslate"><span class="pre">remove</span></code> methods as shown above.</p></li>
</ol>
<p>To understand how to read and create regular expressions, you can refer to
<a class="reference external" href="https://docs.python.org/2/library/re.html">the documentation on the re module</a>.
Some examples of regular expressions you could use:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">r&quot;555-\d{3}-\d{4}&quot;</span></code>: 555, a dash, 3 digits, another dash, 4 digits.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">r&quot;[0-9]{3}[A-Z][0-9]{3}&quot;</span></code>: 3 digits, a capital letter, 3 digits.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">r&quot;[A-Za-z0-9]{8,15}&quot;</span></code>: between 8 and 15 letters and digits.</p></li>
<li><p></p></li>
</ul>
<p>Behind the scenes, a script is created to store the generated information
for a single generator. The <code class="docutils literal notranslate"><span class="pre">RandomStringGenerator</span></code> object will also
read the regular expression you give to it to see what information is
required (letters, digits, a more restricted class, simple characters…)…
More complex regular expressions (with branches for instance) might not be
available.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/utils/random_string_generator/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Pseudo-random generator and registry</a><ul>
<li><a class="reference internal" href="#usage-example">Usage Example</a></li>
<li><a class="reference internal" href="#importing">Importing</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/Contribs/Contrib-Random-String-Generator.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="Contrib-Random-String-Generator.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Pseudo-random generator and registry</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,152 @@
<!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>Red Button example &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Red Button example</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 class="tex2jax_ignore mathjax_ignore" id="red-button-example">
<h1>Red Button example<a class="headerlink" href="#red-button-example" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch, 2011</p>
<p>A red button that you can press to have an effect. This is a more advanced example
object with its own functionality and state tracking.</p>
<p>Create the button with</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>create/drop button:tutorials.red_button.RedButton
</pre></div>
</div>
<p>Note that you must drop the button before you can see its messages! Its
imperative that you press the red button. You know you want to.</p>
<p>Use <code class="docutils literal notranslate"><span class="pre">del</span> <span class="pre">button</span></code> to destroy/stop the button when you are done playing.</p>
<section id="technical">
<h2>Technical<a class="headerlink" href="#technical" title="Permalink to this headline"></a></h2>
<p>The buttons functionality is controlled by CmdSets that gets added and removed
depending on the state the button is in.</p>
<ul class="simple">
<li><p>Lid-closed state: In this state the button is covered by a glass cover and
trying to push it will fail. You can nudge, smash or open the lid.</p></li>
<li><p>Lid-open state: In this state the lid is open but will close again after a
certain time. Using push now will press the button and trigger the
Blind-state.</p></li>
<li><p>Blind-state: In this mode you are blinded by a bright flash. This will affect
your normal commands like look and help until the blindness wears off after
a certain time.</p></li>
</ul>
<p>Timers are handled by persistent delays on the button. These are examples of
<code class="docutils literal notranslate"><span class="pre">evennia.utils.utils.delay</span></code> calls that wait a certain time before calling a
method - such as when closing the lid and un-blinding a character.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/tutorials/red_button/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Red Button example</a><ul>
<li><a class="reference internal" href="#technical">Technical</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/Contribs/Contrib-Red-Button.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="Contrib-Red-Button.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Red Button example</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,166 @@
<!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>SimpleDoor &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">SimpleDoor</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 class="tex2jax_ignore mathjax_ignore" id="simpledoor">
<h1>SimpleDoor<a class="headerlink" href="#simpledoor" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch, 2016</p>
<p>A simple two-way exit that represents a door that can be opened and
closed from both sides. Can easily be expanded to make it lockable,
destroyable etc.</p>
<p>Note that the simpledoor is based on Evennia locks, so it will
not work for a superuser (which bypasses all locks). The superuser
will always appear to be able to close/open the door over and over
without the locks stopping you. To use the door, use <code class="docutils literal notranslate"><span class="pre">quell</span></code> or a
non-superuser account.</p>
<section id="installation">
<h2>Installation:<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Import <code class="docutils literal notranslate"><span class="pre">SimpleDoorCmdSet</span></code> from this module into <code class="docutils literal notranslate"><span class="pre">mygame/commands/default_cmdsets</span></code>
and add it to your <code class="docutils literal notranslate"><span class="pre">CharacterCmdSet</span></code>:</p>
<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">evennia.contrib.grid</span> <span class="kn">import</span> <span class="n">simpledoor</span> <span class="o">&lt;---</span>
<span class="k">class</span> <span class="nc">CharacterCmdSet</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">CharacterCmdSet</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="k">def</span> <span class="nf">at_cmdset_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">simpledoor</span><span class="o">.</span><span class="n">SimpleDoorCmdSet</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="usage">
<h2>Usage:<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<p>To try it out, <code class="docutils literal notranslate"><span class="pre">dig</span></code> a new room and then use the (overloaded) <code class="docutils literal notranslate"><span class="pre">&#64;open</span></code>
commmand to open a new doorway to it like this:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>@open doorway:contrib.grid.simpledoor.SimpleDoor = otherroom
open doorway
close doorway
</pre></div>
</div>
<p>Note: This uses locks, so if you are a superuser you will not be blocked by
a locked door - <code class="docutils literal notranslate"><span class="pre">quell</span></code> yourself, if so. Normal users will find that they
cannot pass through either side of the door once its closed from the other
side.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/grid/simpledoor/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">SimpleDoor</a><ul>
<li><a class="reference internal" href="#installation">Installation:</a></li>
<li><a class="reference internal" href="#usage">Usage:</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/Contribs/Contrib-Simpledoor.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="Contrib-Simpledoor.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">SimpleDoor</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,178 @@
<!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>Slow Exit &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Slow Exit</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 class="tex2jax_ignore mathjax_ignore" id="slow-exit">
<h1>Slow Exit<a class="headerlink" href="#slow-exit" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch 2014</p>
<p>An example of an Exit-type that delays its traversal. This simulates
slow movement, common in many games. The contrib also
contains two commands, <code class="docutils literal notranslate"><span class="pre">setspeed</span></code> and <code class="docutils literal notranslate"><span class="pre">stop</span></code> for changing the movement speed
and abort an ongoing traversal, respectively.</p>
<section id="installation">
<h2>Installation:<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>To try out an exit of this type, you could connect two existing rooms
using something like this:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>@open north:contrib.grid.slow_exit.SlowExit = &lt;destination&gt;
</pre></div>
</div>
<p>To make this your new default exit, modify <code class="docutils literal notranslate"><span class="pre">mygame/typeclasses/exits.py</span></code>
to import this module and change the default <code class="docutils literal notranslate"><span class="pre">Exit</span></code> class to inherit
from <code class="docutils literal notranslate"><span class="pre">SlowExit</span></code> instead.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/typeclasses/exits.py</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.grid.slowexit</span> <span class="kn">import</span> <span class="n">SlowExit</span>
<span class="k">class</span> <span class="nc">Exit</span><span class="p">(</span><span class="n">SlowExit</span><span class="p">):</span>
<span class="c1"># ...</span>
</pre></div>
</div>
<p>To get the ability to change your speed and abort your movement, import</p>
<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">evennia.contrib.grid</span> <span class="kn">import</span> <span class="n">slow_exit</span> <span class="o">&lt;---</span>
<span class="k">class</span> <span class="nc">CharacterCmdSet</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">CharacterCmdSet</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="k">def</span> <span class="nf">at_cmdset_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># ...</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">slow_exit</span><span class="o">.</span><span class="n">SlowDoorCmdSet</span><span class="p">)</span> <span class="o">&lt;---</span>
</pre></div>
</div>
<p>simply import and add CmdSetSpeed and CmdStop from this module to your
default cmdset (see tutorials on how to do this if you are unsure).</p>
<p>To try out an exit of this type, you could connect two existing rooms using
something like this:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>@open north:contrib.grid.slow_exit.SlowExit = &lt;destination&gt;
</pre></div>
</div>
</section>
<section id="notes">
<h2>Notes:<a class="headerlink" href="#notes" title="Permalink to this headline"></a></h2>
<p>This implementation is efficient but not persistent; so incomplete
movement will be lost in a server reload. This is acceptable for most
game types - to simulate longer travel times (more than the couple of
seconds assumed here), a more persistent variant using Scripts or the
TickerHandler might be better.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/grid/slow_exit/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Slow Exit</a><ul>
<li><a class="reference internal" href="#installation">Installation:</a></li>
<li><a class="reference internal" href="#notes">Notes:</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/Contribs/Contrib-Slow-Exit.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="Contrib-Slow-Exit.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Slow Exit</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,140 @@
<!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>Talkative NPC example &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Talkative NPC example</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 class="tex2jax_ignore mathjax_ignore" id="talkative-npc-example">
<h1>Talkative NPC example<a class="headerlink" href="#talkative-npc-example" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch 2011. Updated by grungies1138, 2016</p>
<p>This is an example of a static NPC object capable of holding a simple menu-driven
conversation. Suitable for example as a quest giver or merchant.</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Create the NPC by creating an object of typeclass <code class="docutils literal notranslate"><span class="pre">contrib.tutorials.talking_npc.TalkingNPC</span></code>,
For example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>create/drop John : contrib.tutorials.talking_npc.TalkingNPC
</pre></div>
</div>
<p>Use <code class="docutils literal notranslate"><span class="pre">talk</span></code> in the same room as the NPC to start a conversation.</p>
<p>If there are many talkative npcs in the same room you will get to choose which
ones talk command to call (Evennia handles this automatically).</p>
<p>This use of EvMenu is very simplistic; See EvMenu for a lot more complex
possibilities.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/tutorials/talking_npc/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Talkative NPC example</a><ul>
<li><a class="reference internal" href="#installation">Installation</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/Contribs/Contrib-Talking-Npc.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="Contrib-Talking-Npc.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Talkative NPC example</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,550 @@
<!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>Traits &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Traits</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 class="tex2jax_ignore mathjax_ignore" id="traits">
<h1>Traits<a class="headerlink" href="#traits" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch 2020, based on code by Whitenoise and Ainneve contribs, 2014</p>
<p>A <code class="docutils literal notranslate"><span class="pre">Trait</span></code> represents a modifiable property on (usually) a Character. They can
be used to represent everything from attributes (str, agi etc) to skills
(hunting 10, swords 14 etc) and dynamically changing things like HP, XP etc.
Traits differ from normal Attributes in that they track their changes and limit
themselves to particular value-ranges. One can add/subtract from them easily and
they can even change dynamically at a particular rate (like you being poisoned or
healed).</p>
<p>Traits use Evennia Attributes under the hood, making them persistent (they survive
a server reload/reboot).</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Traits are always added to a typeclass, such as the Character class.</p>
<p>There are two ways to set up Traits on a typeclass. The first sets up the <code class="docutils literal notranslate"><span class="pre">TraitHandler</span></code>
as a property <code class="docutils literal notranslate"><span class="pre">.traits</span></code> on your class and you then access traits as e.g. <code class="docutils literal notranslate"><span class="pre">.traits.strength</span></code>.
The other alternative uses a <code class="docutils literal notranslate"><span class="pre">TraitProperty</span></code>, which makes the trait available directly
as e.g. <code class="docutils literal notranslate"><span class="pre">.strength</span></code>. This solution also uses the <code class="docutils literal notranslate"><span class="pre">TraitHandler</span></code>, but you dont need to
define it explicitly. You can combine both styles if you like.</p>
<section id="traits-with-traithandler">
<h3>Traits with TraitHandler<a class="headerlink" href="#traits-with-traithandler" title="Permalink to this headline"></a></h3>
<p>Heres an example for adding the TraitHandler to the Character class:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># mygame/typeclasses/objects.py</span>
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">DefaultCharacter</span>
<span class="kn">from</span> <span class="nn">evennia.utils</span> <span class="kn">import</span> <span class="n">lazy_property</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.rpg.traits</span> <span class="kn">import</span> <span class="n">TraitHandler</span>
<span class="c1"># ...</span>
<span class="k">class</span> <span class="nc">Character</span><span class="p">(</span><span class="n">DefaultCharacter</span><span class="p">):</span>
<span class="o">...</span>
<span class="nd">@lazy_property</span>
<span class="k">def</span> <span class="nf">traits</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># this adds the handler as .traits</span>
<span class="k">return</span> <span class="n">TraitHandler</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">at_object_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># (or wherever you want)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">&quot;str&quot;</span><span class="p">,</span> <span class="s2">&quot;Strength&quot;</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s2">&quot;static&quot;</span><span class="p">,</span> <span class="n">base</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">mod</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">&quot;hp&quot;</span><span class="p">,</span> <span class="s2">&quot;Health&quot;</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s2">&quot;gauge&quot;</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">&quot;hunting&quot;</span><span class="p">,</span> <span class="s2">&quot;Hunting Skill&quot;</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s2">&quot;counter&quot;</span><span class="p">,</span>
<span class="n">base</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">mod</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
</pre></div>
</div>
<p>When adding the trait, you supply the name of the property (<code class="docutils literal notranslate"><span class="pre">hunting</span></code>) along
with a more human-friendly name (“Hunting Skill”). The latter will show if you
print the trait etc. The <code class="docutils literal notranslate"><span class="pre">trait_type</span></code> is important, this specifies which type
of trait this is (see below).</p>
</section>
<section id="traitproperties">
<h3>TraitProperties<a class="headerlink" href="#traitproperties" title="Permalink to this headline"></a></h3>
<p>Using <code class="docutils literal notranslate"><span class="pre">TraitProperties</span></code> makes the trait available directly on the class, much like Django model
fields. The drawback is that you must make sure that the name of your Traits dont collide with any
other properties/methods on your class.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># mygame/typeclasses/objects.py</span>
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">DefaultObject</span>
<span class="kn">from</span> <span class="nn">evennia.utils</span> <span class="kn">import</span> <span class="n">lazy_property</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.rpg.traits</span> <span class="kn">import</span> <span class="n">TraitProperty</span>
<span class="c1"># ...</span>
<span class="k">class</span> <span class="nc">Object</span><span class="p">(</span><span class="n">DefaultObject</span><span class="p">):</span>
<span class="o">...</span>
<span class="n">strength</span> <span class="o">=</span> <span class="n">TraitProperty</span><span class="p">(</span><span class="s2">&quot;Strength&quot;</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s2">&quot;static&quot;</span><span class="p">,</span> <span class="n">base</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">mod</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="n">health</span> <span class="o">=</span> <span class="n">TraitProperty</span><span class="p">(</span><span class="s2">&quot;Health&quot;</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s2">&quot;gauge&quot;</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">base</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">mod</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="n">hunting</span> <span class="o">=</span> <span class="n">TraitProperty</span><span class="p">(</span><span class="s2">&quot;Hunting Skill&quot;</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s2">&quot;counter&quot;</span><span class="p">,</span> <span class="n">base</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">mod</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
</pre></div>
</div>
<blockquote>
<div><p>Note that the property-name will become the name of the trait and you dont supply <code class="docutils literal notranslate"><span class="pre">trait_key</span></code>
separately.</p>
</div></blockquote>
<blockquote>
<div><p>The <code class="docutils literal notranslate"><span class="pre">.traits</span></code> TraitHandler will still be created (its used under the
hood. But it will only be created when the TraitProperty has been accessed at least once,
so be careful if mixing the two styles. If you want to make sure <code class="docutils literal notranslate"><span class="pre">.traits</span></code> is always available,
add the <code class="docutils literal notranslate"><span class="pre">TraitHandler</span></code> manually like shown earlier - the <code class="docutils literal notranslate"><span class="pre">TraitProperty</span></code> will by default use
the same handler (<code class="docutils literal notranslate"><span class="pre">.traits</span></code>).</p>
</div></blockquote>
</section>
</section>
<section id="using-traits">
<h2>Using traits<a class="headerlink" href="#using-traits" title="Permalink to this headline"></a></h2>
<p>A trait is added to the traithandler (if you use <code class="docutils literal notranslate"><span class="pre">TraitProperty</span></code> the handler is just created under
the hood) after which one can access it as a property on the handler (similarly to how you can do
.db.attrname for Attributes in Evennia).</p>
<p>All traits have a <em>read-only</em> field <code class="docutils literal notranslate"><span class="pre">.value</span></code>. This is only used to read out results, you never
manipulate it directly (if you try, it will just remain unchanged). The <code class="docutils literal notranslate"><span class="pre">.value</span></code> is calculated based
on combining fields, like <code class="docutils literal notranslate"><span class="pre">.base</span></code> and <code class="docutils literal notranslate"><span class="pre">.mod</span></code> - which fields are available and how they relate to
each other depends on the trait type.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">strength</span><span class="o">.</span><span class="n">value</span>
<span class="mi">12</span> <span class="c1"># base + mod</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">strength</span><span class="o">.</span><span class="n">base</span> <span class="o">+=</span> <span class="mi">5</span>
<span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">strength</span><span class="o">.</span><span class="n">value</span>
<span class="mi">17</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">value</span>
<span class="mi">102</span> <span class="c1"># base + mod</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">base</span> <span class="o">-=</span> <span class="mi">200</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">value</span>
<span class="mi">0</span> <span class="c1"># min of 0</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">value</span>
<span class="mi">100</span>
<span class="c1"># you can also access properties like a dict</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="p">[</span><span class="s2">&quot;value&quot;</span><span class="p">]</span>
<span class="mi">100</span>
<span class="c1"># you can store arbitrary data persistently for easy reference</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">effect</span> <span class="o">=</span> <span class="s2">&quot;poisoned!&quot;</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">effect</span>
<span class="s2">&quot;poisoned!&quot;</span>
<span class="c1"># with TraitProperties:</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">value</span>
<span class="mi">12</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">strength</span><span class="o">.</span><span class="n">value</span> <span class="o">+=</span> <span class="mi">5</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">strength</span><span class="o">.</span><span class="n">value</span>
<span class="mi">17</span>
</pre></div>
</div>
</section>
<section id="trait-types">
<h2>Trait types<a class="headerlink" href="#trait-types" title="Permalink to this headline"></a></h2>
<p>All default traits have a read-only <code class="docutils literal notranslate"><span class="pre">.value</span></code> property that shows the relevant or
current value of the trait. Exactly what this means depends on the type of trait.</p>
<p>Traits can also be combined to do arithmetic with their .value, if both have a
compatible type.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span> <span class="n">trait1</span> <span class="o">+</span> <span class="n">trait2</span>
<span class="mi">54</span>
<span class="o">&gt;</span> <span class="n">trait1</span><span class="o">.</span><span class="n">value</span>
<span class="mi">3</span>
<span class="o">&gt;</span> <span class="n">trait1</span> <span class="o">+</span> <span class="mi">2</span>
<span class="o">&gt;</span> <span class="n">trait1</span><span class="o">.</span><span class="n">value</span>
<span class="mi">5</span>
</pre></div>
</div>
<p>Two numerical traits can also be compared (bigger-than etc), which is useful in
all sorts of rule-resolution.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>
<span class="k">if</span> <span class="n">trait1</span> <span class="o">&gt;</span> <span class="n">trait2</span><span class="p">:</span>
<span class="c1"># do stuff</span>
</pre></div>
</div>
</section>
<section id="static-trait">
<h2>Static trait<a class="headerlink" href="#static-trait" title="Permalink to this headline"></a></h2>
<p><code class="docutils literal notranslate"><span class="pre">value</span> <span class="pre">=</span> <span class="pre">base</span> <span class="pre">+</span> <span class="pre">mod</span></code></p>
<p>The static trait has a <code class="docutils literal notranslate"><span class="pre">base</span></code> value and an optional <code class="docutils literal notranslate"><span class="pre">mod</span></code>-ifier. A typical use
of a static trait would be a Strength stat or Skill value. That is, something
that varies slowly or not at all, and which may be modified in-place.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">&quot;str&quot;</span><span class="p">,</span> <span class="s2">&quot;Strength&quot;</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s2">&quot;static&quot;</span><span class="p">,</span> <span class="n">base</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">mod</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">mytrait</span><span class="o">.</span><span class="n">value</span>
<span class="mi">12</span> <span class="c1"># base + mod</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">mytrait</span><span class="o">.</span><span class="n">base</span> <span class="o">+=</span> <span class="mi">2</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">mytrait</span><span class="o">.</span><span class="n">mod</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">mytrait</span><span class="o">.</span><span class="n">value</span>
<span class="mi">15</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">mytrait</span><span class="o">.</span><span class="n">mod</span> <span class="o">=</span> <span class="mi">0</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">mytrait</span><span class="o">.</span><span class="n">value</span>
<span class="mi">12</span>
</pre></div>
</div>
<section id="counter">
<h3>Counter<a class="headerlink" href="#counter" title="Permalink to this headline"></a></h3>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>min/unset base base+mod max/unset
|--------------|--------|---------X--------X------------|
current value
= current
+ mod
</pre></div>
</div>
<p>A counter describes a value that can move from a base. The <code class="docutils literal notranslate"><span class="pre">.current</span></code> property
is the thing usually modified. It starts at the <code class="docutils literal notranslate"><span class="pre">.base</span></code>. One can also add a
modifier, which will both be added to the base and to current (forming
<code class="docutils literal notranslate"><span class="pre">.value</span></code>). The min/max of the range are optional, a boundary set to None will
remove it. A suggested use for a Counter Trait would be to track skill values.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">&quot;hunting&quot;</span><span class="p">,</span> <span class="s2">&quot;Hunting Skill&quot;</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s2">&quot;counter&quot;</span><span class="p">,</span>
<span class="n">base</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">mod</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">value</span>
<span class="mi">11</span> <span class="c1"># current starts at base + mod</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">current</span> <span class="o">+=</span> <span class="mi">10</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">value</span>
<span class="mi">21</span>
<span class="c1"># reset back to base+mod by deleting current</span>
<span class="o">&gt;</span> <span class="k">del</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">current</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">value</span>
<span class="mi">11</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="kc">None</span> <span class="c1"># removing upper bound</span>
<span class="c1"># for TraitProperties, pass the args/kwargs of traits.add() to the</span>
<span class="c1"># TraitProperty constructor instead.</span>
</pre></div>
</div>
<p>Counters have some extra properties:</p>
<section id="descs">
<h4>.descs<a class="headerlink" href="#descs" title="Permalink to this headline"></a></h4>
<p>The <code class="docutils literal notranslate"><span class="pre">descs</span></code> property is a dict <code class="docutils literal notranslate"><span class="pre">{upper_bound:text_description}</span></code>. This allows for easily
storing a more human-friendly description of the current value in the
interval. Here is an example for skill values between 0 and 10:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>{0: &quot;unskilled&quot;, 1: &quot;neophyte&quot;, 5: &quot;trained&quot;, 7: &quot;expert&quot;, 9: &quot;master&quot;}
</pre></div>
</div>
<p>The keys must be supplied from smallest to largest. Any values below the lowest and above the
highest description will be considered to be included in the closest description slot.
By calling <code class="docutils literal notranslate"><span class="pre">.desc()</span></code> on the Counter, you will get the text matching the current <code class="docutils literal notranslate"><span class="pre">value</span></code>.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># (could also have passed descs= to traits.add())</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">descs</span> <span class="o">=</span> <span class="p">{</span>
<span class="mi">0</span><span class="p">:</span> <span class="s2">&quot;unskilled&quot;</span><span class="p">,</span> <span class="mi">10</span><span class="p">:</span> <span class="s2">&quot;neophyte&quot;</span><span class="p">,</span> <span class="mi">50</span><span class="p">:</span> <span class="s2">&quot;trained&quot;</span><span class="p">,</span> <span class="mi">70</span><span class="p">:</span> <span class="s2">&quot;expert&quot;</span><span class="p">,</span> <span class="mi">90</span><span class="p">:</span> <span class="s2">&quot;master&quot;</span><span class="p">}</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">value</span>
<span class="mi">11</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">desc</span><span class="p">()</span>
<span class="s2">&quot;neophyte&quot;</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">current</span> <span class="o">+=</span> <span class="mi">60</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">value</span>
<span class="mi">71</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">desc</span><span class="p">()</span>
<span class="s2">&quot;expert&quot;</span>
</pre></div>
</div>
</section>
<section id="rate">
<h4>.rate<a class="headerlink" href="#rate" title="Permalink to this headline"></a></h4>
<p>The <code class="docutils literal notranslate"><span class="pre">rate</span></code> property defaults to 0. If set to a value different from 0, it
allows the trait to change value dynamically. This could be used for example
for an attribute that was temporarily lowered but will gradually (or abruptly)
recover after a certain time. The rate is given as change of the current
<code class="docutils literal notranslate"><span class="pre">.value</span></code> per-second, and this will still be restrained by min/max boundaries,
if those are set.</p>
<p>It is also possible to set a <code class="docutils literal notranslate"><span class="pre">.ratetarget</span></code>, for the auto-change to stop at
(rather than at the min/max boundaries). This allows the value to return to
a previous value.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">value</span>
<span class="mi">71</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">ratetarget</span> <span class="o">=</span> <span class="mi">71</span>
<span class="c1"># debuff hunting for some reason</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">current</span> <span class="o">-=</span> <span class="mi">30</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">value</span>
<span class="mi">41</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">rate</span> <span class="o">=</span> <span class="mi">1</span> <span class="c1"># 1/s increase</span>
<span class="c1"># Waiting 5s</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">value</span>
<span class="mi">46</span>
<span class="c1"># Waiting 8s</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">value</span>
<span class="mi">54</span>
<span class="c1"># Waiting 100s</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">value</span>
<span class="mi">71</span> <span class="c1"># we have stopped at the ratetarget</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">rate</span> <span class="o">=</span> <span class="mi">0</span> <span class="c1"># disable auto-change</span>
</pre></div>
</div>
<p>Note that when retrieving the <code class="docutils literal notranslate"><span class="pre">current</span></code>, the result will always be of the same
type as the <code class="docutils literal notranslate"><span class="pre">.base</span></code> even <code class="docutils literal notranslate"><span class="pre">rate</span></code> is a non-integer value. So if <code class="docutils literal notranslate"><span class="pre">base</span></code> is an <code class="docutils literal notranslate"><span class="pre">int</span></code>
(default)<code class="docutils literal notranslate"><span class="pre">,</span> <span class="pre">the</span> </code>current<code class="docutils literal notranslate"><span class="pre">value</span> <span class="pre">will</span> <span class="pre">also</span> <span class="pre">be</span> <span class="pre">rounded</span> <span class="pre">the</span> <span class="pre">closest</span> <span class="pre">full</span> <span class="pre">integer.</span> <span class="pre">If</span> <span class="pre">you</span> <span class="pre">want</span> <span class="pre">to</span> <span class="pre">see</span> <span class="pre">the</span> <span class="pre">exact</span></code>current<code class="docutils literal notranslate"><span class="pre">value,</span> <span class="pre">set</span></code>base<code class="docutils literal notranslate"><span class="pre">to</span> <span class="pre">a</span> <span class="pre">float</span> <span class="pre">-</span> <span class="pre">you</span> <span class="pre">will</span> <span class="pre">then</span> <span class="pre">need</span> <span class="pre">to</span> <span class="pre">use</span></code>round()` yourself on the result if you want integers.</p>
</section>
<section id="percent">
<h4>.percent()<a class="headerlink" href="#percent" title="Permalink to this headline"></a></h4>
<p>If both min and max are defined, the <code class="docutils literal notranslate"><span class="pre">.percent()</span></code> method of the trait will
return the value as a percentage.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">percent</span><span class="p">()</span>
<span class="s2">&quot;71.0%&quot;</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hunting</span><span class="o">.</span><span class="n">percent</span><span class="p">(</span><span class="n">formatting</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
<span class="mf">71.0</span>
</pre></div>
</div>
</section>
</section>
<section id="gauge">
<h3>Gauge<a class="headerlink" href="#gauge" title="Permalink to this headline"></a></h3>
<p>This emulates a [fuel-] gauge that empties from a base+mod value.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>min/0 max=base+mod
|-----------------------X---------------------------|
value
= current
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">.current</span></code> value will start from a full gauge. The .max property is
read-only and is set by <code class="docutils literal notranslate"><span class="pre">.base</span></code> + <code class="docutils literal notranslate"><span class="pre">.mod</span></code>. So contrary to a <code class="docutils literal notranslate"><span class="pre">Counter</span></code>, the
<code class="docutils literal notranslate"><span class="pre">.mod</span></code> modifier only applies to the max value of the gauge and not the current
value. The minimum bound defaults to 0 if not set explicitly.</p>
<p>This trait is useful for showing commonly depletable resources like health,
stamina and the like.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">&quot;hp&quot;</span><span class="p">,</span> <span class="s2">&quot;Health&quot;</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s2">&quot;gauge&quot;</span><span class="p">,</span> <span class="n">base</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">value</span> <span class="c1"># (or .current)</span>
<span class="mi">100</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">mod</span> <span class="o">=</span> <span class="mi">10</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">value</span>
<span class="mi">110</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">current</span> <span class="o">-=</span> <span class="mi">30</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">hp</span><span class="o">.</span><span class="n">value</span>
<span class="mi">80</span>
</pre></div>
</div>
<p>The Gauge trait is subclass of the Counter, so you have access to the same
methods and properties where they make sense. So gauges can also have a
<code class="docutils literal notranslate"><span class="pre">.descs</span></code> dict to describe the intervals in text, and can use <code class="docutils literal notranslate"><span class="pre">.percent()</span></code> to
get how filled it is as a percentage etc.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">.rate</span></code> is particularly relevant for gauges - useful for everything
from poison slowly draining your health, to resting gradually increasing it.</p>
</section>
<section id="trait">
<h3>Trait<a class="headerlink" href="#trait" title="Permalink to this headline"></a></h3>
<p>A single value of any type.</p>
<p>This is the base Trait, meant to inherit from if you want to invent
trait-types from scratch (most of the time youll probably inherit from some of
the more advanced trait-type classes though).</p>
<p>Unlike other Trait-types, the single <code class="docutils literal notranslate"><span class="pre">.value</span></code> property of the base <code class="docutils literal notranslate"><span class="pre">Trait</span></code> can
be editied. The value can hold any data that can be stored in an Attribute. If
its an integer/float you can do arithmetic with it, but otherwise this acts just
like a glorified Attribute.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">&quot;mytrait&quot;</span><span class="p">,</span> <span class="s2">&quot;My Trait&quot;</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s2">&quot;trait&quot;</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">mytrait</span><span class="o">.</span><span class="n">value</span>
<span class="mi">30</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">mytrait</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="s2">&quot;stringvalue&quot;</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">mytrait</span><span class="o">.</span><span class="n">value</span>
<span class="s2">&quot;stringvalue&quot;</span>
</pre></div>
</div>
</section>
</section>
<section id="expanding-with-your-own-traits">
<h2>Expanding with your own Traits<a class="headerlink" href="#expanding-with-your-own-traits" title="Permalink to this headline"></a></h2>
<p>A Trait is a class inhering from <code class="docutils literal notranslate"><span class="pre">evennia.contrib.rpg.traits.Trait</span></code> (or from one of
the existing Trait classes).</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in a file, say, &#39;mygame/world/traits.py&#39;</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.rpg.traits</span> <span class="kn">import</span> <span class="n">StaticTrait</span>
<span class="k">class</span> <span class="nc">RageTrait</span><span class="p">(</span><span class="n">StaticTrait</span><span class="p">):</span>
<span class="n">trait_type</span> <span class="o">=</span> <span class="s2">&quot;rage&quot;</span>
<span class="n">default_keys</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;rage&quot;</span><span class="p">:</span> <span class="mi">0</span>
<span class="p">}</span>
<span class="k">def</span> <span class="nf">berserk</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">mod</span> <span class="o">=</span> <span class="mi">100</span>
<span class="k">def</span> <span class="nf">sedate</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">mod</span> <span class="o">=</span> <span class="mi">0</span>
</pre></div>
</div>
<p>Above is an example custom-trait-class “rage” that stores a property “rage” on
itself, with a default value of 0. This has all the functionality of a Trait -
for example, if you do del on the <code class="docutils literal notranslate"><span class="pre">rage</span></code> property, it will be set back to its
default (0). Above we also added some helper methods.</p>
<p>To add your custom RageTrait to Evennia, add the following to your settings file
(assuming your class is in mygame/world/traits.py):</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>TRAIT_CLASS_PATHS = [&quot;world.traits.RageTrait&quot;]
</pre></div>
</div>
<p>Reload the server and you should now be able to use your trait:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">&quot;mood&quot;</span><span class="p">,</span> <span class="s2">&quot;A dark mood&quot;</span><span class="p">,</span> <span class="n">rage</span><span class="o">=</span><span class="mi">30</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s1">&#39;rage&#39;</span><span class="p">)</span>
<span class="o">&gt;</span> <span class="n">obj</span><span class="o">.</span><span class="n">traits</span><span class="o">.</span><span class="n">mood</span><span class="o">.</span><span class="n">rage</span>
<span class="mi">30</span>
<span class="c1"># as TraitProperty</span>
<span class="k">class</span> <span class="nc">Character</span><span class="p">(</span><span class="n">DefaultCharacter</span><span class="p">):</span>
<span class="n">rage</span> <span class="o">=</span> <span class="n">TraitProperty</span><span class="p">(</span><span class="s2">&quot;A dark mood&quot;</span><span class="p">,</span> <span class="n">rage</span><span class="o">=</span><span class="mi">30</span><span class="p">,</span> <span class="n">trait_type</span><span class="o">=</span><span class="s1">&#39;rage&#39;</span><span class="p">)</span>
</pre></div>
</div>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/rpg/traits/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Traits</a><ul>
<li><a class="reference internal" href="#installation">Installation</a><ul>
<li><a class="reference internal" href="#traits-with-traithandler">Traits with TraitHandler</a></li>
<li><a class="reference internal" href="#traitproperties">TraitProperties</a></li>
</ul>
</li>
<li><a class="reference internal" href="#using-traits">Using traits</a></li>
<li><a class="reference internal" href="#trait-types">Trait types</a></li>
<li><a class="reference internal" href="#static-trait">Static trait</a><ul>
<li><a class="reference internal" href="#counter">Counter</a><ul>
<li><a class="reference internal" href="#descs">.descs</a></li>
<li><a class="reference internal" href="#rate">.rate</a></li>
<li><a class="reference internal" href="#percent">.percent()</a></li>
</ul>
</li>
<li><a class="reference internal" href="#gauge">Gauge</a></li>
<li><a class="reference internal" href="#trait">Trait</a></li>
</ul>
</li>
<li><a class="reference internal" href="#expanding-with-your-own-traits">Expanding with your own Traits</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/Contribs/Contrib-Traits.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="Contrib-Traits.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Traits</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,268 @@
<!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>Easy menu selection tree &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Easy menu selection tree</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 class="tex2jax_ignore mathjax_ignore" id="easy-menu-selection-tree">
<h1>Easy menu selection tree<a class="headerlink" href="#easy-menu-selection-tree" title="Permalink to this headline"></a></h1>
<p>Contribution by Tim Ashley Jenkins, 2017</p>
<p>This utility allows you to create and initialize an entire branching EvMenu
instance from a multi-line string passed to one function.</p>
<blockquote>
<div><p>Note: Since the time this contrib was created, EvMenu itself got its own templating
language that has more features and is not compatible with the style used in
this contrib. Both can still be used in parallel.</p>
</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">EvMenu</span></code> is incredibly powerful and flexible but it can be a little overwhelming
and offers a lot of power that may not be needed for a simple multiple-choice menu.</p>
<p>This module provides a function, <code class="docutils literal notranslate"><span class="pre">init_tree_selection</span></code>, which acts as a frontend
for EvMenu, dynamically sourcing the options from a multi-line string you
provide. For example, if you define a string as such:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>TEST_MENU = &#39;&#39;&#39;Foo
Bar
Baz
Qux&#39;&#39;&#39;
</pre></div>
</div>
<p>And then use <code class="docutils literal notranslate"><span class="pre">TEST_MENU</span></code> as the treestr source when you call
<code class="docutils literal notranslate"><span class="pre">init_tree_selection</span></code> on a player:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>init_tree_selection(TEST_MENU, caller, callback)
</pre></div>
</div>
<p>The player will be presented with an EvMenu, like so:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>___________________________
Make your selection:
___________________________
Foo
Bar
Baz
Qux
</pre></div>
</div>
<p>Making a selection will pass the selections key to the specified callback as a
string along with the caller, as well as the index of the selection (the line
number on the source string) along with the source string for the tree itself.</p>
<p>In addition to specifying selections on the menu, you can also specify
categories. Categories are indicated by putting options below it preceded with
a - character. If a selection is a category, then choosing it will bring up a
new menu node, prompting the player to select between those options, or to go
back to the previous menu. In addition, categories are marked by default with a
[+] at the end of their key. Both this marker and the option to go back can be
disabled.</p>
<p>Categories can be nested in other categories as well - just go another -
deeper. You can do this as many times as you like. Theres no hard limit to the
number of categories you can go down.</p>
<p>For example, lets add some more options to our menu, turning Bar into a
category.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>TEST_MENU = &#39;&#39;&#39;Foo
Bar
-You&#39;ve got to know
--When to hold em
--When to fold em
--When to walk away
Baz
Qux&#39;&#39;&#39;
</pre></div>
</div>
<p>Now when we call the menu, we can see that Bar has become a category instead of a
selectable option.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>_______________________________
Make your selection:
_______________________________
Foo
Bar [+]
Baz
Qux
</pre></div>
</div>
<p>Note the [+] next to Bar. If we select Bar, itll show us the option listed
under it.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>________________________________________________________________
Bar
________________________________________________________________
You&#39;ve got to know [+]
&lt;&lt; Go Back: Return to the previous menu.
</pre></div>
</div>
<p>Just the one option, which is a category itself, and the option to go back,
which will take us back to the previous menu. Lets select Youve got to know.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>________________________________________________________________
You&#39;ve got to know
________________________________________________________________
When to hold em
When to fold em
When to walk away
&lt;&lt; Go Back: Return to the previous menu.
</pre></div>
</div>
<p>Now we see the three options listed under it, too. We can select one of them or
use Go Back to return to the Bar menu we were just at before. Its very
simple to make a branching tree of selections!</p>
<p>One last thing - you can set the descriptions for the various options simply by
adding a : character followed by the description to the options line. For
example, lets add a description to Baz in our menu:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>TEST_MENU = &#39;&#39;&#39;Foo
Bar
-You&#39;ve got to know
--When to hold em
--When to fold em
--When to walk away
Baz: Look at this one: the best option.
Qux&#39;&#39;&#39;
</pre></div>
</div>
<p>Now we see that the Baz option has a description attached thats separate from its key:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>_______________________________________________________________
Make your selection:
_______________________________________________________________
Foo
Bar [+]
Baz: Look at this one: the best option.
Qux
</pre></div>
</div>
<p>Once the player makes a selection - lets say, Foo - the menu will terminate
and call your specified callback with the selection, like so:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>callback(caller, TEST_MENU, 0, &quot;Foo&quot;)
</pre></div>
</div>
<p>The index of the selection is given along with a string containing the
selections key. That way, if you have two selections in the menu with the same
key, you can still differentiate between them.</p>
<p>And thats all there is to it! For simple branching-tree selections, using this
system is much easier than manually creating EvMenu nodes. It also makes
generating menus with dynamic options much easier - since the source of the menu
tree is just a string, you could easily generate that string procedurally before
passing it to the <code class="docutils literal notranslate"><span class="pre">init_tree_selection</span></code> function. For example, if a player casts
a spell or does an attack without specifying a target, instead of giving them an
error, you could present them with a list of valid targets to select by
generating a multi-line string of targets and passing it to
<code class="docutils literal notranslate"><span class="pre">init_tree_selection</span></code>, with the callable performing the maneuver once a
selection is made.</p>
<p>This selection system only works for simple branching trees - doing anything
really complicated like jumping between categories or prompting for arbitrary
input would still require a full EvMenu implementation. For simple selections,
however, Im sure you will find using this function to be much easier!</p>
<p>Included in this module is a sample menu and function which will let a player
change the color of their name - feel free to mess with it to get a feel for how
this system works by importing this module in your games <code class="docutils literal notranslate"><span class="pre">default_cmdsets.py</span></code>
module and adding <code class="docutils literal notranslate"><span class="pre">CmdNameColor</span></code> to your default characters command set.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/utils/tree_select/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Tree-Select.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="Contrib-Tree-Select.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Easy menu selection tree</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,166 @@
<!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>Turn based battle system framework &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Turn based battle system framework</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 class="tex2jax_ignore mathjax_ignore" id="turn-based-battle-system-framework">
<h1>Turn based battle system framework<a class="headerlink" href="#turn-based-battle-system-framework" title="Permalink to this headline"></a></h1>
<p>Contribution by Tim Ashley Jenkins, 2017</p>
<p>This is a framework for a simple turn-based combat system, similar
to those used in D&amp;D-style tabletop role playing games. It allows
any character to start a fight in a room, at which point initiative
is rolled and a turn order is established. Each participant in combat
has a limited time to decide their action for that turn (30 seconds by
default), and combat progresses through the turn order, looping through
the participants until the fight ends.</p>
<p>This folder contains multiple examples of how such a system can be
implemented and customized:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>tb_basic.py - The simplest system, which implements initiative and turn
order, attack rolls against defense values, and damage to hit
points. Only very basic game mechanics are included.
tb_equip.py - Adds weapons and armor to the basic implementation of
the battle system, including commands for wielding weapons and
donning armor, and modifiers to accuracy and damage based on
currently used equipment.
tb_items.py - Adds usable items and conditions/status effects, and gives
a lot of examples for each. Items can perform nearly any sort of
function, including healing, adding or curing conditions, or
being used to attack. Conditions affect a fighter&#39;s attributes
and options in combat and persist outside of fights, counting
down per turn in combat and in real time outside combat.
tb_magic.py - Adds a spellcasting system, allowing characters to cast
spells with a variety of effects by spending MP. Spells are
linked to functions, and as such can perform any sort of action
the developer can imagine - spells for attacking, healing and
conjuring objects are included as examples.
tb_range.py - Adds a system for abstract positioning and movement, which
tracks the distance between different characters and objects in
combat, as well as differentiates between melee and ranged
attacks.
</pre></div>
</div>
<p>This system is meant as a basic framework to start from, and is modeled
after the combat systems of popular tabletop role playing games rather than
the real-time battle systems that many MMOs and some MUDs use. As such, it
may be better suited to role-playing or more story-oriented games, or games
meant to closely emulate the experience of playing a tabletop RPG.</p>
<p>Each of these modules contains the full functionality of the battle system
with different customizations added in - the instructions to install each
one is contained in the module itself. Its recommended that you install
and test <code class="docutils literal notranslate"><span class="pre">tb_basic</span></code> first, so you can better understand how the other
modules expand on it and get a better idea of how you can customize the
system to your liking and integrate the subsystems presented here into
your own combat system.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/game_systems/turnbattle/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Turnbattle.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="Contrib-Turnbattle.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Turn based battle system framework</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,218 @@
<!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>Evennia Tutorial World &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Evennia Tutorial World</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 class="tex2jax_ignore mathjax_ignore" id="evennia-tutorial-world">
<h1>Evennia Tutorial World<a class="headerlink" href="#evennia-tutorial-world" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch 2011, 2015</p>
<p>A stand-alone tutorial area for an unmodified Evennia install.
Think of it as a sort of single-player adventure rather than a
full-fledged multi-player game world. The various rooms and objects
are designed to show off features of Evennia, not to be a
very challenging (nor long) gaming experience. As such its of course
only skimming the surface of what is possible. Taking this apart
is a great way to start learning the system.</p>
<p>The tutorial world also includes a game tutor menu example, exemplifying
Evmenu.</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Log in as superuser (#1), then run</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>batchcommand tutorials.tutorial_world.build
</pre></div>
</div>
<p>Wait a little while for building to complete and dont run the command
again even if its slow. This builds the world and connect it to Limbo
and creates a new exit <code class="docutils literal notranslate"><span class="pre">tutorial</span></code>.</p>
<p>If you are a superuser (User <code class="docutils literal notranslate"><span class="pre">#1</span></code>), use the <code class="docutils literal notranslate"><span class="pre">quell</span></code> command to play
the tutorial as intended.</p>
</section>
<section id="comments">
<h2>Comments<a class="headerlink" href="#comments" title="Permalink to this headline"></a></h2>
<p>The tutorial world is intended to be explored and analyzed. It will help you
learn how to accomplish some more advanced effects and might give some good
ideas along the way.</p>
<p>Its suggested you play it through (as a normal user, NOT as Superuser!) and
explore it a bit, then come back here and start looking into the (heavily
documented) build/source code to find out how things tick - thats the
“tutorial” in Tutorial world after all.</p>
<p>Please report bugs in the tutorial to the Evennia issue tracker.</p>
<p><strong>Spoilers below - dont read on unless you already played the
tutorial game</strong></p>
</section>
<section id="tutorial-world-room-map">
<h2>Tutorial World Room map<a class="headerlink" href="#tutorial-world-room-map" title="Permalink to this headline"></a></h2>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> ?
|
+---+----+ +-------------------+ +--------+ +--------+
| | | | |gate | |corner |
| cliff +----+ bridge +----+ +---+ |
| | | | | | | |
+---+---\+ +---------------+---+ +---+----+ +---+----+
| \ | | castle |
| \ +--------+ +----+---+ +---+----+ +---+----+
| \ |under- | |ledge | |along | |court- |
| \|ground +--+ | |wall +---+yard |
| \ | | | | | | |
| +------\-+ +--------+ +--------+ +---+----+
| \ |
++---------+ \ +--------+ +--------+ +---+----+
|intro | \ |cell | |trap | |temple |
o--+ | \| +----+ | | |
L | | \ | /| | | |
I +----+-----+ +--------+ / ---+-+-+-+ +---+----+
M | / | | | |
B +----+-----+ +--------+/ +--+-+-+---------+----+
O |outro | |tomb | |antechamber |
o--+ +----------+ | | |
| | | | | |
+----------+ +--------+ +---------------------+
</pre></div>
</div>
</section>
<section id="hints-notes">
<h2>Hints/Notes:<a class="headerlink" href="#hints-notes" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>o connections to/from Limbo</p></li>
<li><p>intro/outro areas are rooms that automatically sets/cleans the
Character of any settings assigned to it during the
tutorial game.</p></li>
<li><p>The Cliff is a good place to get an overview of the surroundings.</p></li>
<li><p>The Bridge may seem like a big room, but it is really only one room
with custom move commands to make it take longer to cross. You can
also fall off the bridge if you are unlucky or take your time to
take in the view too long.</p></li>
<li><p>In the Castle areas an aggressive mob is patrolling. It implements
rudimentary AI but packs quite a punch unless you have
found yourself a weapon that can harm it. Combat is only
possible once you find a weapon.</p></li>
<li><p>The Antechamber features a puzzle for finding the correct Grave
chamber.</p></li>
<li><p>The Cell is your reward if you fail in various ways. Finding a
way out of it is a small puzzle of its own.</p></li>
<li><p>The Tomb is a nice place to find a weapon that can hurt the
castle guardian. This is the goal of the tutorial.
Explore on, or take the exit to finish the tutorial.</p></li>
<li><p>? - look into the code if you cannot find this bonus area!</p></li>
</ul>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/tutorials/tutorial_world/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Evennia Tutorial World</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#comments">Comments</a></li>
<li><a class="reference internal" href="#tutorial-world-room-map">Tutorial World Room map</a></li>
<li><a class="reference internal" href="#hints-notes">Hints/Notes:</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/Contribs/Contrib-Tutorial-World.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="Contrib-Tutorial-World.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Evennia Tutorial World</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,184 @@
<!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>Unix-like Command style parent &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Unix-like Command style parent</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 class="tex2jax_ignore mathjax_ignore" id="unix-like-command-style-parent">
<h1>Unix-like Command style parent<a class="headerlink" href="#unix-like-command-style-parent" title="Permalink to this headline"></a></h1>
<p>Contribution by Vincent Le Geoff (vlgeoff), 2017</p>
<p>This module contains a command class with an alternate syntax parser implementing
Unix-style command syntax in-game. This means <code class="docutils literal notranslate"><span class="pre">--options</span></code>, positional arguments
and stuff like <code class="docutils literal notranslate"><span class="pre">-n</span> <span class="pre">10</span></code>. It might not the best syntax for the average player
but can be really useful for builders when they need to have a single command do
many things with many options. It uses the <code class="docutils literal notranslate"><span class="pre">ArgumentParser</span></code> from Pythons standard
library under the hood.</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>To use, inherit <code class="docutils literal notranslate"><span class="pre">UnixCommand</span></code> from this module from your own commands. You need
to override two methods:</p>
<ul class="simple">
<li><p>The <code class="docutils literal notranslate"><span class="pre">init_parser</span></code> method, which adds options to the parser. Note that you
should normally <em>not</em> override the normal <code class="docutils literal notranslate"><span class="pre">parse</span></code> method when inheriting from
<code class="docutils literal notranslate"><span class="pre">UnixCommand</span></code>.</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">func</span></code> method, called to execute the command once parsed (like any Command).</p></li>
</ul>
<p>Heres a short example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.base_systems.unixcommand</span> <span class="kn">import</span> <span class="n">UnixCommand</span>
<span class="k">class</span> <span class="nc">CmdPlant</span><span class="p">(</span><span class="n">UnixCommand</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;</span>
<span class="sd"> Plant a tree or plant.</span>
<span class="sd"> This command is used to plant something in the room you are in.</span>
<span class="sd"> Examples:</span>
<span class="sd"> plant orange -a 8</span>
<span class="sd"> plant strawberry --hidden</span>
<span class="sd"> plant potato --hidden --age 5</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">key</span> <span class="o">=</span> <span class="s2">&quot;plant&quot;</span>
<span class="k">def</span> <span class="nf">init_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="s2">&quot;Add the arguments to the parser.&quot;</span>
<span class="c1"># &#39;self.parser&#39; inherits `argparse.ArgumentParser`</span>
<span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;key&quot;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="s2">&quot;the key of the plant to be planted here&quot;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;-a&quot;</span><span class="p">,</span> <span class="s2">&quot;--age&quot;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span>
<span class="n">default</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s2">&quot;the age of the plant to be planted&quot;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">&quot;--hidden&quot;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">&quot;store_true&quot;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="s2">&quot;should the newly-planted plant be hidden to players?&quot;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="s2">&quot;func is called only if the parser succeeded.&quot;</span>
<span class="c1"># &#39;self.opts&#39; contains the parsed options</span>
<span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">opts</span><span class="o">.</span><span class="n">key</span>
<span class="n">age</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">opts</span><span class="o">.</span><span class="n">age</span>
<span class="n">hidden</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">opts</span><span class="o">.</span><span class="n">hidden</span>
<span class="bp">self</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;Going to plant &#39;</span><span class="si">{}</span><span class="s2">&#39;, age=</span><span class="si">{}</span><span class="s2">, hidden=</span><span class="si">{}</span><span class="s2">.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
<span class="n">key</span><span class="p">,</span> <span class="n">age</span><span class="p">,</span> <span class="n">hidden</span><span class="p">))</span>
</pre></div>
</div>
<p>To see the full power of argparse and the types of supported options, visit
<a class="reference external" href="https://docs.python.org/2/library/argparse.html">the documentation of argparse</a>.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/base_systems/unixcommand/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Unix-like Command style parent</a><ul>
<li><a class="reference internal" href="#installation">Installation</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/Contribs/Contrib-Unixcommand.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="Contrib-Unixcommand.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Unix-like Command style parent</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -0,0 +1,234 @@
<!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>Wilderness system &#8212; 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>
<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" />
</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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Wilderness system</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 class="tex2jax_ignore mathjax_ignore" id="wilderness-system">
<h1>Wilderness system<a class="headerlink" href="#wilderness-system" title="Permalink to this headline"></a></h1>
<p>Contribution by titeuf87, 2017</p>
<p>This contrib provides a wilderness map without actually creating a large number
of rooms - as you move, you instead end up back in the same room but its description
changes. This means you can make huge areas with little database use as
long as the rooms are relatively similar (name/desc changing).</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>This contrib does not provide any new commands. Instead the default <code class="docutils literal notranslate"><span class="pre">py</span></code> command
is used to call functions/classes in this contrib directly.</p>
</section>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<p>A wilderness map needs to created first. There can be different maps, all
with their own name. If no name is provided, then a default one is used. Internally,
the wilderness is stored as a Script with the name you specify. If you dont
specify the name, a script named “default” will be created and used.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>@py from evennia.contrib.grid import wilderness; wilderness.create_wilderness()
</pre></div>
</div>
<p>Once created, it is possible to move into that wilderness map:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>@py from evennia.contrib.grid import wilderness; wilderness.enter_wilderness(me)
</pre></div>
</div>
<p>All coordinates used by the wilderness map are in the format of <code class="docutils literal notranslate"><span class="pre">(x,</span> <span class="pre">y)</span></code>
tuples. x goes from left to right and y goes from bottom to top. So <code class="docutils literal notranslate"><span class="pre">(0,</span> <span class="pre">0)</span></code>
is the bottom left corner of the map.</p>
</section>
<section id="customisation">
<h2>Customisation<a class="headerlink" href="#customisation" title="Permalink to this headline"></a></h2>
<p>The defaults, while useable, are meant to be customised. When creating a
new wilderness map it is possible to give a “map provider”: this is a
python object that is smart enough to create the map.</p>
<p>The default provider, <code class="docutils literal notranslate"><span class="pre">WildernessMapProvider</span></code>, just creates a grid area that
is unlimited in size.
This <code class="docutils literal notranslate"><span class="pre">WildernessMapProvider</span></code> can be subclassed to create more interesting
maps and also to customize the room/exit typeclass used.</p>
<p>There is also no command that allows players to enter the wilderness. This
still needs to be added: it can be a command or an exit, depending on your
needs.</p>
</section>
<section id="example">
<h2>Example<a class="headerlink" href="#example" title="Permalink to this headline"></a></h2>
<p>To give an example of how to customize, we will create a very simple (and
small) wilderness map that is shaped like a pyramid. The map will be
provided as a string: a “.” symbol is a location we can walk on.</p>
<p>Lets create a file <code class="docutils literal notranslate"><span class="pre">world/pyramid.py</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># mygame/world/pyramid.py</span>
<span class="n">map_str</span> <span class="o">=</span> <span class="s1">&#39;&#39;&#39;</span>
<span class="s1"> .</span>
<span class="s1"> ...</span>
<span class="s1"> .....</span>
<span class="s1"> .......</span>
<span class="s1">&#39;&#39;&#39;</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.grid</span> <span class="kn">import</span> <span class="n">wilderness</span>
<span class="k">class</span> <span class="nc">PyramidMapProvider</span><span class="p">(</span><span class="n">wilderness</span><span class="o">.</span><span class="n">WildernessMapProvider</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">is_valid_coordinates</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">wilderness</span><span class="p">,</span> <span class="n">coordinates</span><span class="p">):</span>
<span class="s2">&quot;Validates if these coordinates are inside the map&quot;</span>
<span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">coordinates</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">lines</span> <span class="o">=</span> <span class="n">map_str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="c1"># The reverse is needed because otherwise the pyramid will be</span>
<span class="c1"># upside down</span>
<span class="n">lines</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span>
<span class="n">line</span> <span class="o">=</span> <span class="n">lines</span><span class="p">[</span><span class="n">y</span><span class="p">]</span>
<span class="n">column</span> <span class="o">=</span> <span class="n">line</span><span class="p">[</span><span class="n">x</span><span class="p">]</span>
<span class="k">return</span> <span class="n">column</span> <span class="o">==</span> <span class="s2">&quot;.&quot;</span>
<span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span>
<span class="k">def</span> <span class="nf">get_location_name</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">coordinates</span><span class="p">):</span>
<span class="s2">&quot;Set the location name&quot;</span>
<span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">coordinates</span>
<span class="k">if</span> <span class="n">y</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
<span class="k">return</span> <span class="s2">&quot;Atop the pyramid.&quot;</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="s2">&quot;Inside a pyramid.&quot;</span>
<span class="k">def</span> <span class="nf">at_prepare_room</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">coordinates</span><span class="p">,</span> <span class="n">caller</span><span class="p">,</span> <span class="n">room</span><span class="p">):</span>
<span class="s2">&quot;Any other changes done to the room before showing it&quot;</span>
<span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">coordinates</span>
<span class="n">desc</span> <span class="o">=</span> <span class="s2">&quot;This is a room in the pyramid.&quot;</span>
<span class="k">if</span> <span class="n">y</span> <span class="o">==</span> <span class="mi">3</span> <span class="p">:</span>
<span class="n">desc</span> <span class="o">=</span> <span class="s2">&quot;You can see far and wide from the top of the pyramid.&quot;</span>
<span class="n">room</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="n">desc</span>
</pre></div>
</div>
<p>Now we can use our new pyramid-shaped wilderness map. From inside Evennia we
create a new wilderness (with the name “default”) but using our new map provider:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>py from world import pyramid as p; p.wilderness.create_wilderness(mapprovider=p.PyramidMapProvider())
py from evennia.contrib import wilderness; wilderness.enter_wilderness(me, coordinates=(4, 1))
</pre></div>
</div>
</section>
<section id="implementation-details">
<h2>Implementation details<a class="headerlink" href="#implementation-details" title="Permalink to this headline"></a></h2>
<p>When a character moves into the wilderness, they get their own room. If they
move, instead of moving the character, the room changes to match the new
coordinates. If a character meets another character in the wilderness, then
their room merges. When one of the character leaves again, they each get their
own separate rooms. Rooms are created as needed. Unneeded rooms are stored away
to avoid the overhead cost of creating new rooms again in the future.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/grid/wilderness/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</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="#">Wilderness system</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#usage">Usage</a></li>
<li><a class="reference internal" href="#customisation">Customisation</a></li>
<li><a class="reference internal" href="#example">Example</a></li>
<li><a class="reference internal" href="#implementation-details">Implementation details</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/Contribs/Contrib-Wilderness.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="Contrib-Wilderness.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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Wilderness system</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -6,7 +6,7 @@
<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>XYZGrid contrib &#8212; Evennia 1.0-dev documentation</title>
<title>XYZgrid &#8212; 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>
@ -30,7 +30,7 @@
<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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">XYZGrid contrib</a></li>
<li class="nav-item nav-item-this"><a href="">XYZgrid</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
@ -40,17 +40,19 @@
<div class="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="xyzgrid-contrib">
<h1>XYZGrid contrib<a class="headerlink" href="#xyzgrid-contrib" title="Permalink to this headline"></a></h1>
<div class="versionadded">
<p><span class="versionmodified added">New in version 1.0.</span></p>
</div>
<p>This optional contrib adds a coordinate grid to Evennia. It allows for
defining the grid as simple ascii maps that are then spawned into rooms that are
aware of their X, Y, Z coordinates. The system includes shortest-path
pathfinding, auto-stepping and in-game map visualization (with visibility
range). Grid-management is done outside of the game using a new evennia-launcher
<section class="tex2jax_ignore mathjax_ignore" id="xyzgrid">
<h1>XYZgrid<a class="headerlink" href="#xyzgrid" title="Permalink to this headline"></a></h1>
<p>Contribution by Griatch 2021</p>
<p>Places Evennias game world on an xy (z being different maps) coordinate grid.
Grid is created and maintained externally by drawing and parsing 2D ASCII maps,
including teleports, map transitions and special markers to aid pathfinding.
Supports very fast shortest-route pathfinding on each map. Also includes a
fast view function for seeing only a limited number of steps away from your
current location (useful for displaying the grid as an in-game, updating map).</p>
<p>Grid-management is done outside of the game using a new evennia-launcher
option.</p>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h2>
<script id="asciicast-Zz36JuVAiPF0fSUR09Ii7lcxc" src="https://asciinema.org/a/Zz36JuVAiPF0fSUR09Ii7lcxc.js" async></script>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#-#-#-# #</span>
<span class="o">|</span> <span class="o">/</span> <span class="n">d</span>
@ -76,6 +78,7 @@ option.</p>
</pre></div>
</div>
</section>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<ol>
@ -98,7 +101,7 @@ the server. This makes the <code class="docutils literal notranslate"><span clas
</pre></div>
</div>
<p>and</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>PROTOTYPE_MODULES += [evennia.contrib.xyzgrid.prototypes]
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>PROTOTYPE_MODULES += [evennia.contrib.grid.xyzgrid.prototypes]
</pre></div>
</div>
<p>This will add the new ability to enter <code class="docutils literal notranslate"><span class="pre">evennia</span> <span class="pre">xyzgrid</span> <span class="pre">&lt;option&gt;</span></code> on the
@ -146,7 +149,7 @@ manage the grid from the terminal (no game login is needed).</p></li>
This will create a new <code class="docutils literal notranslate"><span class="pre">XYZGrid</span></code> <a class="reference internal" href="../Components/Scripts.html"><span class="doc std std-doc">Script</span></a> if one didnt already exist.
The <code class="docutils literal notranslate"><span class="pre">evennia</span> <span class="pre">xyzgrid</span></code> is a custom launch option added only for this contrib.</p>
<p>The xyzgrid-contrib comes with a full grid example. Lets add it:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ evennia xyzgrid add evennia.contrib.xyzgrid.example
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ evennia xyzgrid add evennia.contrib.grid.xyzgrid.example
</pre></div>
</div>
<p>You can now list the maps on your grid:</p>
@ -160,7 +163,7 @@ $ evennia xyzgrid show &quot;the small cave&quot;
</pre></div>
</div>
<p>If you want to peek at how the grids code, open
<a class="reference internal" href="../api/evennia.contrib.xyzgrid.example.html#evennia-contrib-xyzgrid-example"><span class="std std-ref">evennia/contrib/xyzgrid/example.py</span></a>.
<a class="reference internal" href="../api/evennia.contrib.grid.xyzgrid.example.html#evennia-contrib-grid-xyzgrid-example"><span class="std std-ref">evennia/contrib/grid/xyzgrid/example.py</span></a>.
(Well explain the details in later sections).</p>
<p>So far the grid is abstract and has no actual in-game presence. Lets
spawn actual rooms/exits from it. This will take a little while.</p>
@ -454,9 +457,9 @@ on the map to Python code.</p>
<p>The legend is optional, and any symbol not explicitly given in your legend will
fall back to its value in the default legend <a class="reference internal" href="#default-legend"><span class="std std-doc">outlined below</span></a>.</p>
<ul class="simple">
<li><p><a class="reference internal" href="../api/evennia.contrib.xyzgrid.xymap_legend.html#evennia.contrib.xyzgrid.xymap_legend.MapNode" title="evennia.contrib.xyzgrid.xymap_legend.MapNode"><span class="xref myst py py-class">MapNode</span></a>
<li><p><a class="reference internal" href="../api/evennia.contrib.grid.xyzgrid.xymap_legend.html#evennia.contrib.grid.xyzgrid.xymap_legend.MapNode" title="evennia.contrib.grid.xyzgrid.xymap_legend.MapNode"><span class="xref myst py py-class">MapNode</span></a>
is the base class for all nodes.</p></li>
<li><p><a class="reference internal" href="../api/evennia.contrib.xyzgrid.xymap_legend.html#evennia.contrib.xyzgrid.xymap_legend.MapLink" title="evennia.contrib.xyzgrid.xymap_legend.MapLink"><span class="xref myst py py-class">MapLink</span></a>
<li><p><a class="reference internal" href="../api/evennia.contrib.grid.xyzgrid.xymap_legend.html#evennia.contrib.grid.xyzgrid.xymap_legend.MapLink" title="evennia.contrib.grid.xyzgrid.xymap_legend.MapLink"><span class="xref myst py py-class">MapLink</span></a>
is the base class for all links.</p></li>
</ul>
<p>As the <em>Map String</em> is parsed, each found symbol is looked up in the legend and
@ -467,7 +470,7 @@ initialized into the corresponding MapNode/Link instance.</p>
with a full set of map elements that use these properties in various ways
(described in the next section).</p>
<p>Some useful properties of the
<a class="reference internal" href="../api/evennia.contrib.xyzgrid.xymap_legend.html#evennia.contrib.xyzgrid.xymap_legend.MapNode" title="evennia.contrib.xyzgrid.xymap_legend.MapNode"><span class="xref myst py py-class">MapNode</span></a>
<a class="reference internal" href="../api/evennia.contrib.grid.xyzgrid.xymap_legend.html#evennia.contrib.grid.xyzgrid.xymap_legend.MapNode" title="evennia.contrib.grid.xyzgrid.xymap_legend.MapNode"><span class="xref myst py py-class">MapNode</span></a>
class (see class doc for hook methods):</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">symbol</span></code> (str) - The character to parse from the map into this node. By default this
@ -495,7 +498,7 @@ given, nothing will be spawned for this coordinate (a virtual node can be
useful for various reasons, mostly map-transitions).</p></li>
</ul>
<p>Some useful properties of the
<a class="reference internal" href="../api/evennia.contrib.xyzgrid.xymap_legend.html#evennia.contrib.xyzgrid.xymap_legend.MapLink" title="evennia.contrib.xyzgrid.xymap_legend.MapLink"><span class="xref myst py py-class">MapLink</span></a>
<a class="reference internal" href="../api/evennia.contrib.grid.xyzgrid.xymap_legend.html#evennia.contrib.grid.xyzgrid.xymap_legend.MapLink" title="evennia.contrib.grid.xyzgrid.xymap_legend.MapLink"><span class="xref myst py py-class">MapLink</span></a>
class (see class doc for hook methods):</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">symbol</span></code> (str) - The character to parse from the map into this node. This must
@ -550,7 +553,7 @@ custom directions outside of the cardinal directions + up/down. The exits key
</ul>
<p>Below is an example that changes the maps nodes to show up as red
(maybe for a lava map?):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.xyzgrid</span> <span class="kn">import</span> <span class="n">xymap_legend</span>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.grid.xyzgrid</span> <span class="kn">import</span> <span class="n">xymap_legend</span>
<span class="k">class</span> <span class="nc">RedMapNode</span><span class="p">(</span><span class="n">xymap_legend</span><span class="o">.</span><span class="n">MapNode</span><span class="p">):</span>
<span class="n">display_symbol</span> <span class="o">=</span> <span class="s2">&quot;|r#|n&quot;</span>
@ -568,7 +571,7 @@ custom directions outside of the cardinal directions + up/down. The exits key
<p>Below is the default map legend. The <code class="docutils literal notranslate"><span class="pre">symbol</span></code> is what should be put in the Map
string. It must always be a single character. The <code class="docutils literal notranslate"><span class="pre">display-symbol</span></code> is what is
actually visualized when displaying the map to players in-game. This could have
colors etc. All classes are found in <code class="docutils literal notranslate"><span class="pre">evennia.contrib.xyzgrid.xymap_legend</span></code> and
colors etc. All classes are found in <code class="docutils literal notranslate"><span class="pre">evennia.contrib.grid.xyzgrid.xymap_legend</span></code> and
their names are included to make it easy to know what to override.</p>
<table class="docutils align-default">
<colgroup>
@ -911,7 +914,7 @@ time.</p>
different (unused) unique symbol in your map legend:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in your map definition module</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.xyzgrid</span> <span class="kn">import</span> <span class="n">xymap_legend</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.grid.xyzgrid</span> <span class="kn">import</span> <span class="n">xymap_legend</span>
<span class="n">MAPSTR</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;&quot;&quot;</span>
@ -956,7 +959,7 @@ must be customized in a child class for every transition.</p>
added, with different map-legend symbols:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in your map definition module (let&#39;s say this is mapB)</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.xyzgrid</span> <span class="kn">import</span> <span class="n">xymap_legend</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.grid.xyzgrid</span> <span class="kn">import</span> <span class="n">xymap_legend</span>
<span class="n">MAPSTR</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;&quot;&quot;</span>
@ -1027,9 +1030,9 @@ across the map boundary.</p>
<p><a class="reference internal" href="../Components/Prototypes.html"><span class="doc std std-doc">Prototypes</span></a> are dicts that describe how to <em>spawn</em> a new instance
of an object. Each of the <em>nodes</em> and <em>links</em> above have a default prototype
that allows the <code class="docutils literal notranslate"><span class="pre">evennia</span> <span class="pre">xyzgrid</span> <span class="pre">spawn</span></code> command to convert them to
a <a class="reference internal" href="../api/evennia.contrib.xyzgrid.xyzroom.html#evennia.contrib.xyzgrid.xyzroom.XYZRoom" title="evennia.contrib.xyzgrid.xyzroom.XYZRoom"><span class="xref myst py py-class">XYZRoom</span></a>
or an <a class="reference internal" href="../api/evennia.contrib.xyzgrid.xyzroom.html#evennia.contrib.xyzgrid.xyzroom.XYZRoom" title="evennia.contrib.xyzgrid.xyzroom.XYZRoom"><span class="xref myst py py-class">XYZExit</span></a> respectively.</p>
<p>The default prototypes are found in <code class="docutils literal notranslate"><span class="pre">evennia.contrib.xyzgrid.prototypes</span></code> (added
a <a class="reference internal" href="../api/evennia.contrib.grid.xyzgrid.xyzroom.html#evennia.contrib.grid.xyzgrid.xyzroom.XYZRoom" title="evennia.contrib.grid.xyzgrid.xyzroom.XYZRoom"><span class="xref myst py py-class">XYZRoom</span></a>
or an <a class="reference internal" href="../api/evennia.contrib.grid.xyzgrid.xyzroom.html#evennia.contrib.grid.xyzgrid.xyzroom.XYZRoom" title="evennia.contrib.grid.xyzgrid.xyzroom.XYZRoom"><span class="xref myst py py-class">XYZExit</span></a> respectively.</p>
<p>The default prototypes are found in <code class="docutils literal notranslate"><span class="pre">evennia.contrib.grid.xyzgrid.prototypes</span></code> (added
during installation of this contrib), with <code class="docutils literal notranslate"><span class="pre">prototype_key</span></code>s <code class="docutils literal notranslate"><span class="pre">&quot;xyz_room&quot;</span></code> and
<code class="docutils literal notranslate"><span class="pre">&quot;xyz_exit&quot;</span></code> - use these as <code class="docutils literal notranslate"><span class="pre">prototype_parent</span></code> to add your own custom prototypes.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">&quot;prototypes&quot;</span></code> key of the XYMap-data dict allows you to customize which
@ -1108,7 +1111,7 @@ grid/map, you can rerun <code class="docutils literal notranslate"><span class="
picked up and applied to the existing objects.</p>
<section id="extending-the-base-prototypes">
<h4>Extending the base prototypes<a class="headerlink" href="#extending-the-base-prototypes" title="Permalink to this headline"></a></h4>
<p>The default prototypes are found in <code class="docutils literal notranslate"><span class="pre">evennia.contrib.xyzgrid.prototypes</span></code> and
<p>The default prototypes are found in <code class="docutils literal notranslate"><span class="pre">evennia.contrib.grid.xyzgrid.prototypes</span></code> and
should be included as <code class="docutils literal notranslate"><span class="pre">prototype_parents</span></code> for prototypes on the map. Would it
not be nice to be able to change these and have the change apply to all of the
grid? You can, by adding the following to your <code class="docutils literal notranslate"><span class="pre">mygame/server/conf/settings.py</span></code>:</p>
@ -1257,8 +1260,8 @@ This behavior can be changed per-link by using links with
</ul>
</section>
</section>
<section id="xyzgrid">
<h2>XYZGrid<a class="headerlink" href="#xyzgrid" title="Permalink to this headline"></a></h2>
<section id="id1">
<h2>XYZGrid<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">XYZGrid</span></code> is a <a class="reference internal" href="../Components/Scripts.html"><span class="doc std std-doc">Global Script</span></a> that holds all <code class="docutils literal notranslate"><span class="pre">XYMap</span></code> objects on
the grid. There should be only one XYZGrid created at any time.</p>
<p>To access the grid in-code, there are several ways:</p>
@ -1267,8 +1270,8 @@ the grid. There should be only one XYZGrid created at any time.</p>
<p>grid = evennia.search_script(“XYZGrid”)[0]</p>
<p>(<code class="docutils literal notranslate"><span class="pre">search_script</span></code> always returns a list)</p>
</li>
<li><p>You can get it with <code class="docutils literal notranslate"><span class="pre">evennia.contrib.xyzgrid.xyzgrid.get_xyzgrid</span></code></p>
<p>from evennia.contrib.xyzgrid.xyzgrid import get_xyzgrid
<li><p>You can get it with <code class="docutils literal notranslate"><span class="pre">evennia.contrib.grid.xyzgrid.xyzgrid.get_xyzgrid</span></code></p>
<p>from evennia.contrib.grid.xyzgrid.xyzgrid import get_xyzgrid
grid = get_xyzgrid()</p>
<p>This will <em>always</em> return a grid, creating an empty grid if one didnt
previously exist. So this is also the recommended way of creating a fresh grid
@ -1305,7 +1308,7 @@ know how to call find the pathfinder though:</p>
<li><p><code class="docutils literal notranslate"><span class="pre">xymap.get_shortest_path(start_xy,</span> <span class="pre">end_xy)</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">xymap.get_visual_range(xy,</span> <span class="pre">dist=2,</span> <span class="pre">**kwargs)</span></code></p></li>
</ul>
<p>See the <a class="reference internal" href="../api/evennia.contrib.xyzgrid.commands.html#evennia.contrib.xyzgrid.commands.PathData.xymap" title="evennia.contrib.xyzgrid.commands.PathData.xymap"><span class="xref myst py py-attr">XYMap</span></a> documentation for
<p>See the <a class="reference internal" href="../api/evennia.contrib.grid.xyzgrid.commands.html#evennia.contrib.grid.xyzgrid.commands.PathData.xymap" title="evennia.contrib.grid.xyzgrid.commands.PathData.xymap"><span class="xref myst py py-attr">XYMap</span></a> documentation for
details.</p>
</section>
<section id="xyzroom-and-xyzexit">
@ -1409,6 +1412,66 @@ modifying the <em>Map String</em> and then rerunning <code class="docutils liter
apply the changes.</p></li>
</ol>
</section>
<section id="details">
<h2>Details<a class="headerlink" href="#details" title="Permalink to this headline"></a></h2>
<p>The default Evennias rooms are non-euclidian - they can connect
to each other with any types of exits without necessarily having a clear
position relative to each other. This gives maximum flexibility, but many games
want to use cardinal movements (north, east etc) and also features like finding
the shortest-path between two points.</p>
<p>This contrib forces each room to exist on a 3-dimensional XYZ grid and also
implements very efficient pathfinding along with tools for displaying
your current visual-range and a lot of related features.</p>
<p>The rooms of the grid are entirely controlled from outside the game, using
python modules with strings and dicts defining the map(s) of the game. Its
possible to combine grid- with non-grid rooms, and you can decorate
grid rooms as much as you like in-game, but you cannot spawn new grid
rooms without editing the map files outside of the game.</p>
</section>
<section id="id2">
<h2>Installation<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h2>
<ol>
<li><p>If you havent before, install the extra contrib requirements.
You can do so by doing <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">-r</span> <span class="pre">requirements_extra.txt</span></code> from the
<code class="docutils literal notranslate"><span class="pre">evennia/</span></code> folder.</p></li>
<li><p>Import and add the <code class="docutils literal notranslate"><span class="pre">evennia.contrib.grid.xyzgrid.commands.XYZGridCmdSet</span></code> to the
<code class="docutils literal notranslate"><span class="pre">CharacterCmdset</span></code> cmdset in <code class="docutils literal notranslate"><span class="pre">mygame/commands.default_cmds.py</span></code>. Reload
the server. This makes the <code class="docutils literal notranslate"><span class="pre">map</span></code>, <code class="docutils literal notranslate"><span class="pre">goto/path</span></code> and modified <code class="docutils literal notranslate"><span class="pre">teleport</span></code> and
<code class="docutils literal notranslate"><span class="pre">open</span></code> commands available in-game.</p></li>
<li><p>Edit <code class="docutils literal notranslate"><span class="pre">mygame/server/conf/settings.py</span></code> and set</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> EXTRA_LAUNCHER_COMMANDS[&#39;xyzgrid&#39;] = &#39;evennia.contrib.grid.xyzgrid.launchcmd.xyzcommand&#39;
</pre></div>
</div>
</li>
<li><p>Run the new <code class="docutils literal notranslate"><span class="pre">evennia</span> <span class="pre">xyzgrid</span> <span class="pre">help</span></code> for instructions on how to spawn the grid.</p></li>
</ol>
</section>
<section id="example-usage">
<h2>Example usage<a class="headerlink" href="#example-usage" title="Permalink to this headline"></a></h2>
<p>After installation, do the following (from your command line, where the
<code class="docutils literal notranslate"><span class="pre">evennia</span></code> command is available) to install an example grid:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>evennia xyzgrid init
evennia xyzgrid add evennia.contrib.grid.xyzgrid.example
evennia xyzgrid list
evennia xyzgrid show &quot;the large tree&quot;
evennia xyzgrid show &quot;the small cave&quot;
evennia xyzgrid spawn
evennia reload
</pre></div>
</div>
<p>(remember to reload the server after spawn operations).</p>
<p>Now you can log into the
server and do <code class="docutils literal notranslate"><span class="pre">teleport</span> <span class="pre">(3,0,the</span> <span class="pre">large</span> <span class="pre">tree)</span></code> to teleport into the map.</p>
<p>You can use <code class="docutils literal notranslate"><span class="pre">open</span> <span class="pre">togrid</span> <span class="pre">=</span> <span class="pre">(3,</span> <span class="pre">0,</span> <span class="pre">the</span> <span class="pre">large</span> <span class="pre">tree)</span></code> to open a permanent (one-way)
exit from your current location into the grid. To make a way back to a non-grid
location just stand in a grid room and open a new exit out of it:
<code class="docutils literal notranslate"><span class="pre">open</span> <span class="pre">tolimbo</span> <span class="pre">=</span> <span class="pre">#2</span></code>.</p>
<p>Try <code class="docutils literal notranslate"><span class="pre">goto</span> <span class="pre">view</span></code> to go to the top of the tree and <code class="docutils literal notranslate"><span class="pre">goto</span> <span class="pre">dungeon</span></code> to go down to
the dungeon entrance at the bottom of the tree.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/grid/xyzgrid/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</section>
</section>
@ -1433,7 +1496,8 @@ apply the changes.</p></li>
<script>$('#searchbox').show(0);</script>
<p><h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">XYZGrid contrib</a><ul>
<li><a class="reference internal" href="#">XYZgrid</a><ul>
<li><a class="reference internal" href="#examples">Examples</a></li>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#overview">Overview</a></li>
<li><a class="reference internal" href="#first-example-usage">First example usage</a></li>
@ -1462,9 +1526,12 @@ apply the changes.</p></li>
<li><a class="reference internal" href="#about-the-pathfinder">About the Pathfinder</a></li>
</ul>
</li>
<li><a class="reference internal" href="#xyzgrid">XYZGrid</a></li>
<li><a class="reference internal" href="#id1">XYZGrid</a></li>
<li><a class="reference internal" href="#xyzroom-and-xyzexit">XYZRoom and XYZExit</a></li>
<li><a class="reference internal" href="#working-with-the-grid">Working with the grid</a></li>
<li><a class="reference internal" href="#details">Details</a></li>
<li><a class="reference internal" href="#id2">Installation</a></li>
<li><a class="reference internal" href="#example-usage">Example usage</a></li>
</ul>
</li>
</ul>
@ -1472,7 +1539,7 @@ apply the changes.</p></li>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/XYZGrid.md.txt"
<li><a href="../_sources/Contribs/Contrib-XYZGrid.md.txt"
rel="nofollow">Show Page Source</a></li>
</ul>
</div><h3>Links</h3>
@ -1488,7 +1555,7 @@ apply the changes.</p></li>
</ul>
<h3>Versions</h3>
<ul>
<li><a href="XYZGrid.html">1.0-dev (develop branch)</a></li>
<li><a href="Contrib-XYZGrid.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>
@ -1506,7 +1573,7 @@ apply the changes.</p></li>
<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> &#187;</li>
<li class="nav-item nav-item-this"><a href="">XYZGrid contrib</a></li>
<li class="nav-item nav-item-this"><a href="">XYZgrid</a></li>
</ul>
<div class="develop">develop branch</div>
</div>

View file

@ -1,605 +0,0 @@
<!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>Dynamic In Game Map &#8212; 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>
<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" />
<link rel="next" title="Static In Game Map" href="Static-In-Game-Map.html" />
<link rel="prev" title="Dialogues in events" href="Dialogues-in-events.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="right" >
<a href="Static-In-Game-Map.html" title="Static In Game Map"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Dialogues-in-events.html" title="Dialogues in events"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" accesskey="U">Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Dynamic In Game Map</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 class="tex2jax_ignore mathjax_ignore" id="dynamic-in-game-map">
<h1>Dynamic In Game Map<a class="headerlink" href="#dynamic-in-game-map" title="Permalink to this headline"></a></h1>
<section id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h2>
<p>An often desired feature in a MUD is to show an in-game map to help navigation. The <a class="reference internal" href="Static-In-Game-Map.html"><span class="doc std std-doc">Static in-game
map</span></a> tutorial solves this by creating a <em>static</em> map, meaning the map is pre-
drawn once and for all - the rooms are then created to match that map. When walking around, parts of
the static map is then cut out and displayed next to the room description.</p>
<p>In this tutorial well instead do it the other way around; We will dynamically draw the map based on
the relationships we find between already existing rooms.</p>
</section>
<section id="the-grid-of-rooms">
<h2>The Grid of Rooms<a class="headerlink" href="#the-grid-of-rooms" title="Permalink to this headline"></a></h2>
<p>There are at least two requirements needed for this tutorial to work.</p>
<ol class="simple">
<li><p>The structure of your mud has to follow a logical layout. Evennia supports the layout of your
world to be logically impossible with rooms looping to themselves or exits leading to the other
side of the map. Exits can also be named anything, from “jumping out the window” to “into the fifth
dimension”. This tutorial assumes you can only move in the cardinal directions (N, E, S and W).</p></li>
<li><p>Rooms must be connected and linked together for the map to be generated correctly. Vanilla
Evennia comes with a admin command <a class="reference internal" href="../api/evennia.commands.default.building.html#evennia.commands.default.building.CmdTunnel" title="evennia.commands.default.building.CmdTunnel"><span class="xref myst py py-class">tunnel</span></a> that allows a
user to create rooms in the cardinal directions, but additional work is needed to assure that rooms
are connected. For example, if you <code class="docutils literal notranslate"><span class="pre">tunnel</span> <span class="pre">east</span></code> and then immediately do <code class="docutils literal notranslate"><span class="pre">tunnel</span> <span class="pre">west</span></code> youll find
that you have created two completely stand-alone rooms. So care is needed if you want to create a
“logical” layout. In this tutorial we assume you have such a grid of rooms that we can generate the
map from.</p></li>
</ol>
</section>
<section id="concept">
<h2>Concept<a class="headerlink" href="#concept" title="Permalink to this headline"></a></h2>
<p>Before getting into the code, it is beneficial to understand and conceptualize how this is going to
work. The idea is analogous to a worm that starts at your current position. It chooses a direction
and walks outward from it, mapping its route as it goes. Once it has traveled a pre-set distance
it stops and starts over in another direction. An important note is that we want a system which is
easily callable and not too complicated. Therefore we will wrap this entire code into a custom
Python class (not a typeclass as this doesnt use any core objects from evennia itself).</p>
<p>We are going to create something that displays like this when you type look:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">Hallway</span>
<span class="p">[</span><span class="o">.</span><span class="p">]</span> <span class="p">[</span><span class="o">.</span><span class="p">]</span>
<span class="p">[</span><span class="o">@</span><span class="p">][</span><span class="o">.</span><span class="p">][</span><span class="o">.</span><span class="p">][</span><span class="o">.</span><span class="p">][</span><span class="o">.</span><span class="p">]</span>
<span class="p">[</span><span class="o">.</span><span class="p">]</span> <span class="p">[</span><span class="o">.</span><span class="p">]</span> <span class="p">[</span><span class="o">.</span><span class="p">]</span>
<span class="n">The</span> <span class="n">distant</span> <span class="n">echoes</span> <span class="n">of</span> <span class="n">the</span> <span class="n">forgotten</span>
<span class="n">wail</span> <span class="n">throughout</span> <span class="n">the</span> <span class="n">empty</span> <span class="n">halls</span><span class="o">.</span>
<span class="n">Exits</span><span class="p">:</span> <span class="n">North</span><span class="p">,</span> <span class="n">East</span><span class="p">,</span> <span class="n">South</span>
</pre></div>
</div>
<p>Your current location is defined by <code class="docutils literal notranslate"><span class="pre">[&#64;]</span></code> while the <code class="docutils literal notranslate"><span class="pre">[.]</span></code>s are other rooms that the “worm” has seen
since departing from your location.</p>
</section>
<section id="setting-up-the-map-display">
<h2>Setting up the Map Display<a class="headerlink" href="#setting-up-the-map-display" title="Permalink to this headline"></a></h2>
<p>First we must define the components for displaying the map. For the “worm” to know what symbol to
draw on the map we will have it check an Attribute on the room it visits called <code class="docutils literal notranslate"><span class="pre">sector_type</span></code>. For
this tutorial we understand two symbols - a normal room and the room with us in it. We also define a
fallback symbol for rooms without said Attribute - that way the map will still work even if we
didnt prepare the room correctly. Assuming your game folder is named <code class="docutils literal notranslate"><span class="pre">mygame</span></code>, we create this code
in <code class="docutils literal notranslate"><span class="pre">mygame/world/map.py.</span></code></p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/world/map.py</span>
<span class="c1"># the symbol is identified with a key &quot;sector_type&quot; on the </span>
<span class="c1"># Room. Keys None and &quot;you&quot; must always exist. </span>
<span class="n">SYMBOLS</span> <span class="o">=</span> <span class="p">{</span> <span class="kc">None</span> <span class="p">:</span> <span class="s1">&#39; . &#39;</span><span class="p">,</span> <span class="c1"># for rooms without sector_type Attribute </span>
<span class="s1">&#39;you&#39;</span> <span class="p">:</span> <span class="s1">&#39;[@]&#39;</span><span class="p">,</span>
<span class="s1">&#39;SECT_INSIDE&#39;</span><span class="p">:</span> <span class="s1">&#39;[.]&#39;</span> <span class="p">}</span>
</pre></div>
</div>
<p>Since trying to access an unset Attribute returns <code class="docutils literal notranslate"><span class="pre">None</span></code>, this means rooms without the <code class="docutils literal notranslate"><span class="pre">sector_type</span></code>
Atttribute will show as <code class="docutils literal notranslate"><span class="pre">.</span></code>. Next we start building the custom class <code class="docutils literal notranslate"><span class="pre">Map</span></code>. It will hold all
methods we need.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/world/map.py</span>
<span class="k">class</span> <span class="nc">Map</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">caller</span><span class="p">,</span> <span class="n">max_width</span><span class="o">=</span><span class="mi">9</span><span class="p">,</span> <span class="n">max_length</span><span class="o">=</span><span class="mi">9</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">caller</span> <span class="o">=</span> <span class="n">caller</span>
<span class="bp">self</span><span class="o">.</span><span class="n">max_width</span> <span class="o">=</span> <span class="n">max_width</span>
<span class="bp">self</span><span class="o">.</span><span class="n">max_length</span> <span class="o">=</span> <span class="n">max_length</span>
<span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span> <span class="o">=</span> <span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curX</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curY</span> <span class="o">=</span> <span class="kc">None</span>
</pre></div>
</div>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">self.caller</span></code> is normally your Character object, the one using the map.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">self.max_width/length</span></code> determine the max width and length of the map that will be generated. Note
that its important that these variables are set to <em>odd</em> numbers to make sure the display area has
a center point.</p></li>
<li><p><code class="docutils literal notranslate"> <span class="pre">self.worm_has_mapped</span></code> is building off the worm analogy above. This dictionary will store all
rooms the “worm” has mapped as well as its relative position within the grid. This is the most
important variable as it acts as a checker and address book that is able to tell us where the
worm has been and what it has mapped so far.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">self.curX/Y</span></code> are coordinates representing the worms current location on the grid.</p></li>
</ul>
<p>Before any sort of mapping can actually be done we need to create an empty display area and do some
sanity checks on it by using the following methods.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/world/map.py</span>
<span class="k">class</span> <span class="nc">Map</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="c1"># [... continued]</span>
<span class="k">def</span> <span class="nf">create_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># This method simply creates an empty grid/display area</span>
<span class="c1"># with the specified variables from __init__(self):</span>
<span class="n">board</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max_width</span><span class="p">):</span>
<span class="n">board</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span>
<span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max_length</span><span class="p">):</span>
<span class="n">board</span><span class="p">[</span><span class="n">row</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">board</span>
<span class="k">def</span> <span class="nf">check_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># this method simply checks the grid to make sure </span>
<span class="c1"># that both max_l and max_w are odd numbers.</span>
<span class="k">return</span> <span class="kc">True</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_length</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">!=</span> <span class="mi">0</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_width</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">!=</span> <span class="mi">0</span>\
<span class="k">else</span> <span class="kc">False</span>
</pre></div>
</div>
<p>Before we can set our worm on its way, we need to know some of the computer science behind all this
called Graph Traversing. In Pseudo code what we are trying to accomplish is this:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># pseudo code</span>
<span class="k">def</span> <span class="nf">draw_room_on_map</span><span class="p">(</span><span class="n">room</span><span class="p">,</span> <span class="n">max_distance</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">draw</span><span class="p">(</span><span class="n">room</span><span class="p">)</span>
<span class="k">if</span> <span class="n">max_distance</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">return</span>
<span class="k">for</span> <span class="n">exit</span> <span class="ow">in</span> <span class="n">room</span><span class="o">.</span><span class="n">exits</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_drawn</span><span class="p">(</span><span class="n">exit</span><span class="o">.</span><span class="n">destination</span><span class="p">):</span>
<span class="c1"># skip drawing if we already visited the destination</span>
<span class="k">continue</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># first time here!</span>
<span class="bp">self</span><span class="o">.</span><span class="n">draw_room_on_map</span><span class="p">(</span><span class="n">exit</span><span class="o">.</span><span class="n">destination</span><span class="p">,</span> <span class="n">max_distance</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>The beauty of Python is that our actual code of doing this doesnt differ much if at all from this
Pseudo code example.</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">max_distance</span></code> is a variable indicating to our Worm how many rooms AWAY from your current location
will it map. Obviously the larger the number the more time it will take if your current location has
many many rooms around you.</p></li>
</ul>
<p>The first hurdle here is what value to use for max_distance. There is no reason for the worm to
travel further than what is actually displayed to you. For example, if your current location is
placed in the center of a display area of size <code class="docutils literal notranslate"><span class="pre">max_length</span> <span class="pre">=</span> <span class="pre">max_width</span> <span class="pre">=</span> <span class="pre">9</span></code>, then the worm need only
go <code class="docutils literal notranslate"><span class="pre">4</span></code> spaces in either direction:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="o">.</span><span class="p">][</span><span class="o">.</span><span class="p">][</span><span class="o">.</span><span class="p">][</span><span class="o">.</span><span class="p">][</span><span class="o">@</span><span class="p">][</span><span class="o">.</span><span class="p">][</span><span class="o">.</span><span class="p">][</span><span class="o">.</span><span class="p">][</span><span class="o">.</span><span class="p">]</span>
<span class="mi">4</span> <span class="mi">3</span> <span class="mi">2</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">1</span> <span class="mi">2</span> <span class="mi">3</span> <span class="mi">4</span>
</pre></div>
</div>
<p>The max_distance can be set dynamically based on the size of the display area. As your width/length
changes it becomes a simple algebraic linear relationship which is simply <code class="docutils literal notranslate"><span class="pre">max_distance</span> <span class="pre">=</span> <span class="pre">(min(max_width,</span> <span class="pre">max_length)</span> <span class="pre">-1)</span> <span class="pre">/</span> <span class="pre">2</span></code>.</p>
</section>
<section id="building-the-mapper">
<h2>Building the Mapper<a class="headerlink" href="#building-the-mapper" title="Permalink to this headline"></a></h2>
<p>Now we can start to fill our Map object with some methods. We are still missing a few methods that
are very important:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">self.draw(self,</span> <span class="pre">room)</span></code> - responsible for actually drawing room to grid.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">self.has_drawn(self,</span> <span class="pre">room)</span></code> - checks to see if the room has been mapped and worm has already been
here.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">self.median(self,</span> <span class="pre">number)</span></code> - a simple utility method that finds the median (middle point) from 0,
n</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">self.update_pos(self,</span> <span class="pre">room,</span> <span class="pre">exit_name)</span></code> - updates the worms physical position by reassigning
self.curX/Y. .accordingly</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">self.start_loc_on_grid(self)</span></code> - the very first initial draw on the grid representing your
location in the middle of the grid</p></li>
<li><p>self.show_map<code class="docutils literal notranslate"> <span class="pre">-</span> <span class="pre">after</span> <span class="pre">everything</span> <span class="pre">is</span> <span class="pre">done</span> <span class="pre">convert</span> <span class="pre">the</span> <span class="pre">map</span> <span class="pre">into</span> <span class="pre">a</span> <span class="pre">readable</span> <span class="pre">string</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">self.draw_room_on_map(self,</span> <span class="pre">room,</span> <span class="pre">max_distance)</span></code> - the main method that ties it all together.`</p></li>
</ul>
<p>Now that we know which methods we need, lets refine our initial <code class="docutils literal notranslate"><span class="pre">__init__(self)</span></code> to pass some
conditional statements and set it up to start building the display.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1">#mygame/world/map.py</span>
<span class="k">class</span> <span class="nc">Map</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">caller</span><span class="p">,</span> <span class="n">max_width</span><span class="o">=</span><span class="mi">9</span><span class="p">,</span> <span class="n">max_length</span><span class="o">=</span><span class="mi">9</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">caller</span> <span class="o">=</span> <span class="n">caller</span>
<span class="bp">self</span><span class="o">.</span><span class="n">max_width</span> <span class="o">=</span> <span class="n">max_width</span>
<span class="bp">self</span><span class="o">.</span><span class="n">max_length</span> <span class="o">=</span> <span class="n">max_length</span>
<span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span> <span class="o">=</span> <span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curX</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curY</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">check_grid</span><span class="p">():</span>
<span class="c1"># we have to store the grid into a variable</span>
<span class="bp">self</span><span class="o">.</span><span class="n">grid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_grid</span><span class="p">()</span>
<span class="c1"># we use the algebraic relationship</span>
<span class="bp">self</span><span class="o">.</span><span class="n">draw_room_on_map</span><span class="p">(</span><span class="n">caller</span><span class="o">.</span><span class="n">location</span><span class="p">,</span>
<span class="p">((</span><span class="nb">min</span><span class="p">(</span><span class="n">max_width</span><span class="p">,</span> <span class="n">max_length</span><span class="p">)</span> <span class="o">-</span><span class="mi">1</span> <span class="p">)</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
<p>Here we check to see if the parameters for the grid are okay, then we create an empty canvas and map
our initial location as the first room!</p>
<p>As mentioned above, the code for the <code class="docutils literal notranslate"><span class="pre">self.draw_room_on_map()</span></code> is not much different than the Pseudo
code. The method is shown below:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/world/map.py, in the Map class</span>
<span class="k">def</span> <span class="nf">draw_room_on_map</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">room</span><span class="p">,</span> <span class="n">max_distance</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">draw</span><span class="p">(</span><span class="n">room</span><span class="p">)</span>
<span class="k">if</span> <span class="n">max_distance</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">return</span>
<span class="k">for</span> <span class="n">exit</span> <span class="ow">in</span> <span class="n">room</span><span class="o">.</span><span class="n">exits</span><span class="p">:</span>
<span class="k">if</span> <span class="n">exit</span><span class="o">.</span><span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;north&quot;</span><span class="p">,</span> <span class="s2">&quot;east&quot;</span><span class="p">,</span> <span class="s2">&quot;west&quot;</span><span class="p">,</span> <span class="s2">&quot;south&quot;</span><span class="p">):</span>
<span class="c1"># we only map in the cardinal directions. Mapping up/down would be</span>
<span class="c1"># an interesting learning project for someone who wanted to try it.</span>
<span class="k">continue</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_drawn</span><span class="p">(</span><span class="n">exit</span><span class="o">.</span><span class="n">destination</span><span class="p">):</span>
<span class="c1"># we&#39;ve been to the destination already, skip ahead.</span>
<span class="k">continue</span>
<span class="bp">self</span><span class="o">.</span><span class="n">update_pos</span><span class="p">(</span><span class="n">room</span><span class="p">,</span> <span class="n">exit</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">draw_room_on_map</span><span class="p">(</span><span class="n">exit</span><span class="o">.</span><span class="n">destination</span><span class="p">,</span> <span class="n">max_distance</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>The first thing the “worm” does is to draw your current location in <code class="docutils literal notranslate"><span class="pre">self.draw</span></code>. Lets define that…</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1">#in mygame/word/map.py, in the Map class </span>
<span class="k">def</span> <span class="nf">draw</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">room</span><span class="p">):</span>
<span class="c1"># draw initial ch location on map first!</span>
<span class="k">if</span> <span class="n">room</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">caller</span><span class="o">.</span><span class="n">location</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">start_loc_on_grid</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span><span class="p">[</span><span class="n">room</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">curX</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">curY</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># map all other rooms</span>
<span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span><span class="p">[</span><span class="n">room</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">curX</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">curY</span><span class="p">]</span>
<span class="c1"># this will use the sector_type Attribute or None if not set.</span>
<span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">curX</span><span class="p">][</span><span class="bp">self</span><span class="o">.</span><span class="n">curY</span><span class="p">]</span> <span class="o">=</span> <span class="n">SYMBOLS</span><span class="p">[</span><span class="n">room</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">sector_type</span><span class="p">]</span>
</pre></div>
</div>
<p>In <code class="docutils literal notranslate"><span class="pre">self.start_loc_on_grid()</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">median</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num</span><span class="p">):</span>
<span class="n">lst</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">num</span><span class="p">))</span>
<span class="n">n</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">lst</span><span class="p">)</span>
<span class="n">m</span> <span class="o">=</span> <span class="n">n</span> <span class="o">-</span><span class="mi">1</span>
<span class="k">return</span> <span class="p">(</span><span class="n">lst</span><span class="p">[</span><span class="n">n</span><span class="o">//</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="n">lst</span><span class="p">[</span><span class="n">m</span><span class="o">//</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span> <span class="mf">2.0</span>
<span class="k">def</span> <span class="nf">start_loc_on_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">median</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max_width</span><span class="p">)</span>
<span class="n">y</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">median</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max_length</span><span class="p">)</span>
<span class="c1"># x and y are floats by default, can&#39;t index lists with float types</span>
<span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">[</span><span class="n">x</span><span class="p">][</span><span class="n">y</span><span class="p">]</span> <span class="o">=</span> <span class="n">SYMBOLS</span><span class="p">[</span><span class="s1">&#39;you&#39;</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curX</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">curY</span> <span class="o">=</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="c1"># updating worms current location</span>
</pre></div>
</div>
<p>After the system has drawn the current map it checks to see if the <code class="docutils literal notranslate"><span class="pre">max_distance</span></code> is <code class="docutils literal notranslate"><span class="pre">0</span></code> (since this
is the inital start phase it is not). Now we handle the iteration once we have each individual exit
in the room. The first thing it does is check if the room the Worm is in has been mapped already…
lets define that…</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">has_drawn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">room</span><span class="p">):</span>
<span class="k">return</span> <span class="kc">True</span> <span class="k">if</span> <span class="n">room</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> <span class="k">else</span> <span class="kc">False</span>
</pre></div>
</div>
<p>If <code class="docutils literal notranslate"><span class="pre">has_drawn</span></code> returns <code class="docutils literal notranslate"><span class="pre">False</span></code> that means the worm has found a room that hasnt been mapped yet. It
will then move there. The self.curX/Y sort of lags behind, so we have to make sure to track the
position of the worm; we do this in <code class="docutils literal notranslate"><span class="pre">self.update_pos()</span></code> below.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">update_pos</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">room</span><span class="p">,</span> <span class="n">exit_name</span><span class="p">):</span>
<span class="c1"># this ensures the coordinates stays up to date </span>
<span class="c1"># to where the worm is currently at.</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curX</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">curY</span> <span class="o">=</span> \
<span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span><span class="p">[</span><span class="n">room</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span><span class="p">[</span><span class="n">room</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>
<span class="c1"># now we have to actually move the pointer </span>
<span class="c1"># variables depending on which &#39;exit&#39; it found</span>
<span class="k">if</span> <span class="n">exit_name</span> <span class="o">==</span> <span class="s1">&#39;east&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curY</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">elif</span> <span class="n">exit_name</span> <span class="o">==</span> <span class="s1">&#39;west&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curY</span> <span class="o">-=</span> <span class="mi">1</span>
<span class="k">elif</span> <span class="n">exit_name</span> <span class="o">==</span> <span class="s1">&#39;north&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curX</span> <span class="o">-=</span> <span class="mi">1</span>
<span class="k">elif</span> <span class="n">exit_name</span> <span class="o">==</span> <span class="s1">&#39;south&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curX</span> <span class="o">+=</span> <span class="mi">1</span>
</pre></div>
</div>
<p>Once the system updates the position of the worm it feeds the new room back into the original
<code class="docutils literal notranslate"><span class="pre">draw_room_on_map()</span></code> and starts the process all over again…</p>
<p>That is essentially the entire thing. The final method is to bring it all together and make a nice
presentational string out of it using the <code class="docutils literal notranslate"><span class="pre">self.show_map()</span></code> method.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">show_map</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">map_string</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">:</span>
<span class="n">map_string</span> <span class="o">+=</span> <span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">row</span><span class="p">)</span>
<span class="n">map_string</span> <span class="o">+=</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="k">return</span> <span class="n">map_string</span>
</pre></div>
</div>
</section>
<section id="using-the-map">
<h2>Using the Map<a class="headerlink" href="#using-the-map" title="Permalink to this headline"></a></h2>
<p>In order for the map to get triggered we store it on the Room typeclass. If we put it in
<code class="docutils literal notranslate"><span class="pre">return_appearance</span></code> we will get the map back every time we look at the room.</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">return_appearance</span></code> is a default Evennia hook available on all objects; it is called e.g. by the
<code class="docutils literal notranslate"><span class="pre">look</span></code> command to get the description of something (the room in this case).</p>
</div></blockquote>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/typeclasses/rooms.py</span>
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">DefaultRoom</span>
<span class="kn">from</span> <span class="nn">world.map</span> <span class="kn">import</span> <span class="n">Map</span>
<span class="k">class</span> <span class="nc">Room</span><span class="p">(</span><span class="n">DefaultRoom</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">return_appearance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">looker</span><span class="p">):</span>
<span class="c1"># [...]</span>
<span class="n">string</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">Map</span><span class="p">(</span><span class="n">looker</span><span class="p">)</span><span class="o">.</span><span class="n">show_map</span><span class="p">()</span><span class="si">}</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="c1"># Add all the normal stuff like room description, </span>
<span class="c1"># contents, exits etc. </span>
<span class="n">string</span> <span class="o">+=</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">+</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">return_appearance</span><span class="p">(</span><span class="n">looker</span><span class="p">)</span>
<span class="k">return</span> <span class="n">string</span>
</pre></div>
</div>
<p>Obviously this method of generating maps doesnt take into account of any doors or exits that are
hidden… etc… but hopefully it serves as a good base to start with. Like previously mentioned, it
is very important to have a solid foundation on rooms before implementing this. You can try this on
vanilla evennia by using &#64;tunnel and essentially you can just create a long straight/edgy non-
looping rooms that will show on your in-game map.</p>
<p>The above example will display the map above the room description. You could also use an
<a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia.utils.evtable">EvTable</a> to place description and map next to each other. Some other
things you can do is to have a <a class="reference internal" href="../Components/Commands.html"><span class="doc std std-doc">Command</span></a> that displays with a larger radius, maybe with a
legend and other features.</p>
<p>Below is the whole <code class="docutils literal notranslate"><span class="pre">map.py</span></code> for your reference. You need to update your <code class="docutils literal notranslate"><span class="pre">Room</span></code> typeclass (see above)
to actually call it. Remember that to see different symbols for a location you also need to set the
<code class="docutils literal notranslate"><span class="pre">sector_type</span></code> Attribute on the room to one of the keys in the <code class="docutils literal notranslate"><span class="pre">SYMBOLS</span></code> dictionary. So in this
example, to make a room be mapped as <code class="docutils literal notranslate"><span class="pre">[.]</span></code> you would set the rooms <code class="docutils literal notranslate"><span class="pre">sector_type</span></code> to
<code class="docutils literal notranslate"><span class="pre">&quot;SECT_INSIDE&quot;</span></code>. Try it out with <code class="docutils literal notranslate"><span class="pre">&#64;set</span> <span class="pre">here/sector_type</span> <span class="pre">=</span> <span class="pre">&quot;SECT_INSIDE&quot;</span></code>. If you wanted all new
rooms to have a given sector symbol, you could change the default in the <code class="docutils literal notranslate"><span class="pre">SYMBOLS´</span> <span class="pre">dictionary</span> <span class="pre">below,</span> <span class="pre">or</span> <span class="pre">you</span> <span class="pre">could</span> <span class="pre">add</span> <span class="pre">the</span> <span class="pre">Attribute</span> <span class="pre">in</span> <span class="pre">the</span> <span class="pre">Room's</span> </code>at_object_creation` method.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1">#mygame/world/map.py</span>
<span class="c1"># These are keys set with the Attribute sector_type on the room.</span>
<span class="c1"># The keys None and &quot;you&quot; must always exist.</span>
<span class="n">SYMBOLS</span> <span class="o">=</span> <span class="p">{</span> <span class="kc">None</span> <span class="p">:</span> <span class="s1">&#39; . &#39;</span><span class="p">,</span> <span class="c1"># for rooms without a sector_type attr</span>
<span class="s1">&#39;you&#39;</span> <span class="p">:</span> <span class="s1">&#39;[@]&#39;</span><span class="p">,</span>
<span class="s1">&#39;SECT_INSIDE&#39;</span><span class="p">:</span> <span class="s1">&#39;[.]&#39;</span> <span class="p">}</span>
<span class="k">class</span> <span class="nc">Map</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">caller</span><span class="p">,</span> <span class="n">max_width</span><span class="o">=</span><span class="mi">9</span><span class="p">,</span> <span class="n">max_length</span><span class="o">=</span><span class="mi">9</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">caller</span> <span class="o">=</span> <span class="n">caller</span>
<span class="bp">self</span><span class="o">.</span><span class="n">max_width</span> <span class="o">=</span> <span class="n">max_width</span>
<span class="bp">self</span><span class="o">.</span><span class="n">max_length</span> <span class="o">=</span> <span class="n">max_length</span>
<span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span> <span class="o">=</span> <span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curX</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curY</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">check_grid</span><span class="p">():</span>
<span class="c1"># we actually have to store the grid into a variable</span>
<span class="bp">self</span><span class="o">.</span><span class="n">grid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_grid</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">draw_room_on_map</span><span class="p">(</span><span class="n">caller</span><span class="o">.</span><span class="n">location</span><span class="p">,</span>
<span class="p">((</span><span class="nb">min</span><span class="p">(</span><span class="n">max_width</span><span class="p">,</span> <span class="n">max_length</span><span class="p">)</span> <span class="o">-</span><span class="mi">1</span> <span class="p">)</span> <span class="o">/</span> <span class="mi">2</span><span class="p">))</span>
<span class="k">def</span> <span class="nf">update_pos</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">room</span><span class="p">,</span> <span class="n">exit_name</span><span class="p">):</span>
<span class="c1"># this ensures the pointer variables always </span>
<span class="c1"># stays up to date to where the worm is currently at.</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curX</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">curY</span> <span class="o">=</span> \
<span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span><span class="p">[</span><span class="n">room</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span><span class="p">[</span><span class="n">room</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>
<span class="c1"># now we have to actually move the pointer </span>
<span class="c1"># variables depending on which &#39;exit&#39; it found</span>
<span class="k">if</span> <span class="n">exit_name</span> <span class="o">==</span> <span class="s1">&#39;east&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curY</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">elif</span> <span class="n">exit_name</span> <span class="o">==</span> <span class="s1">&#39;west&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curY</span> <span class="o">-=</span> <span class="mi">1</span>
<span class="k">elif</span> <span class="n">exit_name</span> <span class="o">==</span> <span class="s1">&#39;north&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curX</span> <span class="o">-=</span> <span class="mi">1</span>
<span class="k">elif</span> <span class="n">exit_name</span> <span class="o">==</span> <span class="s1">&#39;south&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curX</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">def</span> <span class="nf">draw_room_on_map</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">room</span><span class="p">,</span> <span class="n">max_distance</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">draw</span><span class="p">(</span><span class="n">room</span><span class="p">)</span>
<span class="k">if</span> <span class="n">max_distance</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">return</span>
<span class="k">for</span> <span class="n">exit</span> <span class="ow">in</span> <span class="n">room</span><span class="o">.</span><span class="n">exits</span><span class="p">:</span>
<span class="k">if</span> <span class="n">exit</span><span class="o">.</span><span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;north&quot;</span><span class="p">,</span> <span class="s2">&quot;east&quot;</span><span class="p">,</span> <span class="s2">&quot;west&quot;</span><span class="p">,</span> <span class="s2">&quot;south&quot;</span><span class="p">):</span>
<span class="c1"># we only map in the cardinal directions. Mapping up/down would be</span>
<span class="c1"># an interesting learning project for someone who wanted to try it.</span>
<span class="k">continue</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_drawn</span><span class="p">(</span><span class="n">exit</span><span class="o">.</span><span class="n">destination</span><span class="p">):</span>
<span class="c1"># we&#39;ve been to the destination already, skip ahead.</span>
<span class="k">continue</span>
<span class="bp">self</span><span class="o">.</span><span class="n">update_pos</span><span class="p">(</span><span class="n">room</span><span class="p">,</span> <span class="n">exit</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">draw_room_on_map</span><span class="p">(</span><span class="n">exit</span><span class="o">.</span><span class="n">destination</span><span class="p">,</span> <span class="n">max_distance</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">draw</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">room</span><span class="p">):</span>
<span class="c1"># draw initial caller location on map first!</span>
<span class="k">if</span> <span class="n">room</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">caller</span><span class="o">.</span><span class="n">location</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">start_loc_on_grid</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span><span class="p">[</span><span class="n">room</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">curX</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">curY</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># map all other rooms</span>
<span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span><span class="p">[</span><span class="n">room</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">curX</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">curY</span><span class="p">]</span>
<span class="c1"># this will use the sector_type Attribute or None if not set.</span>
<span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">curX</span><span class="p">][</span><span class="bp">self</span><span class="o">.</span><span class="n">curY</span><span class="p">]</span> <span class="o">=</span> <span class="n">SYMBOLS</span><span class="p">[</span><span class="n">room</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">sector_type</span><span class="p">]</span>
<span class="k">def</span> <span class="nf">median</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num</span><span class="p">):</span>
<span class="n">lst</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">num</span><span class="p">))</span>
<span class="n">n</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">lst</span><span class="p">)</span>
<span class="n">m</span> <span class="o">=</span> <span class="n">n</span> <span class="o">-</span><span class="mi">1</span>
<span class="k">return</span> <span class="p">(</span><span class="n">lst</span><span class="p">[</span><span class="n">n</span><span class="o">//</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="n">lst</span><span class="p">[</span><span class="n">m</span><span class="o">//</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span> <span class="mf">2.0</span>
<span class="k">def</span> <span class="nf">start_loc_on_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">x</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">median</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max_width</span><span class="p">)</span>
<span class="n">y</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">median</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max_length</span><span class="p">)</span>
<span class="c1"># x and y are floats by default, can&#39;t index lists with float types</span>
<span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">[</span><span class="n">x</span><span class="p">][</span><span class="n">y</span><span class="p">]</span> <span class="o">=</span> <span class="n">SYMBOLS</span><span class="p">[</span><span class="s1">&#39;you&#39;</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">curX</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">curY</span> <span class="o">=</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="c1"># updating worms current location</span>
<span class="k">def</span> <span class="nf">has_drawn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">room</span><span class="p">):</span>
<span class="k">return</span> <span class="kc">True</span> <span class="k">if</span> <span class="n">room</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">worm_has_mapped</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> <span class="k">else</span> <span class="kc">False</span>
<span class="k">def</span> <span class="nf">create_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># This method simply creates an empty grid </span>
<span class="c1"># with the specified variables from __init__(self):</span>
<span class="n">board</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max_width</span><span class="p">):</span>
<span class="n">board</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span>
<span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max_length</span><span class="p">):</span>
<span class="n">board</span><span class="p">[</span><span class="n">row</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">board</span>
<span class="k">def</span> <span class="nf">check_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># this method simply checks the grid to make sure </span>
<span class="c1"># both max_l and max_w are odd numbers</span>
<span class="k">return</span> <span class="kc">True</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_length</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">!=</span> <span class="mi">0</span> <span class="ow">or</span> \
<span class="bp">self</span><span class="o">.</span><span class="n">max_width</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">!=</span> <span class="mi">0</span> <span class="k">else</span> <span class="kc">False</span>
<span class="k">def</span> <span class="nf">show_map</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">map_string</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="p">:</span>
<span class="n">map_string</span> <span class="o">+=</span> <span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">row</span><span class="p">)</span>
<span class="n">map_string</span> <span class="o">+=</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="k">return</span> <span class="n">map_string</span>
</pre></div>
</div>
</section>
<section id="final-comments">
<h2>Final Comments<a class="headerlink" href="#final-comments" title="Permalink to this headline"></a></h2>
<p>The Dynamic map could be expanded with further capabilities. For example, it could mark exits or
allow NE, SE etc directions as well. It could have colors for different terrain types. One could
also look into up/down directions and figure out how to display that in a good way.</p>
</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="#">Dynamic In Game Map</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#the-grid-of-rooms">The Grid of Rooms</a></li>
<li><a class="reference internal" href="#concept">Concept</a></li>
<li><a class="reference internal" href="#setting-up-the-map-display">Setting up the Map Display</a></li>
<li><a class="reference internal" href="#building-the-mapper">Building the Mapper</a></li>
<li><a class="reference internal" href="#using-the-map">Using the Map</a></li>
<li><a class="reference internal" href="#final-comments">Final Comments</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Dialogues-in-events.html"
title="previous chapter">Dialogues in events</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Static-In-Game-Map.html"
title="next chapter">Static In Game Map</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Dynamic-In-Game-Map.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="Dynamic-In-Game-Map.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="right" >
<a href="Static-In-Game-Map.html" title="Static In Game Map"
>next</a> |</li>
<li class="right" >
<a href="Dialogues-in-events.html" title="Dialogues in events"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" >Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Dynamic In Game Map</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>

View file

@ -1,534 +0,0 @@
<!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>Static In Game Map &#8212; 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>
<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" />
<link rel="next" title="Building menus" href="Building-menus.html" />
<link rel="prev" title="Dynamic In Game Map" href="Dynamic-In-Game-Map.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="right" >
<a href="Building-menus.html" title="Building menus"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Dynamic-In-Game-Map.html" title="Dynamic In Game Map"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" accesskey="U">Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Static In Game Map</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 class="tex2jax_ignore mathjax_ignore" id="static-in-game-map">
<h1>Static In Game Map<a class="headerlink" href="#static-in-game-map" title="Permalink to this headline"></a></h1>
<section id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h2>
<p>This tutorial describes the creation of an in-game map display based on a pre-drawn map. It also
details how to use the <a class="reference internal" href="../Components/Batch-Code-Processor.html"><span class="doc std std-doc">Batch code processor</span></a> for advanced building. There is
also the <a class="reference internal" href="Dynamic-In-Game-Map.html"><span class="doc std std-doc">Dynamic in-game map tutorial</span></a> that works in the opposite direction,
by generating a map from an existing grid of rooms.</p>
<p>Evennia does not require its rooms to be positioned in a “logical” way. Your exits could be named
anything. You could make an exit “west” that leads to a room described to be in the far north. You
could have rooms inside one another, exits leading back to the same room or describing spatial
geometries impossible in the real world.</p>
<p>That said, most games <em>do</em> organize their rooms in a logical fashion, if nothing else to retain the
sanity of their players. And when they do, the game becomes possible to map. This tutorial will give
an example of a simple but flexible in-game map system to further help players to navigate. We will</p>
<p>To simplify development and error-checking well break down the work into bite-size chunks, each
building on what came before. For this well make extensive use of the [Batch code processor](Batch-
Code-Processor), so you may want to familiarize yourself with that.</p>
<ol>
<li><p><strong>Planning the map</strong> - Here well come up with a small example map to use for the rest of the
tutorial.</p></li>
<li><p><strong>Making a map object</strong> - This will showcase how to make a static in-game “map” object a
Character could pick up and look at.</p></li>
<li><p><strong>Building the map areas</strong> - Here well actually create the small example area according to the
map we designed before.</p></li>
<li><p><strong>Map code</strong> - This will link the map to the location so our output looks something like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>crossroads(#3)
↑╚∞╝↑
≈↑│↑∩ The merger of two roads. To the north looms a mighty castle.
O─O─O To the south, the glow of a campfire can be seen. To the east lie
≈↑│↑∩ the vast mountains and to the west is heard the waves of the sea.
↑▲O▲↑
Exits: north(#8), east(#9), south(#10), west(#11)
</pre></div>
</div>
</li>
</ol>
<p>We will henceforth assume your game folder is name named <code class="docutils literal notranslate"><span class="pre">mygame</span></code> and that you havent modified the
default commands. We will also not be using <a class="reference internal" href="../Concepts/Colors.html"><span class="doc std std-doc">Colors</span></a> for our map since they
dont show in the documentation wiki.</p>
</section>
<section id="planning-the-map">
<h2>Planning the Map<a class="headerlink" href="#planning-the-map" title="Permalink to this headline"></a></h2>
<p>Lets begin with the fun part! Maps in MUDs come in many different [shapes and
sizes](<a class="reference external" href="http://journal.imaginary-realities.com/volume-05/issue-01/modern-interface-modern-">http://journal.imaginary-realities.com/volume-05/issue-01/modern-interface-modern-</a>
mud/index.html). Some appear as just boxes connected by lines. Others have complex graphics that are
external to the game itself.</p>
<p>Our map will be in-game text but that doesnt mean were restricted to the normal alphabet! If
youve ever selected the <a class="reference external" href="https://en.wikipedia.org/wiki/Wingdings">Wingdings font</a> in Microsoft Word
you will know there are a multitude of other characters around to use. When creating your game with
Evennia you have access to the <a class="reference external" href="https://en.wikipedia.org/wiki/UTF-8">UTF-8 character encoding</a> which
put at your disposal <a class="reference external" href="https://mcdlr.com/utf-8/#1">thousands of letters, number and geometric shapes</a>.</p>
<p>For this exercise, weve copy-and-pasted from the pallet of special characters used over at
<a class="reference external" href="https://dwarffortresswiki.org/index.php/Character_table">Dwarf Fortress</a> to create what is hopefully
a pleasing and easy to understood landscape:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>≈≈↑↑↑↑↑∩∩
≈≈↑╔═╗↑∩∩ Places the account can visit are indicated by &quot;O&quot;.
≈≈↑║O║↑∩∩ Up the top is a castle visitable by the account.
≈≈↑╚∞╝↑∩∩ To the right is a cottage and to the left the beach.
≈≈≈↑│↑∩∩∩ And down the bottom is a camp site with tents.
≈≈O─O─O⌂∩ In the center is the starting location, a crossroads
≈≈≈↑│↑∩∩∩ which connect the four other areas.
≈≈↑▲O▲↑∩∩
≈≈↑↑▲↑↑∩∩
≈≈↑↑↑↑↑∩∩
</pre></div>
</div>
<p>There are many considerations when making a game map depending on the play style and requirements
you intend to implement. Here we will display a 5x5 character map of the area surrounding the
account. This means making sure to account for 2 characters around every visitable location. Good
planning at this stage can solve many problems before they happen.</p>
</section>
<section id="creating-a-map-object">
<h2>Creating a Map Object<a class="headerlink" href="#creating-a-map-object" title="Permalink to this headline"></a></h2>
<p>In this section we will try to create an actual “map” object that an account can pick up and look
at.</p>
<p>Evennia offers a range of <a class="reference internal" href="../Components/Default-Commands.html"><span class="doc std std-doc">default commands</span></a> for
<a class="reference internal" href="../Howto/Starting/Part1/Building-Quickstart.html"><span class="doc std std-doc">creating objects and rooms in-game</span></a>. While readily accessible, these commands are made to do very
specific, restricted things and will thus not offer as much flexibility to experiment (for an
advanced exception see <a class="reference internal" href="../Components/FuncParser.html"><span class="doc std std-doc">the FuncParser</span></a>). Additionally, entering long
descriptions and properties over and over in the game client can become tedious; especially when
testing and you may want to delete and recreate things over and over.</p>
<p>To overcome this, Evennia offers <a class="reference internal" href="../Components/Batch-Processors.html"><span class="doc std std-doc">batch processors</span></a> that work as input-files
created out-of-game. In this tutorial well be using the more powerful of the two available batch
processors, the <a class="reference internal" href="../Components/Batch-Code-Processor.html"><span class="doc std std-doc">Batch Code Processor </span></a>, called with the <code class="docutils literal notranslate"><span class="pre">&#64;batchcode</span></code> command.
This is a very powerful tool. It allows you to craft Python files to act as blueprints of your
entire game world. These files have access to use Evennias Python API directly. Batchcode allows
for easy editing and creation in whatever text editor you prefer, avoiding having to manually build
the world line-by-line inside the game.</p>
<blockquote>
<div><p>Important warning: <code class="docutils literal notranslate"><span class="pre">&#64;batchcode</span></code>s power is only rivaled by the <code class="docutils literal notranslate"><span class="pre">&#64;py</span></code> command. Batchcode is so
powerful it should be reserved only for the <a class="reference internal" href="../Concepts/Building-Permissions.html"><span class="doc std std-doc">superuser</span></a>. Think carefully
before you let others (such as <code class="docutils literal notranslate"><span class="pre">Developer</span></code>- level staff) run <code class="docutils literal notranslate"><span class="pre">&#64;batchcode</span></code> on their own - make sure
you are okay with them running <em>arbitrary Python code</em> on your server.</p>
</div></blockquote>
<p>While a simple example, the map object it serves as good way to try out <code class="docutils literal notranslate"><span class="pre">&#64;batchcode</span></code>. Go to
<code class="docutils literal notranslate"><span class="pre">mygame/world</span></code> and create a new file there named <code class="docutils literal notranslate"><span class="pre">batchcode_map.py</span></code>:</p>
<div class="highlight-Python notranslate"><div class="highlight"><pre><span></span><span class="c1"># mygame/world/batchcode_map.py</span>
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">create_object</span>
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">DefaultObject</span>
<span class="c1"># We use the create_object function to call into existence a </span>
<span class="c1"># DefaultObject named &quot;Map&quot; wherever you are standing.</span>
<span class="nb">map</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">DefaultObject</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;Map&quot;</span><span class="p">,</span> <span class="n">location</span><span class="o">=</span><span class="n">caller</span><span class="o">.</span><span class="n">location</span><span class="p">)</span>
<span class="c1"># We then access its description directly to make it our map.</span>
<span class="nb">map</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;</span>
<span class="s2">≈≈↑↑↑↑↑∩∩</span>
<span class="s2">≈≈↑╔═╗↑∩∩</span>
<span class="s2">≈≈↑║O║↑∩∩</span>
<span class="s2">≈≈↑╚∞╝↑∩∩</span>
<span class="s2">≈≈≈↑│↑∩∩∩</span>
<span class="s2">≈≈O─O─O⌂∩</span>
<span class="s2">≈≈≈↑│↑∩∩∩</span>
<span class="s2">≈≈↑▲O▲↑∩∩</span>
<span class="s2">≈≈↑↑▲↑↑∩∩</span>
<span class="s2">≈≈↑↑↑↑↑∩∩</span>
<span class="s2">&quot;&quot;&quot;</span>
<span class="c1"># This message lets us know our map was created successfully.</span>
<span class="n">caller</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;A map appears out of thin air and falls to the ground.&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>Log into your game project as the superuser and run the command</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@batchcode</span> <span class="n">batchcode_map</span>
</pre></div>
</div>
<p>This will load your <code class="docutils literal notranslate"><span class="pre">batchcode_map.py</span></code> file and execute the code (Evennia will look in your <code class="docutils literal notranslate"><span class="pre">world/</span></code>
folder automatically so you dont need to specify it).</p>
<p>A new map object should have appeared on the ground. You can view the map by using <code class="docutils literal notranslate"><span class="pre">look</span> <span class="pre">map</span></code>. Lets
take it with the <code class="docutils literal notranslate"><span class="pre">get</span> <span class="pre">map</span></code> command. Well need it in case we get lost!</p>
</section>
<section id="building-the-map-areas">
<h2>Building the map areas<a class="headerlink" href="#building-the-map-areas" title="Permalink to this headline"></a></h2>
<p>Weve just used batchcode to create an object useful for our adventures. But the locations on that
map does not actually exist yet - were all mapped up with nowhere to go! Lets use batchcode to
build a game area based on our map. We have five areas outlined: a castle, a cottage, a campsite, a
coastal beach and the crossroads which connects them. Create a new batchcode file for this in
<code class="docutils literal notranslate"><span class="pre">mygame/world</span></code>, named <code class="docutils literal notranslate"><span class="pre">batchcode_world.py</span></code>.</p>
<div class="highlight-Python notranslate"><div class="highlight"><pre><span></span><span class="c1"># mygame/world/batchcode_world.py</span>
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">create_object</span><span class="p">,</span> <span class="n">search_object</span>
<span class="kn">from</span> <span class="nn">typeclasses</span> <span class="kn">import</span> <span class="n">rooms</span><span class="p">,</span> <span class="n">exits</span>
<span class="c1"># We begin by creating our rooms so we can detail them later.</span>
<span class="n">centre</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">rooms</span><span class="o">.</span><span class="n">Room</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;crossroads&quot;</span><span class="p">)</span>
<span class="n">north</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">rooms</span><span class="o">.</span><span class="n">Room</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;castle&quot;</span><span class="p">)</span>
<span class="n">east</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">rooms</span><span class="o">.</span><span class="n">Room</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;cottage&quot;</span><span class="p">)</span>
<span class="n">south</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">rooms</span><span class="o">.</span><span class="n">Room</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;camp&quot;</span><span class="p">)</span>
<span class="n">west</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">rooms</span><span class="o">.</span><span class="n">Room</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;coast&quot;</span><span class="p">)</span>
<span class="c1"># This is where we set up the cross roads.</span>
<span class="c1"># The rooms description is what we see with the &#39;look&#39; command.</span>
<span class="n">centre</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;</span>
<span class="s2">The merger of two roads. A single lamp post dimly illuminates the lonely crossroads.</span>
<span class="s2">To the north looms a mighty castle. To the south the glow of a campfire can be seen.</span>
<span class="s2">To the east lie a wall of mountains and to the west the dull roar of the open sea.</span>
<span class="s2">&quot;&quot;&quot;</span>
<span class="c1"># Here we are creating exits from the centre &quot;crossroads&quot; location to </span>
<span class="c1"># destinations to the north, east, south, and west. We will be able </span>
<span class="c1"># to use the exit by typing it&#39;s key e.g. &quot;north&quot; or an alias e.g. &quot;n&quot;.</span>
<span class="n">centre_north</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;north&quot;</span><span class="p">,</span>
<span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;n&quot;</span><span class="p">],</span> <span class="n">location</span><span class="o">=</span><span class="n">centre</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">north</span><span class="p">)</span>
<span class="n">centre_east</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;east&quot;</span><span class="p">,</span>
<span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;e&quot;</span><span class="p">],</span> <span class="n">location</span><span class="o">=</span><span class="n">centre</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">east</span><span class="p">)</span>
<span class="n">centre_south</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;south&quot;</span><span class="p">,</span>
<span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;s&quot;</span><span class="p">],</span> <span class="n">location</span><span class="o">=</span><span class="n">centre</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">south</span><span class="p">)</span>
<span class="n">centre_west</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;west&quot;</span><span class="p">,</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> <span class="n">location</span><span class="o">=</span><span class="n">centre</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">west</span><span class="p">)</span>
<span class="c1"># Now we repeat this for the other rooms we&#39;ll be implementing.</span>
<span class="c1"># This is where we set up the northern castle.</span>
<span class="n">north</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="s2">&quot;An impressive castle surrounds you. &quot;</span> \
<span class="s2">&quot;There might be a princess in one of these towers.&quot;</span>
<span class="n">north_south</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;south&quot;</span><span class="p">,</span>
<span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;s&quot;</span><span class="p">],</span> <span class="n">location</span><span class="o">=</span><span class="n">north</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">centre</span><span class="p">)</span>
<span class="c1"># This is where we set up the eastern cottage.</span>
<span class="n">east</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="s2">&quot;A cosy cottage nestled among mountains &quot;</span> \
<span class="s2">&quot;stretching east as far as the eye can see.&quot;</span>
<span class="n">east_west</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;west&quot;</span><span class="p">,</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> <span class="n">location</span><span class="o">=</span><span class="n">east</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">centre</span><span class="p">)</span>
<span class="c1"># This is where we set up the southern camp.</span>
<span class="n">south</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="s2">&quot;Surrounding a clearing are a number of &quot;</span> \
<span class="s2">&quot;tribal tents and at their centre a roaring fire.&quot;</span>
<span class="n">south_north</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;north&quot;</span><span class="p">,</span>
<span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;n&quot;</span><span class="p">],</span> <span class="n">location</span><span class="o">=</span><span class="n">south</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">centre</span><span class="p">)</span>
<span class="c1"># This is where we set up the western coast.</span>
<span class="n">west</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="s2">&quot;The dark forest halts to a sandy beach. &quot;</span> \
<span class="s2">&quot;The sound of crashing waves calms the soul.&quot;</span>
<span class="n">west_east</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;east&quot;</span><span class="p">,</span>
<span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;e&quot;</span><span class="p">],</span> <span class="n">location</span><span class="o">=</span><span class="n">west</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">centre</span><span class="p">)</span>
<span class="c1"># Lastly, lets make an entrance to our world from the default Limbo room.</span>
<span class="n">limbo</span> <span class="o">=</span> <span class="n">search_object</span><span class="p">(</span><span class="s1">&#39;Limbo&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">limbo_exit</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">exits</span><span class="o">.</span><span class="n">Exit</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;enter world&quot;</span><span class="p">,</span>
<span class="n">aliases</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;enter&quot;</span><span class="p">],</span> <span class="n">location</span><span class="o">=</span><span class="n">limbo</span><span class="p">,</span> <span class="n">destination</span><span class="o">=</span><span class="n">centre</span><span class="p">)</span>
</pre></div>
</div>
<p>Apply this new batch code with <code class="docutils literal notranslate"><span class="pre">&#64;batchcode</span> <span class="pre">batchcode_world</span></code>. If there are no errors in the code we
now have a nice mini-world to explore. Remember that if you get lost you can look at the map we
created!</p>
</section>
<section id="in-game-minimap">
<h2>In-game minimap<a class="headerlink" href="#in-game-minimap" title="Permalink to this headline"></a></h2>
<p>Now we have a landscape and matching map, but what we really want is a mini-map that displays
whenever we move to a room or use the <code class="docutils literal notranslate"><span class="pre">look</span></code> command.</p>
<p>We <em>could</em> manually enter a part of the map into the description of every room like we did our map
object description. But some MUDs have tens of thousands of rooms! Besides, if we ever changed our
map we would have to potentially alter a lot of those room descriptions manually to match the
change. So instead we will make one central module to hold our map. Rooms will reference this
central location on creation and the map changes will thus come into effect when next running our
batchcode.</p>
<p>To make our mini-map we need to be able to cut our full map into parts. To do this we need to put it
in a format which allows us to do that easily. Luckily, python allows us to treat strings as lists
of characters allowing us to pick out the characters we need.</p>
<p><code class="docutils literal notranslate"><span class="pre">mygame/world/map_module.py</span></code></p>
<div class="highlight-Python notranslate"><div class="highlight"><pre><span></span><span class="c1"># We place our map into a sting here.</span>
<span class="n">world_map</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;</span><span class="se">\</span>
<span class="s2">≈≈↑↑↑↑↑∩∩</span>
<span class="s2">≈≈↑╔═╗↑∩∩</span>
<span class="s2">≈≈↑║O║↑∩∩</span>
<span class="s2">≈≈↑╚∞╝↑∩∩</span>
<span class="s2">≈≈≈↑│↑∩∩∩</span>
<span class="s2">≈≈O─O─O⌂∩</span>
<span class="s2">≈≈≈↑│↑∩∩∩</span>
<span class="s2">≈≈↑▲O▲↑∩∩</span>
<span class="s2">≈≈↑↑▲↑↑∩∩</span>
<span class="s2">≈≈↑↑↑↑↑∩∩</span>
<span class="s2">&quot;&quot;&quot;</span>
<span class="c1"># This turns our map string into a list of rows. Because python </span>
<span class="c1"># allows us to treat strings as a list of characters, we can access </span>
<span class="c1"># those characters with world_map[5][5] where world_map[row][column].</span>
<span class="n">world_map</span> <span class="o">=</span> <span class="n">world_map</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">return_map</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> This function returns the whole map</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">map</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="c1">#For each row in our map, add it to map</span>
<span class="k">for</span> <span class="n">valuey</span> <span class="ow">in</span> <span class="n">world_map</span><span class="p">:</span>
<span class="nb">map</span> <span class="o">+=</span> <span class="n">valuey</span>
<span class="nb">map</span> <span class="o">+=</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="k">return</span> <span class="nb">map</span>
<span class="k">def</span> <span class="nf">return_minimap</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">radius</span> <span class="o">=</span> <span class="mi">2</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> This function returns only part of the map.</span>
<span class="sd"> Returning all chars in a 2 char radius from (x,y)</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">map</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="c1">#For each row we need, add the characters we need.</span>
<span class="k">for</span> <span class="n">valuey</span> <span class="ow">in</span> <span class="n">world_map</span><span class="p">[</span><span class="n">y</span><span class="o">-</span><span class="n">radius</span><span class="p">:</span><span class="n">y</span><span class="o">+</span><span class="n">radius</span><span class="o">+</span><span class="mi">1</span><span class="p">]:</span> <span class="k">for</span> <span class="n">valuex</span> <span class="ow">in</span> <span class="n">valuey</span><span class="p">[</span><span class="n">x</span><span class="o">-</span><span class="n">radius</span><span class="p">:</span><span class="n">x</span><span class="o">+</span><span class="n">radius</span><span class="o">+</span><span class="mi">1</span><span class="p">]:</span>
<span class="nb">map</span> <span class="o">+=</span> <span class="n">valuex</span>
<span class="nb">map</span> <span class="o">+=</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="k">return</span> <span class="nb">map</span>
</pre></div>
</div>
<p>With our map_module set up, lets replace our hardcoded map in <code class="docutils literal notranslate"><span class="pre">mygame/world/batchcode_map.py</span></code> with
a reference to our map module. Make sure to import our map_module!</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># mygame/world/batchcode_map.py</span>
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">create_object</span>
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">DefaultObject</span>
<span class="kn">from</span> <span class="nn">world</span> <span class="kn">import</span> <span class="n">map_module</span>
<span class="nb">map</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">DefaultObject</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">&quot;Map&quot;</span><span class="p">,</span> <span class="n">location</span><span class="o">=</span><span class="n">caller</span><span class="o">.</span><span class="n">location</span><span class="p">)</span>
<span class="nb">map</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="n">map_module</span><span class="o">.</span><span class="n">return_map</span><span class="p">()</span>
<span class="n">caller</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;A map appears out of thin air and falls to the ground.&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>Log into Evennia as the superuser and run this batchcode. If everything worked our new map should
look exactly the same as the old map - you can use <code class="docutils literal notranslate"><span class="pre">&#64;delete</span></code> to delete the old one (use a number to
pick which to delete).</p>
<p>Now, lets turn our attention towards our games rooms. Lets use the <code class="docutils literal notranslate"><span class="pre">return_minimap</span></code> method we
created above in order to include a minimap in our room descriptions. This is a little more
complicated.</p>
<p>By itself we would have to settle for either the map being <em>above</em> the description with
<code class="docutils literal notranslate"><span class="pre">room.db.desc</span> <span class="pre">=</span> <span class="pre">map_string</span> <span class="pre">+</span> <span class="pre">description_string</span></code>, or the map going <em>below</em> by reversing their order.
Both options are rather unsatisfactory - we would like to have the map next to the text! For this
solution well explore the utilities that ship with Evennia. Tucked away in <code class="docutils literal notranslate"><span class="pre">evennia\evennia\utils</span></code>
is a little module called <a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia.utils.evtable">EvTable</a> . This is an advanced ASCII table
creator for you to utilize in your game. Well use it by creating a basic table with 1 row and two
columns (one for our map and one for our text) whilst also hiding the borders. Open the batchfile
again</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># mygame\world\batchcode_world.py</span>
<span class="c1"># Add to imports</span>
<span class="kn">from</span> <span class="nn">evennia.utils</span> <span class="kn">import</span> <span class="n">evtable</span>
<span class="kn">from</span> <span class="nn">world</span> <span class="kn">import</span> <span class="n">map_module</span>
<span class="c1"># [...]</span>
<span class="c1"># Replace the descriptions with the below code.</span>
<span class="c1"># The cross roads.</span>
<span class="c1"># We pass what we want in our table and EvTable does the rest.</span>
<span class="c1"># Passing two arguments will create two columns but we could add more.</span>
<span class="c1"># We also specify no border.</span>
<span class="n">centre</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="n">evtable</span><span class="o">.</span><span class="n">EvTable</span><span class="p">(</span><span class="n">map_module</span><span class="o">.</span><span class="n">return_minimap</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span>
<span class="s2">&quot;The merger of two roads. A single lamp post dimly &quot;</span> \
<span class="s2">&quot;illuminates the lonely crossroads. To the north &quot;</span> \
<span class="s2">&quot;looms a mighty castle. To the south the glow of &quot;</span> \
<span class="s2">&quot;a campfire can be seen. To the east lie a wall of &quot;</span> \
<span class="s2">&quot;mountains and to the west the dull roar of the open sea.&quot;</span><span class="p">,</span>
<span class="n">border</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
<span class="c1"># EvTable allows formatting individual columns and cells. We use that here</span>
<span class="c1"># to set a maximum width for our description, but letting the map fill</span>
<span class="c1"># whatever space it needs. </span>
<span class="n">centre</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span><span class="o">.</span><span class="n">reformat_column</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="mi">70</span><span class="p">)</span>
<span class="c1"># [...]</span>
<span class="c1"># The northern castle.</span>
<span class="n">north</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="n">evtable</span><span class="o">.</span><span class="n">EvTable</span><span class="p">(</span><span class="n">map_module</span><span class="o">.</span><span class="n">return_minimap</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span><span class="mi">2</span><span class="p">),</span>
<span class="s2">&quot;An impressive castle surrounds you. There might be &quot;</span> \
<span class="s2">&quot;a princess in one of these towers.&quot;</span><span class="p">,</span>
<span class="n">border</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
<span class="n">north</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span><span class="o">.</span><span class="n">reformat_column</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="mi">70</span><span class="p">)</span>
<span class="c1"># [...]</span>
<span class="c1"># The eastern cottage.</span>
<span class="n">east</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="n">evtable</span><span class="o">.</span><span class="n">EvTable</span><span class="p">(</span><span class="n">map_module</span><span class="o">.</span><span class="n">return_minimap</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span>
<span class="s2">&quot;A cosy cottage nestled among mountains stretching &quot;</span> \
<span class="s2">&quot;east as far as the eye can see.&quot;</span><span class="p">,</span>
<span class="n">border</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
<span class="n">east</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span><span class="o">.</span><span class="n">reformat_column</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="mi">70</span><span class="p">)</span>
<span class="c1"># [...]</span>
<span class="c1"># The southern camp.</span>
<span class="n">south</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="n">evtable</span><span class="o">.</span><span class="n">EvTable</span><span class="p">(</span><span class="n">map_module</span><span class="o">.</span><span class="n">return_minimap</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span><span class="mi">7</span><span class="p">),</span>
<span class="s2">&quot;Surrounding a clearing are a number of tribal tents &quot;</span> \
<span class="s2">&quot;and at their centre a roaring fire.&quot;</span><span class="p">,</span>
<span class="n">border</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
<span class="n">south</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span><span class="o">.</span><span class="n">reformat_column</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="mi">70</span><span class="p">)</span>
<span class="c1"># [...]</span>
<span class="c1"># The western coast.</span>
<span class="n">west</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span> <span class="o">=</span> <span class="n">evtable</span><span class="o">.</span><span class="n">EvTable</span><span class="p">(</span><span class="n">map_module</span><span class="o">.</span><span class="n">return_minimap</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span>
<span class="s2">&quot;The dark forest halts to a sandy beach. The sound of &quot;</span> \
<span class="s2">&quot;crashing waves calms the soul.&quot;</span><span class="p">,</span>
<span class="n">border</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
<span class="n">west</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">desc</span><span class="o">.</span><span class="n">reformat_column</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="mi">70</span><span class="p">)</span>
</pre></div>
</div>
<p>Before we run our new batchcode, if you are anything like me you would have something like 100 maps
lying around and 3-4 different versions of our rooms extending from limbo. Lets wipe it all and
start with a clean slate. In Command Prompt you can run <code class="docutils literal notranslate"><span class="pre">evennia</span> <span class="pre">flush</span></code> to clear the database and
start anew. It wont reset dbref values however, so if you are at #100 it will start from there.
Alternatively you can navigate to <code class="docutils literal notranslate"><span class="pre">mygame/server</span></code> and delete the <code class="docutils literal notranslate"><span class="pre">evennia.db3</span></code> file. Now in Command
Prompt use <code class="docutils literal notranslate"><span class="pre">evennia</span> <span class="pre">migrate</span></code> to have a completely freshly made database.</p>
<p>Log in to evennia and run <code class="docutils literal notranslate"><span class="pre">&#64;batchcode</span> <span class="pre">batchcode_world</span></code> and youll have a little world to explore.</p>
</section>
<section id="conclusions">
<h2>Conclusions<a class="headerlink" href="#conclusions" title="Permalink to this headline"></a></h2>
<p>You should now have a mapped little world and a basic understanding of batchcode, EvTable and how
easily new game defining features can be added to Evennia.</p>
<p>You can easily build from this tutorial by expanding the map and creating more rooms to explore. Why
not add more features to your game by trying other tutorials: [Add weather to your world](Weather-
Tutorial), <a class="reference internal" href="../Howto/Tutorial-Aggressive-NPCs.html"><span class="doc std std-doc">fill your world with NPCs</span></a> or
<a class="reference internal" href="../Howto/Starting/Part3/Turn-based-Combat-System.html"><span class="doc std std-doc">implement a combat system</span></a>.</p>
</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="#">Static In Game Map</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#planning-the-map">Planning the Map</a></li>
<li><a class="reference internal" href="#creating-a-map-object">Creating a Map Object</a></li>
<li><a class="reference internal" href="#building-the-map-areas">Building the map areas</a></li>
<li><a class="reference internal" href="#in-game-minimap">In-game minimap</a></li>
<li><a class="reference internal" href="#conclusions">Conclusions</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Dynamic-In-Game-Map.html"
title="previous chapter">Dynamic In Game Map</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Building-menus.html"
title="next chapter">Building menus</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Static-In-Game-Map.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="Static-In-Game-Map.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="right" >
<a href="Building-menus.html" title="Building menus"
>next</a> |</li>
<li class="right" >
<a href="Dynamic-In-Game-Map.html" title="Dynamic In Game Map"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="Contrib-Overview.html" >Contrib modules</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Static In Game Map</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>