Revert "Updated HTML docs."

This reverts commit 51d5840b8b.
This commit is contained in:
Griatch 2022-11-14 22:43:45 +01:00
parent 51d5840b8b
commit e34f258a92
2504 changed files with 820160 additions and 0 deletions

View file

@ -0,0 +1,363 @@
<!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>
<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 menu" href="Contrib-Building-Menu.html" />
<link rel="prev" title="Contribs" href="Contribs-Overview.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="Contrib-Building-Menu.html" title="Building menu"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contribs-Overview.html" title="Contribs"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<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>
</ul>
</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>
<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>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contribs-Overview.html"
title="previous chapter">Contribs</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Building-Menu.html"
title="next chapter">Building menu</a></p>
<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="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 id="technical-details">
<h2>Technical details<a class="headerlink" href="#technical-details" title="Permalink to this headline"></a></h2>
<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 id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<section id="set-up-aws-account">
<h3>Set up AWS account<a class="headerlink" href="#set-up-aws-account" title="Permalink to this headline"></a></h3>
<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>
<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 id="uninstallation">
<h2>Uninstallation<a class="headerlink" href="#uninstallation" title="Permalink to this headline"></a></h2>
<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 id="license">
<h2>License<a class="headerlink" href="#license" title="Permalink to this headline"></a></h2>
<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 id="versioning">
<h2>Versioning<a class="headerlink" href="#versioning" title="Permalink to this headline"></a></h2>
<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>
</section>
</div>
</div>
</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="Contrib-Building-Menu.html" title="Building menu"
>next</a> |</li>
<li class="right" >
<a href="Contribs-Overview.html" title="Contribs"
>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="Contribs-Overview.html" >Contribs</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,210 @@
<!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>
<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="Easy fillable form" href="Contrib-Fieldfill.html" />
<link rel="prev" title="Evennia Tutorial World" href="Contrib-Tutorial-World.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="Contrib-Fieldfill.html" title="Easy fillable form"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Tutorial-World.html" title="Evennia Tutorial World"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Tutorial-World.html"
title="previous chapter">Evennia Tutorial World</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Fieldfill.html"
title="next chapter">Easy fillable form</a></p>
<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="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>
</div>
</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="Contrib-Fieldfill.html" title="Easy fillable form"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Tutorial-World.html" title="Evennia Tutorial World"
>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="Contribs-Overview.html" >Contribs</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,249 @@
<!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>
<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="Clothing" href="Contrib-Clothing.html" />
<link rel="prev" title="EvscapeRoom" href="Contrib-Evscaperoom.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="Contrib-Clothing.html" title="Clothing"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Evscaperoom.html" title="EvscapeRoom"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Evscaperoom.html"
title="previous chapter">EvscapeRoom</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Clothing.html"
title="next chapter">Clothing</a></p>
<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="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>
</div>
</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="Contrib-Clothing.html" title="Clothing"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Evscaperoom.html" title="EvscapeRoom"
>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="Contribs-Overview.html" >Contribs</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,175 @@
<!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>
<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="Script example" href="Contrib-Bodyfunctions.html" />
<link rel="prev" title="Traits" href="Contrib-Traits.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="Contrib-Bodyfunctions.html" title="Script example"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Traits.html" title="Traits"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Traits.html"
title="previous chapter">Traits</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Bodyfunctions.html"
title="next chapter">Script example</a></p>
<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="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>
</div>
</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="Contrib-Bodyfunctions.html" title="Script example"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Traits.html" title="Traits"
>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="Contribs-Overview.html" >Contribs</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,157 @@
<!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>
<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="EvAdventure" href="Contrib-Evadventure.html" />
<link rel="prev" title="Batch processor examples" href="Contrib-Batchprocessor.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="Contrib-Evadventure.html" title="EvAdventure"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Batchprocessor.html" title="Batch processor examples"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Batchprocessor.html"
title="previous chapter">Batch processor examples</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Evadventure.html"
title="next chapter">EvAdventure</a></p>
<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="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>
</div>
</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="Contrib-Evadventure.html" title="EvAdventure"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Batchprocessor.html" title="Batch processor examples"
>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="Contribs-Overview.html" >Contribs</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,594 @@
<!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>Buffs &#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>
<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="Character Creator contrib" href="Contrib-Character-Creator.html" />
<link rel="prev" title="XYZgrid" href="Contrib-XYZGrid.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="Contrib-Character-Creator.html" title="Character Creator contrib"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-XYZGrid.html" title="XYZgrid"
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="Contribs-Overview.html" accesskey="U">Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Buffs</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Buffs</a><ul>
<li><a class="reference internal" href="#quick-start">Quick Start</a><ul>
<li><a class="reference internal" href="#customization">Customization</a></li>
</ul>
</li>
<li><a class="reference internal" href="#using-the-handler">Using the Handler</a><ul>
<li><a class="reference internal" href="#apply-a-buff">Apply a Buff</a></li>
<li><a class="reference internal" href="#get-buffs">Get Buffs</a></li>
<li><a class="reference internal" href="#remove-buffs">Remove Buffs</a></li>
<li><a class="reference internal" href="#check-modifiers">Check Modifiers</a><ul>
<li><a class="reference internal" href="#multiplicative-buffs-advanced">Multiplicative Buffs (Advanced)</a></li>
<li><a class="reference internal" href="#buff-strength-priority-advanced">Buff Strength Priority (Advanced)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#trigger-buffs">Trigger Buffs</a></li>
<li><a class="reference internal" href="#ticking">Ticking</a></li>
<li><a class="reference internal" href="#context">Context</a></li>
<li><a class="reference internal" href="#viewing">Viewing</a></li>
</ul>
</li>
<li><a class="reference internal" href="#creating-new-buffs">Creating New Buffs</a><ul>
<li><a class="reference internal" href="#basics">Basics</a><ul>
<li><a class="reference internal" href="#buff-cache-advanced">Buff Cache (Advanced)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#modifiers">Modifiers</a><ul>
<li><a class="reference internal" href="#generating-mods-advanced">Generating Mods (Advanced)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#triggers">Triggers</a></li>
<li><a class="reference internal" href="#id1">Ticking</a></li>
<li><a class="reference internal" href="#extras">Extras</a><ul>
<li><a class="reference internal" href="#conditionals">Conditionals</a></li>
<li><a class="reference internal" href="#helper-methods">Helper Methods</a></li>
<li><a class="reference internal" href="#playtime-duration">Playtime Duration</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-XYZGrid.html"
title="previous chapter">XYZgrid</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Character-Creator.html"
title="next chapter">Character Creator contrib</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Buffs.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-Buffs.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="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="buffs">
<h1>Buffs<a class="headerlink" href="#buffs" title="Permalink to this headline"></a></h1>
<p>Contribution by Tegiminis 2022</p>
<p>A buff is a timed object, attached to a game entity. It is capable of modifying values, triggering code, or both.
It is a common design pattern in RPGs, particularly action games.</p>
<p>Features:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">BuffHandler</span></code>: A buff handler to apply to your objects.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">BaseBuff</span></code>: A buff class to extend from to create your own buffs.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">BuffableProperty</span></code>: A sample property class to show how to automatically check modifiers.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">CmdBuff</span></code>: A command which applies buffs.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">samplebuffs.py</span></code>: Some sample buffs to learn from.</p></li>
</ul>
<section id="quick-start">
<h2>Quick Start<a class="headerlink" href="#quick-start" title="Permalink to this headline"></a></h2>
<p>Assign the handler to a property on the object, like so.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@lazy_property</span>
<span class="k">def</span> <span class="nf">buffs</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">BuffHandler</span><span class="p">:</span>
<span class="k">return</span> <span class="n">BuffHandler</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
</pre></div>
</div>
<p>You may then call the handler to add or manipulate buffs like so: <code class="docutils literal notranslate"><span class="pre">object.buffs</span></code>. See <strong>Using the Handler</strong>.</p>
<section id="customization">
<h3>Customization<a class="headerlink" href="#customization" title="Permalink to this headline"></a></h3>
<p>If you want to customize the handler, you can feed the constructor two arguments:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">dbkey</span></code>: The string you wish to use as the attribute key for the buff database. Defaults to “buffs”. This allows you to keep separate buff pools - for example, “buffs” and “perks”.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">autopause</span></code>: If you want this handler to automatically pause playtime buffs when its owning object is unpuppeted.</p></li>
</ul>
<blockquote>
<div><p><strong>Note</strong>: If you enable autopausing, you MUST initialize the property in your owning objects
<code class="docutils literal notranslate"><span class="pre">at_init</span></code> hook. Otherwise, a hot reload can cause playtime buffs to not update properly
on puppet/unpuppet. You have been warned!</p>
</div></blockquote>
<p>Lets say you want another handler for an object, <code class="docutils literal notranslate"><span class="pre">perks</span></code>, which has a separate database and
respects playtime buffs. Youd assign this new property as so:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">BuffableObject</span><span class="p">(</span><span class="n">Object</span><span class="p">):</span>
<span class="nd">@lazy_property</span>
<span class="k">def</span> <span class="nf">perks</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">BuffHandler</span><span class="p">:</span>
<span class="k">return</span> <span class="n">BuffHandler</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dbkey</span><span class="o">=</span><span class="s1">&#39;perks&#39;</span><span class="p">,</span> <span class="n">autopause</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">at_init</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">perks</span>
</pre></div>
</div>
</section>
</section>
<section id="using-the-handler">
<h2>Using the Handler<a class="headerlink" href="#using-the-handler" title="Permalink to this headline"></a></h2>
<p>Heres how to make use of your new handler.</p>
<section id="apply-a-buff">
<h3>Apply a Buff<a class="headerlink" href="#apply-a-buff" title="Permalink to this headline"></a></h3>
<p>Call the handlers <code class="docutils literal notranslate"><span class="pre">add</span></code> method. This requires a class reference, and also contains a number of
optional arguments to customize the buffs duration, stacks, and so on. You can also store any arbitrary value
in the buffs cache by passing a dictionary through the <code class="docutils literal notranslate"><span class="pre">to_cache</span></code> optional argument. This will not overwrite the normal
values on the cache.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="bp">self</span><span class="o">.</span><span class="n">buffs</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">StrengthBuff</span><span class="p">)</span> <span class="c1"># A single stack of StrengthBuff with normal duration</span>
<span class="bp">self</span><span class="o">.</span><span class="n">buffs</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">DexBuff</span><span class="p">,</span> <span class="n">stacks</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">duration</span><span class="o">=</span><span class="mi">60</span><span class="p">)</span> <span class="c1"># Three stacks of DexBuff, with a duration of 60 seconds</span>
<span class="bp">self</span><span class="o">.</span><span class="n">buffs</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">ReflectBuff</span><span class="p">,</span> <span class="n">to_cache</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;reflect&#39;</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">})</span> <span class="c1"># A single stack of ReflectBuff, with an extra cache value</span>
</pre></div>
</div>
<p>Two important attributes on the buff are checked when the buff is applied: <code class="docutils literal notranslate"><span class="pre">refresh</span></code> and <code class="docutils literal notranslate"><span class="pre">unique</span></code>.</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">refresh</span></code> (default: True) determines if a buffs timer is refreshed when it is reapplied.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">unique</span></code> (default: True) determines if this buff is unique; that is, only one of it exists on the object.</p></li>
</ul>
<p>The combination of these two booleans creates one of three kinds of keys:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">Unique</span> <span class="pre">is</span> <span class="pre">True,</span> <span class="pre">Refresh</span> <span class="pre">is</span> <span class="pre">True/False</span></code>: The buffs default key.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">Unique</span> <span class="pre">is</span> <span class="pre">False,</span> <span class="pre">Refresh</span> <span class="pre">is</span> <span class="pre">True</span></code>: The default key mixed with the appliers dbref. This makes the buff “unique-per-player”, so you can refresh through reapplication.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">Unique</span> <span class="pre">is</span> <span class="pre">False,</span> <span class="pre">Refresh</span> <span class="pre">is</span> <span class="pre">False</span></code>: The default key mixed with a randomized number.</p></li>
</ul>
</section>
<section id="get-buffs">
<h3>Get Buffs<a class="headerlink" href="#get-buffs" title="Permalink to this headline"></a></h3>
<p>The handler has several getter methods which return instanced buffs. You wont need to use these for basic functionality, but if you want to manipulate
buffs after application, they are very useful. The handlers <code class="docutils literal notranslate"><span class="pre">check</span></code>/<code class="docutils literal notranslate"><span class="pre">trigger</span></code> methods utilize some of these getters, while others are just for developer convenience.</p>
<p><code class="docutils literal notranslate"><span class="pre">get(key)</span></code> is the most basic getter. It returns a single buff instance, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if the buff doesnt exist on the handler. It is also the only getter
that returns a single buff instance, rather than a dictionary.</p>
<blockquote>
<div><p><strong>Note</strong>: The handler method <code class="docutils literal notranslate"><span class="pre">has(buff)</span></code> allows you to check if a matching key (if a string) or buff class (if a class) is present on the handler cache, without actually instantiating the buff. You should use this method for basic “is this buff present?” checks.</p>
</div></blockquote>
<p>Group getters, listed below, return a dictionary of values in the format <code class="docutils literal notranslate"><span class="pre">{buffkey:</span> <span class="pre">instance}</span></code>. If you want to iterate over all of these buffs,
you should do so via the <code class="docutils literal notranslate"><span class="pre">dict.values()</span></code> method.</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">get_all()</span></code> returns all buffs on this handler. You can also use the <code class="docutils literal notranslate"><span class="pre">handler.all</span></code> property.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">get_by_type(BuffClass)</span></code> returns buffs of the specified type.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">get_by_stat(stat)</span></code> returns buffs with a <code class="docutils literal notranslate"><span class="pre">Mod</span></code> object of the specified <code class="docutils literal notranslate"><span class="pre">stat</span></code> string in their <code class="docutils literal notranslate"><span class="pre">mods</span></code> list.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">get_by_trigger(string)</span></code> returns buffs with the specified string in their <code class="docutils literal notranslate"><span class="pre">triggers</span></code> list.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">get_by_source(Object)</span></code> returns buffs applied by the specified <code class="docutils literal notranslate"><span class="pre">source</span></code> object.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">get_by_cachevalue(key,</span> <span class="pre">value)</span></code> returns buffs with the matching <code class="docutils literal notranslate"><span class="pre">key:</span> <span class="pre">value</span></code> pair in their cache. <code class="docutils literal notranslate"><span class="pre">value</span></code> is optional.</p></li>
</ul>
<p>All group getters besides <code class="docutils literal notranslate"><span class="pre">get_all()</span></code> can “slice” an existing dictionary through the optional <code class="docutils literal notranslate"><span class="pre">to_filter</span></code> argument.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">dict1</span> <span class="o">=</span> <span class="n">handler</span><span class="o">.</span><span class="n">get_by_type</span><span class="p">(</span><span class="n">Burned</span><span class="p">)</span> <span class="c1"># This finds all &quot;Burned&quot; buffs on the handler</span>
<span class="n">dict2</span> <span class="o">=</span> <span class="n">handler</span><span class="o">.</span><span class="n">get_by_source</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_filter</span><span class="o">=</span><span class="n">dict1</span><span class="p">)</span> <span class="c1"># This filters dict1 to find buffs with the matching source</span>
</pre></div>
</div>
<blockquote>
<div><p><strong>Note</strong>: Most of these getters also have an associated handler property. For example, <code class="docutils literal notranslate"><span class="pre">handler.effects</span></code> returns all buffs that can be triggered, which
is then iterated over by the <code class="docutils literal notranslate"><span class="pre">get_by_trigger</span></code> method.</p>
</div></blockquote>
</section>
<section id="remove-buffs">
<h3>Remove Buffs<a class="headerlink" href="#remove-buffs" title="Permalink to this headline"></a></h3>
<p>There are also a number of remover methods. Generally speaking, these follow the same format as the getters.</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">remove(key)</span></code> removes the buff with the specified key.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">clear()</span></code> removes all buffs.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">remove_by_type(BuffClass)</span></code> removes buffs of the specified type.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">remove_by_stat(stat)</span></code> removes buffs with a <code class="docutils literal notranslate"><span class="pre">Mod</span></code> object of the specified <code class="docutils literal notranslate"><span class="pre">stat</span></code> string in their <code class="docutils literal notranslate"><span class="pre">mods</span></code> list.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">remove_by_trigger(string)</span></code> removes buffs with the specified string in their <code class="docutils literal notranslate"><span class="pre">triggers</span></code> list.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">remove_by_source(Object)</span></code> removes buffs applied by the specified source</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">remove_by_cachevalue(key,</span> <span class="pre">value)</span></code> removes buffs with the matching <code class="docutils literal notranslate"><span class="pre">key:</span> <span class="pre">value</span></code> pair in their cache. <code class="docutils literal notranslate"><span class="pre">value</span></code> is optional.</p></li>
</ul>
<p>You can also remove a buff by calling the instances <code class="docutils literal notranslate"><span class="pre">remove</span></code> helper method. You can do this on the dictionaries returned by the
getters listed above.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">to_remove</span> <span class="o">=</span> <span class="n">handler</span><span class="o">.</span><span class="n">get_by_trigger</span><span class="p">(</span><span class="n">trigger</span><span class="p">)</span> <span class="c1"># Finds all buffs with the specified trigger</span>
<span class="k">for</span> <span class="n">buff</span> <span class="ow">in</span> <span class="n">to_remove</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> <span class="c1"># Removes all buffs in the to_remove dictionary via helper methods</span>
<span class="n">buff</span><span class="o">.</span><span class="n">remove</span><span class="p">()</span>
</pre></div>
</div>
</section>
<section id="check-modifiers">
<h3>Check Modifiers<a class="headerlink" href="#check-modifiers" title="Permalink to this headline"></a></h3>
<p>Call the handler <code class="docutils literal notranslate"><span class="pre">check(value,</span> <span class="pre">stat)</span></code> method when you want to see the modified value.
This will return the <code class="docutils literal notranslate"><span class="pre">value</span></code>, modified by any relevant buffs on the handlers owner (identified by
the <code class="docutils literal notranslate"><span class="pre">stat</span></code> string).</p>
<p>For example, lets say you want to modify how much damage you take. That might look something like this:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># The method we call to damage ourselves</span>
<span class="k">def</span> <span class="nf">take_damage</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">source</span><span class="p">,</span> <span class="n">damage</span><span class="p">):</span>
<span class="n">_damage</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">buffs</span><span class="o">.</span><span class="n">check</span><span class="p">(</span><span class="n">damage</span><span class="p">,</span> <span class="s1">&#39;taken_damage&#39;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">health</span> <span class="o">-=</span> <span class="n">_damage</span>
</pre></div>
</div>
<p>This method calls the <code class="docutils literal notranslate"><span class="pre">at_pre_check</span></code> and <code class="docutils literal notranslate"><span class="pre">at_post_check</span></code> methods at the relevant points in the process. You can use to this make
buffs that are reactive to being checked; for example, removing themselves, altering their values, or interacting with the game state.</p>
<blockquote>
<div><p><strong>Note</strong>: You can also trigger relevant buffs at the same time as you check them by ensuring the optional argument <code class="docutils literal notranslate"><span class="pre">trigger</span></code> is True in the <code class="docutils literal notranslate"><span class="pre">check</span></code> method.</p>
</div></blockquote>
<p>Modifiers are calculated additively - that is, all modifiers of the same type are added together before being applied. They are then
applied through the following formula.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">base</span> <span class="o">+</span> <span class="n">total_add</span><span class="p">)</span> <span class="o">/</span> <span class="nb">max</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mf">1.0</span> <span class="o">+</span> <span class="n">total_div</span><span class="p">)</span> <span class="o">*</span> <span class="nb">max</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mf">1.0</span> <span class="o">+</span> <span class="n">total_mult</span><span class="p">)</span>
</pre></div>
</div>
<section id="multiplicative-buffs-advanced">
<h4>Multiplicative Buffs (Advanced)<a class="headerlink" href="#multiplicative-buffs-advanced" title="Permalink to this headline"></a></h4>
<p>Multiply/divide modifiers in this buff system are additive by default. This means that two +50% modifiers will equal a +100% modifier. But what if you want to apply mods multiplicatively?</p>
<p>First, you should carefully consider if you truly want multiplicative modifiers. Heres some things to consider.</p>
<ul class="simple">
<li><p>They are unintuitive to the average user, as two +50% damage buffs equal +125% instead of +100%.</p></li>
<li><p>They lead to “power explosion”, where stacking buffs in the right way can turn characters into unstoppable forces</p></li>
</ul>
<p>Doing purely-additive multipliers allows you to better control the balance of your game. Conversely, doing multiplicative multipliers enables very fun build-crafting where smart usage of buffs and skills can turn you into a one-shot powerhouse. Each has its place.</p>
<p>The best design practice for multiplicative buffs is to divide your multipliers into “tiers”, where each tier is applied separately. You can easily do this with multiple <code class="docutils literal notranslate"><span class="pre">check</span></code> calls.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">damage</span> <span class="o">=</span> <span class="n">damage</span>
<span class="n">damage</span> <span class="o">=</span> <span class="n">handler</span><span class="o">.</span><span class="n">check</span><span class="p">(</span><span class="n">damage</span><span class="p">,</span> <span class="s1">&#39;damage&#39;</span><span class="p">)</span>
<span class="n">damage</span> <span class="o">=</span> <span class="n">handler</span><span class="o">.</span><span class="n">check</span><span class="p">(</span><span class="n">damage</span><span class="p">,</span> <span class="s1">&#39;empower&#39;</span><span class="p">)</span>
<span class="n">damage</span> <span class="o">=</span> <span class="n">handler</span><span class="o">.</span><span class="n">check</span><span class="p">(</span><span class="n">damage</span><span class="p">,</span> <span class="s1">&#39;radiant&#39;</span><span class="p">)</span>
<span class="n">damage</span> <span class="o">=</span> <span class="n">handler</span><span class="o">.</span><span class="n">check</span><span class="p">(</span><span class="n">damage</span><span class="p">,</span> <span class="s1">&#39;overpower&#39;</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="buff-strength-priority-advanced">
<h4>Buff Strength Priority (Advanced)<a class="headerlink" href="#buff-strength-priority-advanced" title="Permalink to this headline"></a></h4>
<p>Sometimes you only want to apply the strongest modifier to a stat. This is supported by the optional <code class="docutils literal notranslate"><span class="pre">strongest</span></code> bool arg in the handlers check method</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">take_damage</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">source</span><span class="p">,</span> <span class="n">damage</span><span class="p">):</span>
<span class="n">_damage</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">buffs</span><span class="o">.</span><span class="n">check</span><span class="p">(</span><span class="n">damage</span><span class="p">,</span> <span class="s1">&#39;taken_damage&#39;</span><span class="p">,</span> <span class="n">strongest</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">health</span> <span class="o">-=</span> <span class="n">_damage</span>
</pre></div>
</div>
</section>
</section>
<section id="trigger-buffs">
<h3>Trigger Buffs<a class="headerlink" href="#trigger-buffs" title="Permalink to this headline"></a></h3>
<p>Call the handlers <code class="docutils literal notranslate"><span class="pre">trigger(string)</span></code> method when you want an event call. This will call the <code class="docutils literal notranslate"><span class="pre">at_trigger</span></code> hook method on all buffs with the relevant trigger <code class="docutils literal notranslate"><span class="pre">string</span></code>.</p>
<p>For example, lets say you want to trigger a buff to “detonate” when you hit your target with an attack.
Youd write a buff that might look like this:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Detonate</span><span class="p">(</span><span class="n">BaseBuff</span><span class="p">):</span>
<span class="o">...</span>
<span class="n">triggers</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;take_damage&#39;</span><span class="p">]</span>
<span class="k">def</span> <span class="nf">at_trigger</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">trigger</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">owner</span><span class="o">.</span><span class="n">take_damage</span><span class="p">(</span><span class="mi">100</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">remove</span><span class="p">()</span>
</pre></div>
</div>
<p>And then call <code class="docutils literal notranslate"><span class="pre">handler.trigger('take_damage')</span></code> in the method you use to take damage.</p>
<blockquote>
<div><p><strong>Note</strong> You could also do this through mods and <code class="docutils literal notranslate"><span class="pre">at_post_check</span></code> if you like, depending on how to want to add the damage.</p>
</div></blockquote>
</section>
<section id="ticking">
<h3>Ticking<a class="headerlink" href="#ticking" title="Permalink to this headline"></a></h3>
<p>Ticking buffs are slightly special. They are similar to trigger buffs in that they run code, but instead of
doing so on an event trigger, they do so on a periodic tick. A common use case for a buff like this is a poison,
or a heal over time.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Poison</span><span class="p">(</span><span class="n">BaseBuff</span><span class="p">):</span>
<span class="o">...</span>
<span class="n">tickrate</span> <span class="o">=</span> <span class="mi">5</span>
<span class="k">def</span> <span class="nf">at_tick</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">initial</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="n">_dmg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dmg</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">stacks</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">initial</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">owner</span><span class="o">.</span><span class="n">location</span><span class="o">.</span><span class="n">msg_contents</span><span class="p">(</span>
<span class="s2">&quot;Poison courses through </span><span class="si">{actor}</span><span class="s2">&#39;s body, dealing </span><span class="si">{damage}</span><span class="s2"> damage.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
<span class="n">actor</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">owner</span><span class="o">.</span><span class="n">named</span><span class="p">,</span> <span class="n">damage</span><span class="o">=</span><span class="n">_dmg</span>
<span class="p">)</span>
<span class="p">)</span>
</pre></div>
</div>
<p>To make a buff ticking, ensure the <code class="docutils literal notranslate"><span class="pre">tickrate</span></code> is 1 or higher, and it has code in its <code class="docutils literal notranslate"><span class="pre">at_tick</span></code>
method. Once you add it to the handler, it starts ticking!</p>
<blockquote>
<div><p><strong>Note</strong>: Ticking buffs always tick on initial application, when <code class="docutils literal notranslate"><span class="pre">initial</span></code> is <code class="docutils literal notranslate"><span class="pre">True</span></code>. If you dont want your hook to fire at that time,
make sure to check the value of <code class="docutils literal notranslate"><span class="pre">initial</span></code> in your <code class="docutils literal notranslate"><span class="pre">at_tick</span></code> method.</p>
</div></blockquote>
</section>
<section id="context">
<h3>Context<a class="headerlink" href="#context" title="Permalink to this headline"></a></h3>
<p>Every important handler method optionally accepts a <code class="docutils literal notranslate"><span class="pre">context</span></code> dictionary.</p>
<p>Context is an important concept for this handler. Every method which checks, triggers, or ticks a buff passes this
dictionary (default: empty) to the buff hook methods as keyword arguments (<code class="docutils literal notranslate"><span class="pre">**kwargs</span></code>). It is used for nothing else. This allows you to make those
methods “event-aware” by storing relevant data in the dictionary you feed to the method.</p>
<p>For example, lets say you want a “thorns” buff which damages enemies that attack you. Lets take our <code class="docutils literal notranslate"><span class="pre">take_damage</span></code> method
and add a context to the mix.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">take_damage</span><span class="p">(</span><span class="n">attacker</span><span class="p">,</span> <span class="n">damage</span><span class="p">):</span>
<span class="n">context</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;attacker&#39;</span><span class="p">:</span> <span class="n">attacker</span><span class="p">,</span> <span class="s1">&#39;damage&#39;</span><span class="p">:</span> <span class="n">damage</span><span class="p">}</span>
<span class="n">_damage</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">buffs</span><span class="o">.</span><span class="n">check</span><span class="p">(</span><span class="n">damage</span><span class="p">,</span> <span class="s1">&#39;taken_damage&#39;</span><span class="p">,</span> <span class="n">context</span><span class="o">=</span><span class="n">context</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">buffs</span><span class="o">.</span><span class="n">trigger</span><span class="p">(</span><span class="s1">&#39;taken_damage&#39;</span><span class="p">,</span> <span class="n">context</span><span class="o">=</span><span class="n">context</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">health</span> <span class="o">-=</span> <span class="n">_damage</span>
</pre></div>
</div>
<p>Now we use the values that context passes to the buff kwargs to customize our logic.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">ThornsBuff</span><span class="p">(</span><span class="n">BaseBuff</span><span class="p">):</span>
<span class="o">...</span>
<span class="n">triggers</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;taken_damage&#39;</span><span class="p">]</span>
<span class="c1"># This is the hook method on our thorns buff</span>
<span class="k">def</span> <span class="nf">at_trigger</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">trigger</span><span class="p">,</span> <span class="n">attacker</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">damage</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">attacker</span><span class="p">:</span>
<span class="k">return</span>
<span class="n">attacker</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">health</span> <span class="o">-=</span> <span class="n">damage</span> <span class="o">*</span> <span class="mf">0.2</span>
</pre></div>
</div>
<p>Apply the buff, take damage, and watch the thorns buff do its work!</p>
</section>
<section id="viewing">
<h3>Viewing<a class="headerlink" href="#viewing" title="Permalink to this headline"></a></h3>
<p>There are two helper methods on the handler that allow you to get useful buff information back.</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">view</span></code>: Returns a dictionary of tuples in the format <code class="docutils literal notranslate"><span class="pre">{buffkey:</span> <span class="pre">(buff.name,</span> <span class="pre">buff.flavor)}</span></code>. Finds all buffs by default, but optionally accepts a dictionary of buffs to filter as well. Useful for basic buff readouts.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">view_modifiers(stat)</span></code>: Returns a nested dictionary of information on modifiers that affect the specified stat. The first layer is the modifier type (<code class="docutils literal notranslate"><span class="pre">add/mult/div</span></code>) and the second layer is the value type (<code class="docutils literal notranslate"><span class="pre">total/strongest</span></code>). Does not return the buffs that cause these modifiers, just the modifiers themselves (akin to using <code class="docutils literal notranslate"><span class="pre">handler.check</span></code> but without actually modifying a value). Useful for stat sheets.</p></li>
</ul>
<p>You can also create your own custom viewing methods through the various handler getters, which will always return the entire buff object.</p>
</section>
</section>
<section id="creating-new-buffs">
<h2>Creating New Buffs<a class="headerlink" href="#creating-new-buffs" title="Permalink to this headline"></a></h2>
<p>Creating a new buff is very easy: extend <code class="docutils literal notranslate"><span class="pre">BaseBuff</span></code> into a new class, and fill in all the relevant buff details.
However, there are a lot of individual moving parts to a buff. Heres a step-through of the important stuff.</p>
<section id="basics">
<h3>Basics<a class="headerlink" href="#basics" title="Permalink to this headline"></a></h3>
<p>Regardless of any other functionality, all buffs have the following class attributes:</p>
<ul class="simple">
<li><p>They have customizable <code class="docutils literal notranslate"><span class="pre">key</span></code>, <code class="docutils literal notranslate"><span class="pre">name</span></code>, and <code class="docutils literal notranslate"><span class="pre">flavor</span></code> strings.</p></li>
<li><p>They have a <code class="docutils literal notranslate"><span class="pre">duration</span></code> (float), and automatically clean-up at the end. Use -1 for infinite duration, and 0 to clean-up immediately. (default: -1)</p></li>
<li><p>They have a <code class="docutils literal notranslate"><span class="pre">tickrate</span></code> (float), and automatically tick if it is greater than 1 (default: 0)</p></li>
<li><p>They can stack, if <code class="docutils literal notranslate"><span class="pre">maxstacks</span></code> (int) is not equal to 1. If its 0, the buff stacks forever. (default: 1)</p></li>
<li><p>They can be <code class="docutils literal notranslate"><span class="pre">unique</span></code> (bool), which determines if they have a unique namespace or not. (default: True)</p></li>
<li><p>They can <code class="docutils literal notranslate"><span class="pre">refresh</span></code> (bool), which resets the duration when stacked or reapplied. (default: True)</p></li>
<li><p>They can be <code class="docutils literal notranslate"><span class="pre">playtime</span></code> (bool) buffs, where duration only counts down during active play. (default: False)</p></li>
</ul>
<p>Buffs also have a few useful properties:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">owner</span></code>: The object this buff is attached to</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ticknum</span></code>: How many ticks the buff has gone through</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">timeleft</span></code>: How much time is remaining on the buff</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ticking</span></code>/<code class="docutils literal notranslate"><span class="pre">stacking</span></code>: If this buff ticks/stacks (checks <code class="docutils literal notranslate"><span class="pre">tickrate</span></code> and <code class="docutils literal notranslate"><span class="pre">maxstacks</span></code>)</p></li>
</ul>
<section id="buff-cache-advanced">
<h4>Buff Cache (Advanced)<a class="headerlink" href="#buff-cache-advanced" title="Permalink to this headline"></a></h4>
<p>Buffs always store some useful mutable information about themselves in the cache (what is stored on the owning objects database attribute). A buffs cache corresponds to <code class="docutils literal notranslate"><span class="pre">{buffkey:</span> <span class="pre">buffcache}</span></code>, where <code class="docutils literal notranslate"><span class="pre">buffcache</span></code> is a dictionary containing <strong>at least</strong> the information below:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">ref</span></code> (class): The buff class path we use to construct the buff.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">start</span></code> (float): The timestamp of when the buff was applied.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">source</span></code> (Object): If specified; this allows you to track who or what applied the buff.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">prevtick</span></code> (float): The timestamp of the previous tick.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">duration</span></code> (float): The cached duration. This can vary from the class duration, depending on if the duration has been modified (paused, extended, shortened, etc).</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">tickrate</span></code> (float): The buffs tick rate. Cannot go below 0. Altering the tickrate on an applied buff will not cause it to start ticking if it wasnt ticking before. (<code class="docutils literal notranslate"><span class="pre">pause</span></code> and <code class="docutils literal notranslate"><span class="pre">unpause</span></code> to start/stop ticking on existing buffs)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">stacks</span></code> (int): How many stacks they have.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">paused</span></code> (bool): Paused buffs do not clean up, modify values, tick, or fire any hook methods.</p></li>
</ul>
<p>Sometimes you will want to dynamically update a buffs cache at runtime, such as changing a tickrate in a hook method, or altering a buffs duration.
You can do so by using the interface <code class="docutils literal notranslate"><span class="pre">buff.cachekey</span></code>. As long as the attribute name matches a key in the cache dictionary, it will update the stored
cache with the new value.</p>
<p>If there is no matching key, it will do nothing. If you wish to add a new key to the cache, you must use the <code class="docutils literal notranslate"><span class="pre">buff.update_cache(dict)</span></code> method,
which will properly update the cache (including adding new keys) using the dictionary provided.</p>
<blockquote>
<div><p><strong>Example</strong>: You want to increase a buffs duration by 30 seconds. You use <code class="docutils literal notranslate"><span class="pre">buff.duration</span> <span class="pre">+=</span> <span class="pre">30</span></code>. This new duration is now reflected on both the instance and the cache.</p>
</div></blockquote>
<p>The buff cache can also store arbitrary information. To do so, pass a dictionary through the handler <code class="docutils literal notranslate"><span class="pre">add</span></code> method (<code class="docutils literal notranslate"><span class="pre">handler.add(BuffClass,</span> <span class="pre">to_cache=dict)</span></code>),
set the <code class="docutils literal notranslate"><span class="pre">cache</span></code> dictionary attribute on your buff class, or use the aforementioned <code class="docutils literal notranslate"><span class="pre">buff.update_cache(dict)</span></code> method.</p>
<blockquote>
<div><p><strong>Example</strong>: You store <code class="docutils literal notranslate"><span class="pre">damage</span></code> as a value in the buff cache and use it for your poison buff. You want to increase it over time, so you use <code class="docutils literal notranslate"><span class="pre">buff.damage</span> <span class="pre">+=</span> <span class="pre">1</span></code> in the tick method.</p>
</div></blockquote>
</section>
</section>
<section id="modifiers">
<h3>Modifiers<a class="headerlink" href="#modifiers" title="Permalink to this headline"></a></h3>
<p>Mods are stored in the <code class="docutils literal notranslate"><span class="pre">mods</span></code> list attribute. Buffs which have one or more Mod objects in them can modify stats. You can use the handler method to check all
mods of a specific stat string and apply their modifications to the value; however, you are encouraged to use <code class="docutils literal notranslate"><span class="pre">check</span></code> in a getter/setter, for easy access.</p>
<p>Mod objects consist of only four values, assigned by the constructor in this order:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">stat</span></code>: The stat you want to modify. When <code class="docutils literal notranslate"><span class="pre">check</span></code> is called, this string is used to find all the mods that are to be collected.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mod</span></code>: The modifier. Defaults are <code class="docutils literal notranslate"><span class="pre">add</span></code> (addition/subtraction), <code class="docutils literal notranslate"><span class="pre">mult</span></code> (multiply), and <code class="docutils literal notranslate"><span class="pre">div</span></code> (divide). Modifiers are calculated additively (see <code class="docutils literal notranslate"><span class="pre">_calculate_mods</span></code> for more)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">value</span></code>: How much value the modifier gives regardless of stacks</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">perstack</span></code>: How much value the modifier grants per stack, <strong>INCLUDING</strong> the first. (default: 0)</p></li>
</ul>
<p>The most basic way to add a Mod to a buff is to do so in the buff class definition, like this:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">DamageBuff</span><span class="p">(</span><span class="n">BaseBuff</span><span class="p">):</span>
<span class="n">mods</span> <span class="o">=</span> <span class="p">[</span><span class="n">Mod</span><span class="p">(</span><span class="s1">&#39;damage&#39;</span><span class="p">,</span> <span class="s1">&#39;add&#39;</span><span class="p">,</span> <span class="mi">10</span><span class="p">)]</span>
</pre></div>
</div>
<p>No mods applied to the value are permanent in any way. All calculations are done at runtime, and the mod values are never stored
anywhere except on the buff in question. In other words: you dont need to track the origin of particular stat mods, and you will
never permanently change a stat modified by a buff. To remove the modification, simply remove the buff from the object.</p>
<blockquote>
<div><p><strong>Note</strong>: You can add your own modifier types by overloading the <code class="docutils literal notranslate"><span class="pre">_calculate_mods</span></code> method, which contains the basic modifier application logic.</p>
</div></blockquote>
<section id="generating-mods-advanced">
<h4>Generating Mods (Advanced)<a class="headerlink" href="#generating-mods-advanced" title="Permalink to this headline"></a></h4>
<p>An advanced way to do mods is to generate them when the buff is initialized. This lets you create mods on the fly that are reactive to the game state.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">GeneratedStatBuff</span><span class="p">(</span><span class="n">BaseBuff</span><span class="p">):</span>
<span class="o">...</span>
<span class="k">def</span> <span class="nf">at_init</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="c1"># Finds our &quot;modgen&quot; cache value, and generates a mod from it</span>
<span class="n">modgen</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cache</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;modgen&quot;</span><span class="p">))</span>
<span class="k">if</span> <span class="n">modgen</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">mods</span> <span class="o">=</span> <span class="p">[</span><span class="n">Mod</span><span class="p">(</span><span class="o">*</span><span class="n">modgen</span><span class="p">)]</span>
</pre></div>
</div>
</section>
</section>
<section id="triggers">
<h3>Triggers<a class="headerlink" href="#triggers" title="Permalink to this headline"></a></h3>
<p>Buffs which have one or more strings in the <code class="docutils literal notranslate"><span class="pre">triggers</span></code> attribute can be triggered by events.</p>
<p>When the handlers <code class="docutils literal notranslate"><span class="pre">trigger</span></code> method is called, it searches all buffs on the handler for any with a matchingtrigger,
then calls their <code class="docutils literal notranslate"><span class="pre">at_trigger</span></code> hooks. Buffs can have multiple triggers, and you can tell which trigger was used by
the <code class="docutils literal notranslate"><span class="pre">trigger</span></code> argument in the hook.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">AmplifyBuff</span><span class="p">(</span><span class="n">BaseBuff</span><span class="p">):</span>
<span class="n">triggers</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;damage&#39;</span><span class="p">,</span> <span class="s1">&#39;heal&#39;</span><span class="p">]</span>
<span class="k">def</span> <span class="nf">at_trigger</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">trigger</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="k">if</span> <span class="n">trigger</span> <span class="o">==</span> <span class="s1">&#39;damage&#39;</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Damage trigger called!&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">trigger</span> <span class="o">==</span> <span class="s1">&#39;heal&#39;</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Heal trigger called!&#39;</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="id1">
<h3>Ticking<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h3>
<p>A buff which ticks isnt much different than one which triggers. Youre still executing arbitrary hooks on
the buff class. To tick, the buff must have a <code class="docutils literal notranslate"><span class="pre">tickrate</span></code> of 1 or higher.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Poison</span><span class="p">(</span><span class="n">BaseBuff</span><span class="p">):</span>
<span class="o">...</span>
<span class="c1"># this buff will tick 6 times between application and cleanup.</span>
<span class="n">duration</span> <span class="o">=</span> <span class="mi">30</span>
<span class="n">tickrate</span> <span class="o">=</span> <span class="mi">5</span>
<span class="k">def</span> <span class="nf">at_tick</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">initial</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">owner</span><span class="o">.</span><span class="n">take_damage</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
</pre></div>
</div>
<blockquote>
<div><p><strong>Note</strong>: The buff always ticks once when applied. For this <strong>first tick only</strong>, <code class="docutils literal notranslate"><span class="pre">initial</span></code> will be True in the <code class="docutils literal notranslate"><span class="pre">at_tick</span></code> hook method. <code class="docutils literal notranslate"><span class="pre">initial</span></code> will be False on subsequent ticks.</p>
</div></blockquote>
<p>Ticks utilize a persistent delay, so they should be pickleable. As long as you are not adding new properties to your buff class, this shouldnt be a concern.
If you <strong>are</strong> adding new properties, try to ensure they do not end up with a circular code path to their object or handler, as this will cause pickling errors.</p>
</section>
<section id="extras">
<h3>Extras<a class="headerlink" href="#extras" title="Permalink to this headline"></a></h3>
<p>Buffs have a grab-bag of extra functionality to let you add complexity to your designs.</p>
<section id="conditionals">
<h4>Conditionals<a class="headerlink" href="#conditionals" title="Permalink to this headline"></a></h4>
<p>You can restrict whether or not the buff will <code class="docutils literal notranslate"><span class="pre">check</span></code>, <code class="docutils literal notranslate"><span class="pre">trigger</span></code>, or <code class="docutils literal notranslate"><span class="pre">tick</span></code> through defining the <code class="docutils literal notranslate"><span class="pre">conditional</span></code> hook. As long
as it returns a “truthy” value, the buff will apply itself. This is useful for making buffs dependent on game state - for
example, if you want a buff that makes the player take more damage when they are on fire:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">FireSick</span><span class="p">(</span><span class="n">BaseBuff</span><span class="p">):</span>
<span class="o">...</span>
<span class="k">def</span> <span class="nf">conditional</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">owner</span><span class="o">.</span><span class="n">buffs</span><span class="o">.</span><span class="n">has</span><span class="p">(</span><span class="n">FireBuff</span><span class="p">):</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="k">return</span> <span class="kc">False</span>
</pre></div>
</div>
<p>Conditionals for <code class="docutils literal notranslate"><span class="pre">check</span></code>/<code class="docutils literal notranslate"><span class="pre">trigger</span></code> are checked when the buffs are gathered by the handler methods for the respective operations. <code class="docutils literal notranslate"><span class="pre">Tick</span></code>
conditionals are checked each tick.</p>
</section>
<section id="helper-methods">
<h4>Helper Methods<a class="headerlink" href="#helper-methods" title="Permalink to this headline"></a></h4>
<p>Buff instances have a number of helper methods.</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">remove</span></code>/<code class="docutils literal notranslate"><span class="pre">dispel</span></code>: Allows you to remove or dispel the buff. Calls <code class="docutils literal notranslate"><span class="pre">at_remove</span></code>/<code class="docutils literal notranslate"><span class="pre">at_dispel</span></code>, depending on optional arguments.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pause</span></code>/<code class="docutils literal notranslate"><span class="pre">unpause</span></code>: Pauses and unpauses the buff. Calls <code class="docutils literal notranslate"><span class="pre">at_pause</span></code>/<code class="docutils literal notranslate"><span class="pre">at_unpause</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">reset</span></code>: Resets the buffs start to the current time; same as “refreshing” it.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">alter_cache</span></code>: Updates the buffs cache with the <code class="docutils literal notranslate"><span class="pre">{key:value}</span></code> pairs in the provided dictionary. Can overwrite default values, so be careful!</p></li>
</ul>
</section>
<section id="playtime-duration">
<h4>Playtime Duration<a class="headerlink" href="#playtime-duration" title="Permalink to this headline"></a></h4>
<p>If your handler has <code class="docutils literal notranslate"><span class="pre">autopause</span></code> enabled, any buffs with truthy <code class="docutils literal notranslate"><span class="pre">playtime</span></code> value will automatically pause
and unpause when the object the handler is attached to is puppetted or unpuppetted. This even works with ticking buffs,
although if you have less than 1 second of tick duration remaining, it will round up to 1s.</p>
<blockquote>
<div><p><strong>Note</strong>: If you want more control over this process, you can comment out the signal subscriptions on the handler and move the autopause logic
to your objects <code class="docutils literal notranslate"><span class="pre">at_pre/post_puppet/unpuppet</span></code> hooks.</p>
</div></blockquote>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/rpg/buffs/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</section>
</section>
</section>
</section>
</div>
</div>
</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="Contrib-Character-Creator.html" title="Character Creator contrib"
>next</a> |</li>
<li class="right" >
<a href="Contrib-XYZGrid.html" title="XYZgrid"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Buffs</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>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,263 @@
<!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>Character Creator contrib &#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>
<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="Dice roller" href="Contrib-Dice.html" />
<link rel="prev" title="Buffs" href="Contrib-Buffs.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="Contrib-Dice.html" title="Dice roller"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Buffs.html" title="Buffs"
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="Contribs-Overview.html" accesskey="U">Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Character Creator contrib</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Character Creator contrib</a><ul>
<li><a class="reference internal" href="#installation">Installation</a><ul>
<li><a class="reference internal" href="#example">Example:</a></li>
</ul>
</li>
<li><a class="reference internal" href="#usage">Usage</a><ul>
<li><a class="reference internal" href="#the-evmenu">The EvMenu</a><ul>
<li><a class="reference internal" href="#informational-pages">Informational Pages</a></li>
<li><a class="reference internal" href="#option-categories">Option Categories</a></li>
<li><a class="reference internal" href="#multiple-choice">Multiple Choice</a></li>
<li><a class="reference internal" href="#starting-objects">Starting Objects</a></li>
<li><a class="reference internal" href="#choosing-a-name">Choosing a Name</a></li>
</ul>
</li>
<li><a class="reference internal" href="#charcreate-command"><code class="docutils literal notranslate"><span class="pre">charcreate</span></code> command</a></li>
<li><a class="reference internal" href="#changes-to-account-at-look">Changes to <code class="docutils literal notranslate"><span class="pre">Account.at_look</span></code></a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Buffs.html"
title="previous chapter">Buffs</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Dice.html"
title="next chapter">Dice roller</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Character-Creator.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-Character-Creator.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="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="character-creator-contrib">
<h1>Character Creator contrib<a class="headerlink" href="#character-creator-contrib" title="Permalink to this headline"></a></h1>
<p>Commands for managing and initiating an in-game character-creation menu.</p>
<p>Contribution by InspectorCaracal, 2022</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>In your game folder <code class="docutils literal notranslate"><span class="pre">commands/default_cmdsets.py</span></code>, import and add
<code class="docutils literal notranslate"><span class="pre">ContribCmdCharCreate</span></code> to your <code class="docutils literal notranslate"><span class="pre">AccountCmdSet</span></code>.</p>
<p>Example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.rpg.character_creator.character_creator</span> <span class="kn">import</span> <span class="n">ContribCmdCharCreate</span>
<span class="k">class</span> <span class="nc">AccountCmdSet</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">AccountCmdSet</span><span class="p">):</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="o">.</span><span class="n">at_cmdset_creation</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">ContribCmdCharCreate</span><span class="p">)</span>
</pre></div>
</div>
<p>In your game folder <code class="docutils literal notranslate"><span class="pre">typeclasses/accounts.py</span></code>, import and inherit from <code class="docutils literal notranslate"><span class="pre">ContribChargenAccount</span></code>
on your Account class.</p>
<p>(Alternatively, you can copy the <code class="docutils literal notranslate"><span class="pre">at_look</span></code> method directly into your own class.)</p>
<section id="example">
<h3>Example:<a class="headerlink" href="#example" 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.rpg.character_creator.character_creator</span> <span class="kn">import</span> <span class="n">ContribChargenAccount</span>
<span class="k">class</span> <span class="nc">Account</span><span class="p">(</span><span class="n">ContribChargenAccount</span><span class="p">):</span>
<span class="c1"># your Account class code</span>
</pre></div>
</div>
<p>In your settings file <code class="docutils literal notranslate"><span class="pre">server/conf/settings.py</span></code>, add the following settings:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">AUTO_CREATE_CHARACTER_WITH_ACCOUNT</span> <span class="o">=</span> <span class="kc">False</span>
<span class="n">AUTO_PUPPET_ON_LOGIN</span> <span class="o">=</span> <span class="kc">False</span>
</pre></div>
</div>
<p>(If you want to allow players to create more than one character, you can
customize that with the setting <code class="docutils literal notranslate"><span class="pre">MAX_NR_CHARACTERS</span></code>.)</p>
<p>By default, the new <code class="docutils literal notranslate"><span class="pre">charcreate</span></code> command will reference the example menu
provided by the contrib, so you can test it out before building your own menu.
You can reference
<a class="reference external" href="https://github.com/evennia/evennia/blob/develop/evennia/contrib/rpg/character_creator/example_menu.py">the example menu here</a> for
ideas on how to build your own.</p>
<p>Once you have your own menu, just add it to your settings to use it. e.g. if your menu is in
<code class="docutils literal notranslate"><span class="pre">mygame/word/chargen_menu.py</span></code>, youd add the following to your settings file:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">CHARGEN_MENU</span> <span class="o">=</span> <span class="s2">&quot;world.chargen_menu&quot;</span>
</pre></div>
</div>
</section>
</section>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<section id="the-evmenu">
<h3>The EvMenu<a class="headerlink" href="#the-evmenu" title="Permalink to this headline"></a></h3>
<p>In order to use the contrib, you will need to create your own chargen EvMenu.
The included <code class="docutils literal notranslate"><span class="pre">example_menu.py</span></code> gives a number of useful menu node techniques
with basic attribute examples for you to reference. It can be run as-is as a
tutorial for yourself/your devs, or used as base for your own menu.</p>
<p>The example menu includes code, tips, and instructions for the following types
of decision nodes:</p>
<section id="informational-pages">
<h4>Informational Pages<a class="headerlink" href="#informational-pages" title="Permalink to this headline"></a></h4>
<p>A small set of nodes that let you page through information on different choices before committing to one.</p>
</section>
<section id="option-categories">
<h4>Option Categories<a class="headerlink" href="#option-categories" title="Permalink to this headline"></a></h4>
<p>A pair of nodes which let you divide an arbitrary number of options into separate categories.</p>
<p>The base node has a list of categories as the options, and the child node displays the actual character choices.</p>
</section>
<section id="multiple-choice">
<h4>Multiple Choice<a class="headerlink" href="#multiple-choice" title="Permalink to this headline"></a></h4>
<p>Allows players to select and deselect options from the list in order to choose more than one.</p>
</section>
<section id="starting-objects">
<h4>Starting Objects<a class="headerlink" href="#starting-objects" title="Permalink to this headline"></a></h4>
<p>Allows players to choose from a selection of starting objects, which are then created on chargen completion.</p>
</section>
<section id="choosing-a-name">
<h4>Choosing a Name<a class="headerlink" href="#choosing-a-name" title="Permalink to this headline"></a></h4>
<p>The contrib assumes the player will choose their name during character creation,
so the necessary code for doing so is of course included!</p>
</section>
</section>
<section id="charcreate-command">
<h3><code class="docutils literal notranslate"><span class="pre">charcreate</span></code> command<a class="headerlink" href="#charcreate-command" title="Permalink to this headline"></a></h3>
<p>The contrib overrides the character creation command - <code class="docutils literal notranslate"><span class="pre">charcreate</span></code> - to use a
character creator menu, as well as supporting exiting/resuming the process. In
addition, unlike the core command, its designed for the character name to be
chosen later on via the menu, so it wont parse any arguments passed to it.</p>
</section>
<section id="changes-to-account-at-look">
<h3>Changes to <code class="docutils literal notranslate"><span class="pre">Account.at_look</span></code><a class="headerlink" href="#changes-to-account-at-look" title="Permalink to this headline"></a></h3>
<p>The contrib version works mostly the same as core evennia, but adds an
additional check to recognize an in-progress character. If youve modified your
own <code class="docutils literal notranslate"><span class="pre">at_look</span></code> hook, its an easy addition to make: just add this section to the
playable character list loop.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="k">for</span> <span class="n">char</span> <span class="ow">in</span> <span class="n">characters</span><span class="p">:</span>
<span class="c1"># contrib code starts here</span>
<span class="k">if</span> <span class="n">char</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">chargen_step</span><span class="p">:</span>
<span class="c1"># currently in-progress character; don&#39;t display placeholder names</span>
<span class="n">result</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2"> - |Yin progress|n (|wcharcreate|n to continue)&quot;</span><span class="p">)</span>
<span class="k">continue</span>
<span class="c1"># the rest of your code continues here</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/character_creator/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>
</div>
</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="Contrib-Dice.html" title="Dice roller"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Buffs.html" title="Buffs"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Character Creator contrib</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,225 @@
<!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>
<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="Cooldowns" href="Contrib-Cooldowns.html" />
<link rel="prev" title="Barter system" href="Contrib-Barter.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="Contrib-Cooldowns.html" title="Cooldowns"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Barter.html" title="Barter system"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Barter.html"
title="previous chapter">Barter system</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Cooldowns.html"
title="next chapter">Cooldowns</a></p>
<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="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>
</div>
</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="Contrib-Cooldowns.html" title="Cooldowns"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Barter.html" title="Barter system"
>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="Contribs-Overview.html" >Contribs</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,196 @@
<!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>Additional 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>
<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="Components" href="Contrib-Components.html" />
<link rel="prev" title="Building menu" href="Contrib-Building-Menu.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="Contrib-Components.html" title="Components"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Building-Menu.html" title="Building menu"
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="Contribs-Overview.html" accesskey="U">Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Additional Color markups</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Additional 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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Building-Menu.html"
title="previous chapter">Building menu</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Components.html"
title="next chapter">Components</a></p>
<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="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="additional-color-markups">
<h1>Additional Color markups<a class="headerlink" href="#additional-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_XTERM256_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_XTERM256_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_XTERM256_BRIGHT_BG_EXTRA_MAP</span> <span class="o">=</span> <span class="n">color_markups</span><span class="o">.</span><span class="n">MUX_COLOR_ANSI_XTERM256_BRIGHT_BG_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>
</div>
</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="Contrib-Components.html" title="Components"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Building-Menu.html" title="Building menu"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Additional 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,328 @@
<!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>Components &#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>
<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="Custom gameime" href="Contrib-Custom-Gametime.html" />
<link rel="prev" title="Additional Color markups" href="Contrib-Color-Markups.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="Contrib-Custom-Gametime.html" title="Custom gameime"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Color-Markups.html" title="Additional Color markups"
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="Contribs-Overview.html" accesskey="U">Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Components</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Components</a></li>
<li><a class="reference internal" href="#the-components-contrib">The Components Contrib</a></li>
<li><a class="reference internal" href="#pros">Pros</a></li>
<li><a class="reference internal" href="#cons">Cons</a></li>
<li><a class="reference internal" href="#how-to-install">How to install</a></li>
<li><a class="reference internal" href="#full-example">Full Example</a></li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Color-Markups.html"
title="previous chapter">Additional Color markups</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Custom-Gametime.html"
title="next chapter">Custom gameime</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Components.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-Components.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="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="components">
<h1>Components<a class="headerlink" href="#components" title="Permalink to this headline"></a></h1>
<p><em>Contrib by ChrisLR 2021</em></p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="the-components-contrib">
<h1>The Components Contrib<a class="headerlink" href="#the-components-contrib" title="Permalink to this headline"></a></h1>
<p>This contrib introduces Components and Composition to Evennia.
Each Component class represents a feature that will be enabled on a typeclass instance.
You can register these components on an entire typeclass or a single object at runtime.
It supports both persisted attributes and in-memory attributes by using Evennias AttributeHandler.</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="pros">
<h1>Pros<a class="headerlink" href="#pros" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p>You can reuse a feature across multiple typeclasses without inheritance</p></li>
<li><p>You can cleanly organize each feature into a self-contained class.</p></li>
<li><p>You can check if your object supports a feature without checking its instance.</p></li>
</ul>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="cons">
<h1>Cons<a class="headerlink" href="#cons" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p>It introduces additional complexity.</p></li>
<li><p>A host typeclass instance is required.</p></li>
</ul>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="how-to-install">
<h1>How to install<a class="headerlink" href="#how-to-install" title="Permalink to this headline"></a></h1>
<p>To enable component support for a typeclass,
import and inherit the ComponentHolderMixin, similar to this</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.base_systems.components</span> <span class="kn">import</span> <span class="n">ComponentHolderMixin</span>
<span class="k">class</span> <span class="nc">Character</span><span class="p">(</span><span class="n">ComponentHolderMixin</span><span class="p">,</span> <span class="n">DefaultCharacter</span><span class="p">):</span>
<span class="c1"># ...</span>
</pre></div>
</div>
<p>Components need to inherit the Component class directly and require a name.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.components</span> <span class="kn">import</span> <span class="n">Component</span>
<span class="k">class</span> <span class="nc">Health</span><span class="p">(</span><span class="n">Component</span><span class="p">):</span>
<span class="n">name</span> <span class="o">=</span> <span class="s2">&quot;health&quot;</span>
</pre></div>
</div>
<p>Components may define DBFields or NDBFields at the class level.
DBField will store its values in the hosts DB with a prefixed key.
NDBField will store its values in the hosts NDB and will not persist.
The key used will be component_name::field_name.
They use AttributeProperty under the hood.</p>
<p>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.components</span> <span class="kn">import</span> <span class="n">Component</span><span class="p">,</span> <span class="n">DBField</span>
<span class="k">class</span> <span class="nc">Health</span><span class="p">(</span><span class="n">Component</span><span class="p">):</span>
<span class="n">health</span> <span class="o">=</span> <span class="n">DBField</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>Note that default is optional and will default to None.</p>
<p>Adding a component to a host will also a similarly named tag with components as category.
A Component named health will appear as key=”health, category=“components”.
This allows you to retrieve objects with specific components by searching with the tag.</p>
<p>It is also possible to add Component Tags the same way, using TagField.
TagField accepts a default value and can be used to store a single or multiple tags.
Default values are automatically added when the component is added.
Component Tags are cleared from the host if the component is removed.</p>
<p>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.components</span> <span class="kn">import</span> <span class="n">Component</span><span class="p">,</span> <span class="n">TagField</span>
<span class="k">class</span> <span class="nc">Health</span><span class="p">(</span><span class="n">Component</span><span class="p">):</span>
<span class="n">resistances</span> <span class="o">=</span> <span class="n">TagField</span><span class="p">()</span>
<span class="n">vulnerability</span> <span class="o">=</span> <span class="n">TagField</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="s2">&quot;fire&quot;</span><span class="p">,</span> <span class="n">enforce_single</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
<p>The resistances field in this example can be set to multiple times and it will keep the added tags.
The vulnerability field in this example will override the previous tag with the new one.</p>
<p>Each typeclass using the ComponentHolderMixin can declare its components
in the class via the ComponentProperty.
These are components that will always be present in a typeclass.
You can also pass kwargs to override the default values
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.components</span> <span class="kn">import</span> <span class="n">ComponentHolderMixin</span>
<span class="k">class</span> <span class="nc">Character</span><span class="p">(</span><span class="n">ComponentHolderMixin</span><span class="p">,</span> <span class="n">DefaultCharacter</span><span class="p">):</span>
<span class="n">health</span> <span class="o">=</span> <span class="n">ComponentProperty</span><span class="p">(</span><span class="s2">&quot;health&quot;</span><span class="p">,</span> <span class="n">hp</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">max_hp</span><span class="o">=</span><span class="mi">50</span><span class="p">)</span>
</pre></div>
</div>
<p>You can then use character.components.health to access it.
The shorter form character.cmp.health also exists.
character.health would also be accessible but only for typeclasses that have
this component defined on the class.</p>
<p>Alternatively you can add those components at runtime.
You will have to access those via the component handler.
Example</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">character</span> <span class="o">=</span> <span class="bp">self</span>
<span class="n">vampirism</span> <span class="o">=</span> <span class="n">components</span><span class="o">.</span><span class="n">Vampirism</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">character</span><span class="p">)</span>
<span class="n">character</span><span class="o">.</span><span class="n">components</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">vampirism</span><span class="p">)</span>
<span class="o">...</span>
<span class="n">vampirism_from_elsewhere</span> <span class="o">=</span> <span class="n">character</span><span class="o">.</span><span class="n">components</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;vampirism&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>Keep in mind that all components must be imported to be visible in the listing.
As such, I recommend regrouping them in a package.
You can then import all your components in that packages <strong>init</strong></p>
<p>Because of how Evennia import typeclasses and the behavior of python imports
I recommend placing the components package inside the typeclass package.
In other words, create a folder named components inside your typeclass folder.
Then, inside the typeclasses/<strong>init</strong>.py file add the import to the folder, like</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">typeclasses</span> <span class="kn">import</span> <span class="n">components</span>
</pre></div>
</div>
<p>This ensures that the components package will be imported when the typeclasses are imported.
You will also need to import each components inside the packages own typeclasses/components/<strong>init</strong>.py file.
You only need to import each module/file from there but importing the right class is a good practice.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">typeclasses.components.health</span> <span class="kn">import</span> <span class="n">Health</span>
</pre></div>
</div>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">typeclasses.components</span> <span class="kn">import</span> <span class="n">health</span>
</pre></div>
</div>
<p>Both of the above examples will work.</p>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="full-example">
<h1>Full Example<a class="headerlink" href="#full-example" title="Permalink to this headline"></a></h1>
<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">components</span>
<span class="c1"># This is the Component class</span>
<span class="k">class</span> <span class="nc">Health</span><span class="p">(</span><span class="n">components</span><span class="o">.</span><span class="n">Component</span><span class="p">):</span>
<span class="n">name</span> <span class="o">=</span> <span class="s2">&quot;health&quot;</span>
<span class="c1"># Stores the current and max values as Attributes on the host, defaulting to 100</span>
<span class="n">current</span> <span class="o">=</span> <span class="n">components</span><span class="o">.</span><span class="n">DBField</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
<span class="nb">max</span> <span class="o">=</span> <span class="n">components</span><span class="o">.</span><span class="n">DBField</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">damage</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">current</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">return</span>
<span class="bp">self</span><span class="o">.</span><span class="n">current</span> <span class="o">-=</span> <span class="n">value</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">current</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">return</span>
<span class="bp">self</span><span class="o">.</span><span class="n">current</span> <span class="o">=</span> <span class="mi">0</span>
<span class="bp">self</span><span class="o">.</span><span class="n">on_death</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">heal</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="n">hp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">current</span>
<span class="n">hp</span> <span class="o">+=</span> <span class="n">value</span>
<span class="k">if</span> <span class="n">hp</span> <span class="o">&gt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_hp</span><span class="p">:</span>
<span class="n">hp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_hp</span>
<span class="bp">self</span><span class="o">.</span><span class="n">current</span> <span class="o">=</span> <span class="n">hp</span>
<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">is_dead</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">current</span> <span class="o">&lt;=</span> <span class="mi">0</span>
<span class="k">def</span> <span class="nf">on_death</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># Behavior is defined on the typeclass</span>
<span class="bp">self</span><span class="o">.</span><span class="n">host</span><span class="o">.</span><span class="n">on_death</span><span class="p">()</span>
<span class="c1"># This is how the Character inherits the mixin and registers the component &#39;health&#39;</span>
<span class="k">class</span> <span class="nc">Character</span><span class="p">(</span><span class="n">ComponentHolderMixin</span><span class="p">,</span> <span class="n">DefaultCharacter</span><span class="p">):</span>
<span class="n">health</span> <span class="o">=</span> <span class="n">ComponentProperty</span><span class="p">(</span><span class="s2">&quot;health&quot;</span><span class="p">)</span>
<span class="c1"># This is an example of a command that checks for the component</span>
<span class="k">class</span> <span class="nc">Attack</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;attack&quot;</span>
<span class="n">aliases</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;melee&#39;</span><span class="p">,</span> <span class="s1">&#39;hit&#39;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">at_pre_cmd</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">caller</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">caller</span>
<span class="n">targets</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">search</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">quiet</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">valid_target</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">for</span> <span class="n">target</span> <span class="ow">in</span> <span class="n">targets</span><span class="p">:</span>
<span class="c1"># Attempt to retrieve the component, None is obtained if it does not exist.</span>
<span class="k">if</span> <span class="n">target</span><span class="o">.</span><span class="n">components</span><span class="o">.</span><span class="n">health</span><span class="p">:</span>
<span class="n">valid_target</span> <span class="o">=</span> <span class="n">target</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">valid_target</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;You can&#39;t attack that!&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="kc">True</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/components/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</section>
</div>
</div>
</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="Contrib-Custom-Gametime.html" title="Custom gameime"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Color-Markups.html" title="Additional Color markups"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Components</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,194 @@
<!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>
<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" href="Contrib-Crafting.html" />
<link rel="prev" title="Clothing" href="Contrib-Clothing.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="Contrib-Crafting.html" title="Crafting system"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Clothing.html" title="Clothing"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<li><a class="reference internal" href="#example">Example</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Clothing.html"
title="previous chapter">Clothing</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Crafting.html"
title="next chapter">Crafting system</a></p>
<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="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 to model 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.contrib.game_systems.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 id="example">
<h2>Example<a class="headerlink" href="#example" title="Permalink to this headline"></a></h2>
<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>
</section>
</div>
</div>
</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="Contrib-Crafting.html" title="Crafting system"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Clothing.html" title="Clothing"
>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="Contribs-Overview.html" >Contribs</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

@ -0,0 +1,419 @@
<!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>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>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Gendersub" href="Contrib-Gendersub.html" />
<link rel="prev" title="Cooldowns" href="Contrib-Cooldowns.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="Contrib-Gendersub.html" title="Gendersub"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Cooldowns.html" title="Cooldowns"
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="Contribs-Overview.html" accesskey="U">Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Crafting system</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<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>
</ul>
</li>
<li><a class="reference internal" href="#even-more-customization">Even more customization</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Cooldowns.html"
title="previous chapter">Cooldowns</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Gendersub.html"
title="next chapter">Gendersub</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Crafting.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-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>
</div>
</div>
<div class="bodywrapper">
<div class="body" role="main">
<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>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>
<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>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>
<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>
<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>
<span class="k">class</span> <span class="nc">WoodenPuppetRecipe</span><span class="p">(</span><span class="n">CraftingRecipe</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;A puppet&quot;&quot;&quot;</span><span class="s2">&quot;</span>
<span class="n">name</span> <span class="o">=</span> <span class="s2">&quot;wooden puppet&quot;</span> <span class="c1"># name to refer to this recipe as</span>
<span class="n">tool_tags</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;knife&quot;</span><span class="p">]</span>
<span class="n">consumable_tags</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;wood&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;A carved wooden doll&quot;</span><span class="p">,</span>
<span class="s2">&quot;typeclass&quot;</span><span class="p">:</span> <span class="s2">&quot;typeclasses.objects.decorations.Toys&quot;</span><span class="p">,</span>
<span class="s2">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;A small carved doll&quot;</span><span class="p">}</span>
<span class="p">]</span>
</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>
<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
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>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>&gt; craft wooden puppet from wood using hobby knife
</pre></div>
</div>
<p>In code we would do</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>
<span class="n">puppet</span> <span class="o">=</span> <span class="n">craft</span><span class="p">(</span><span class="n">crafter</span><span class="p">,</span> <span class="s2">&quot;wooden puppet&quot;</span><span class="p">,</span> <span class="n">knife</span><span class="p">,</span> <span class="n">wood</span><span class="p">)</span>
</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>
</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>
<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>
<span class="n">tools</span><span class="p">,</span> <span class="n">consumables</span> <span class="o">=</span> <span class="n">MyRecipe</span><span class="o">.</span><span class="n">seed</span><span class="p">()</span>
<span class="n">recipe</span> <span class="o">=</span> <span class="n">MyRecipe</span><span class="p">(</span><span class="n">crafter</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">tools</span> <span class="o">+</span> <span class="n">consumables</span><span class="p">))</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">recipe</span><span class="o">.</span><span class="n">craft</span><span class="p">()</span>
</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.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
<code class="docutils literal notranslate"><span class="pre">validated_tools</span></code> respectively. On error, this reports the error to the crafter and raises the
<code class="docutils literal notranslate"><span class="pre">CraftingValidationError</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">craft</span></code> - this will only be called if <code class="docutils literal notranslate"><span class="pre">pre_craft</span></code> finished without an exception. This should
return the result of the crafting, by spawnging the prototypes. Or the empty list if crafting
fails for some reason. This is the place to add skill-checks or random chance if you need it
for your game.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">post_craft</span></code> - this receives the result from <code class="docutils literal notranslate"><span class="pre">craft</span></code> and handles error messages and also deletes
any consumables as needed. It may also modify the result before returning it.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">msg</span></code> - this is a wrapper for <code class="docutils literal notranslate"><span class="pre">self.crafter.msg</span></code> and should be used to send messages to the
crafter. Centralizing this means you can also easily modify the sending style in one place later.</p></li>
</ul>
<p>The class constructor (and the <code class="docutils literal notranslate"><span class="pre">craft</span></code> access function) takes optional <code class="docutils literal notranslate"><span class="pre">**kwargs</span></code>. These are passed
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>
<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>
<span class="k">class</span> <span class="nc">SkillRecipe</span><span class="p">(</span><span class="n">CraftingRecipe</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;A recipe that considers skill&quot;&quot;&quot;</span>
<span class="n">difficulty</span> <span class="o">=</span> <span class="mi">20</span>
<span class="k">def</span> <span class="nf">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="sd">&quot;&quot;&quot;The input is ok. Determine if crafting succeeds&quot;&quot;&quot;</span>
<span class="c1"># this is set at initialization</span>
<span class="n">crafter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">crafte</span>
<span class="c1"># let&#39;s assume the skill is stored directly on the crafter</span>
<span class="c1"># - the skill is 0..100.</span>
<span class="n">crafting_skill</span> <span class="o">=</span> <span class="n">crafter</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">skill_crafting</span>
<span class="c1"># roll for success:</span>
<span class="k">if</span> <span class="n">randint</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="p">(</span><span class="n">crafting_skill</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">difficulty</span><span class="p">):</span>
<span class="c1"># all is good, craft away</span>
<span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">craft</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">msg</span><span class="p">(</span><span class="s2">&quot;You are not good enough to craft this. Better luck next time!&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="p">[]</span>
</pre></div>
</div>
<p>In this example we introduce a <code class="docutils literal notranslate"><span class="pre">.difficulty</span></code> for the recipe and makes a dice roll to see
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.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>
<section id="even-more-customization">
<h2>Even more customization<a class="headerlink" href="#even-more-customization" title="Permalink to this headline"></a></h2>
<p>If you want to build something even more custom (maybe using different input types of validation logic)
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>
</div>
</div>
</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="Contrib-Gendersub.html" title="Gendersub"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Cooldowns.html" title="Cooldowns"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Crafting 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,187 @@
<!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>
<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="Email-based login system" href="Contrib-Email-Login.html" />
<link rel="prev" title="Components" href="Contrib-Components.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="Contrib-Email-Login.html" title="Email-based login system"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Components.html" title="Components"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Components.html"
title="previous chapter">Components</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Email-Login.html"
title="next chapter">Email-based login system</a></p>
<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="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>
</div>
</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="Contrib-Email-Login.html" title="Email-based login system"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Components.html" title="Components"
>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="Contribs-Overview.html" >Contribs</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,206 @@
<!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 roller &#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>
<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="Health Bar" href="Contrib-Health-Bar.html" />
<link rel="prev" title="Character Creator contrib" href="Contrib-Character-Creator.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="Contrib-Health-Bar.html" title="Health Bar"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Character-Creator.html" title="Character Creator contrib"
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="Contribs-Overview.html" accesskey="U">Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Dice roller</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Dice roller</a><ul>
<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>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Character-Creator.html"
title="previous chapter">Character Creator contrib</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Health-Bar.html"
title="next chapter">Health Bar</a></p>
<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="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="dice-roller">
<h1>Dice roller<a class="headerlink" href="#dice-roller" 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 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">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 id="usage">
<h2>Usage:<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<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">
<h3>Rolling dice from code<a class="headerlink" href="#rolling-dice-from-code" title="Permalink to this headline"></a></h3>
<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>
</section>
</div>
</div>
</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="Contrib-Health-Bar.html" title="Health Bar"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Character-Creator.html" title="Character Creator contrib"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Dice roller</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,170 @@
<!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>
<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 in-game Python system" href="Contrib-Ingame-Python.html" />
<link rel="prev" title="Custom gameime" href="Contrib-Custom-Gametime.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="Contrib-Ingame-Python.html" title="Evennia in-game Python system"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Custom-Gametime.html" title="Custom gameime"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Custom-Gametime.html"
title="previous chapter">Custom gameime</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Ingame-Python.html"
title="next chapter">Evennia in-game Python system</a></p>
<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="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>
</div>
</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="Contrib-Ingame-Python.html" title="Evennia in-game Python system"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Custom-Gametime.html" title="Custom gameime"
>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="Contribs-Overview.html" >Contribs</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,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>EvAdventure &#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>
<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="TutorialMirror" href="Contrib-Mirror.html" />
<link rel="prev" title="Script example" href="Contrib-Bodyfunctions.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="Contrib-Mirror.html" title="TutorialMirror"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Bodyfunctions.html" title="Script example"
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="Contribs-Overview.html" accesskey="U">Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">EvAdventure</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">EvAdventure</a><ul>
<li><a class="reference internal" href="#features">Features</a></li>
<li><a class="reference internal" href="#installation">Installation</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Bodyfunctions.html"
title="previous chapter">Script example</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Mirror.html"
title="next chapter">TutorialMirror</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Evadventure.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-Evadventure.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="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="evadventure">
<h1>EvAdventure<a class="headerlink" href="#evadventure" title="Permalink to this headline"></a></h1>
<p>Contrib by Griatch 2022</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>NOTE - this tutorial is WIP and NOT complete! It was put on hold to focus on
releasing Evennia 1.0. You will still learn things from it, but dont expect
perfection.</p>
</div>
<p>A complete example MUD using Evennia. This is the final result of what is
implemented if you follow the Getting-Started tutorial. Its recommended
that you follow the tutorial step by step and write your own code. But if
you prefer you can also pick apart or use this as a starting point for your
own game.</p>
<section id="features">
<h2>Features<a class="headerlink" href="#features" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Uses a MUD-version of the <a class="reference external" href="https://rpggeek.com/rpg/50827/knave">Knave</a> old-school
fantasy ruleset by Ben Milton (classless and overall compatible with early
edition D&amp;D), released under the Creative Commons Attribution (all uses,
including commercial are allowed
as long as attribution is given).</p></li>
<li><p>Character creation using an editable character sheet</p></li>
<li><p>Weapons, effects, healing and resting</p></li>
<li><p>Two alternative combat systems (turn-based and twitch based)</p></li>
<li><p>Magic (three spells)</p></li>
<li><p>NPC/mobs with simple AI.</p></li>
<li><p>Simple Quest system.</p></li>
<li><p>Small game world.</p></li>
<li><p>Coded using best Evennia practices, with unit tests.</p></li>
</ul>
</section>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>TODO</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/tutorials/evadventure/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</section>
</section>
</div>
</div>
</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="Contrib-Mirror.html" title="TutorialMirror"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Bodyfunctions.html" title="Script example"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">EvAdventure</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,262 @@
<!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>
<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="Barter system" href="Contrib-Barter.html" />
<link rel="prev" title="Unix-like Command style" href="Contrib-Unixcommand.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="Contrib-Barter.html" title="Barter system"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Unixcommand.html" title="Unix-like Command style"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">EvscapeRoom</a><ul>
<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>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Unixcommand.html"
title="previous chapter">Unix-like Command style</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Barter.html"
title="next chapter">Barter system</a></p>
<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="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 id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h2>
<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 id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<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 id="making-your-own-evscaperoom">
<h2>Making your own evscaperoom<a class="headerlink" href="#making-your-own-evscaperoom" title="Permalink to this headline"></a></h2>
<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">
<h3>Other useful settings<a class="headerlink" href="#other-useful-settings" title="Permalink to this headline"></a></h3>
<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 id="playing-the-game">
<h2>Playing the game<a class="headerlink" href="#playing-the-game" title="Permalink to this headline"></a></h2>
<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 id="technical">
<h2>Technical<a class="headerlink" href="#technical" title="Permalink to this headline"></a></h2>
<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 id="design-philosophy">
<h2>Design Philosophy<a class="headerlink" href="#design-philosophy" title="Permalink to this headline"></a></h2>
<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>
</section>
</div>
</div>
</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="Contrib-Barter.html" title="Barter system"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Unixcommand.html" title="Unix-like Command style"
>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="Contribs-Overview.html" >Contribs</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,221 @@
<!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>
<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="Basic Map" href="Contrib-Ingame-Map-Display.html" />
<link rel="prev" title="Turn based battle system framework" href="Contrib-Turnbattle.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="Contrib-Ingame-Map-Display.html" title="Basic Map"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Turnbattle.html" title="Turn based battle system framework"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Turnbattle.html"
title="previous chapter">Turn based battle system framework</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Ingame-Map-Display.html"
title="next chapter">Basic Map</a></p>
<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="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 new 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>
</div>
</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="Contrib-Ingame-Map-Display.html" title="Basic Map"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Turnbattle.html" title="Turn based battle system framework"
>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="Contribs-Overview.html" >Contribs</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,291 @@
<!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>
<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="In-game Git Integration" href="Contrib-Git-Integration.html" />
<link rel="prev" title="Input/Output Auditing" href="Contrib-Auditing.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="Contrib-Git-Integration.html" title="In-game Git Integration"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Auditing.html" title="Input/Output Auditing"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Auditing.html"
title="previous chapter">Input/Output Auditing</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Git-Integration.html"
title="next chapter">In-game Git Integration</a></p>
<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="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>
</div>
</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="Contrib-Git-Integration.html" title="In-game Git Integration"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Auditing.html" title="Input/Output Auditing"
>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="Contribs-Overview.html" >Contribs</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,210 @@
<!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>
<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="In-Game Mail system" href="Contrib-Mail.html" />
<link rel="prev" title="Crafting system" href="Contrib-Crafting.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="Contrib-Mail.html" title="In-Game Mail system"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Crafting.html" title="Crafting system"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Crafting.html"
title="previous chapter">Crafting system</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Mail.html"
title="next chapter">In-Game Mail system</a></p>
<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="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>
<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.game_systems.gendersub</span> <span class="kn">import</span> <span class="n">SetGender</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_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">SetGender</span><span class="p">())</span> <span class="c1"># &lt;---</span>
</pre></div>
</div>
<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>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># mygame/typeclasses/characters.py</span>
<span class="c1"># ...</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.game_systems.gendersub</span> <span class="kn">import</span> <span class="n">GenderCharacter</span> <span class="c1"># &lt;---</span>
<span class="k">class</span> <span class="nc">Character</span><span class="p">(</span><span class="n">GenderCharacter</span><span class="p">):</span> <span class="c1"># &lt;---</span>
<span class="c1"># ...</span>
</pre></div>
</div>
<p>Reload the server (<code class="docutils literal notranslate"><span class="pre">evennia</span> <span class="pre">reload</span></code> or <code class="docutils literal notranslate"><span class="pre">reload</span></code> from inside the game).</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>
</div>
</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="Contrib-Mail.html" title="In-Game Mail system"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Crafting.html" title="Crafting system"
>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="Contribs-Overview.html" >Contribs</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,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>In-game Git Integration &#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>
<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="Random Name Generator" href="Contrib-Name-Generator.html" />
<link rel="prev" title="Easy fillable form" href="Contrib-Fieldfill.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="Contrib-Name-Generator.html" title="Random Name Generator"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Fieldfill.html" title="Easy fillable form"
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="Contribs-Overview.html" accesskey="U">Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">In-game Git Integration</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">In-game Git Integration</a><ul>
<li><a class="reference internal" href="#dependencies">Dependencies</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="#settings-used">Settings Used</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Fieldfill.html"
title="previous chapter">Easy fillable form</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Name-Generator.html"
title="next chapter">Random Name Generator</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Git-Integration.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-Git-Integration.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="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="in-game-git-integration">
<h1>In-game Git Integration<a class="headerlink" href="#in-game-git-integration" title="Permalink to this headline"></a></h1>
<p>Contribution by helpme (2022)</p>
<p>A module to integrate a stripped-down version of git within the game, allowing developers to view their git status, change branches, and pull updated code of both their local mygame repo and Evennia core. After a successful pull or checkout, the git command will reload the game: Manual restarts may be required to to apply certain changes that would impact persistent scripts etc.</p>
<p>Once the contrib is set up, integrating remote changes is as simple as entering the following into your game:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">pull</span>
</pre></div>
</div>
<p>The repositories you want to work with, be it only your local mygame repo, only Evennia core, or both, must be git directories for the command to function. If you are only interested in using this to get upstream Evennia changes, only the Evennia repository needs to be a git repository. <a class="reference external" href="https://www.evennia.com/docs/1.0-dev/Coding/Version-Control.html">Get started with version control here.</a></p>
<section id="dependencies">
<h2>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline"></a></h2>
<p>This package requires the dependency “gitpython”, a python library used to interact with git repositories. To install, its easiest to 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="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>This utility adds a simple assortment of git commands. Import the module into your commands and add it to your command set to make it available.</p>
<p>Specifically, 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.utils.git_integration</span> <span class="kn">import</span> <span class="n">GitCmdSet</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">GitCmdSet</span><span class="p">)</span> <span class="c1"># &lt;---</span>
</pre></div>
</div>
<p>Then <code class="docutils literal notranslate"><span class="pre">reload</span></code> to make the git command available.</p>
</section>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<p>This utility will only work if the directory you wish to work with is a git directory. If they are not, you will be prompted to initiate your directory as a git repository using the following commands in your terminal:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">init</span>
<span class="n">git</span> <span class="n">remote</span> <span class="n">add</span> <span class="n">origin</span> <span class="s1">&#39;link to your repository&#39;</span>
</pre></div>
</div>
<p>By default, the git commands are only available to those with Developer permissions and higher. You can change this by overriding the command and setting its locks from “cmd:pperm(Developer)” to the lock of your choice.</p>
<p>The supported commands are:</p>
<ul class="simple">
<li><p>git status: An overview of your git repository, which files have been changed locally, and the commit youre on.</p></li>
<li><p>git branch: What branches are available for you to check out.</p></li>
<li><p>git checkout branch: Checkout a branch.</p></li>
<li><p>git pull: Pull the latest code from your current branch.</p></li>
<li><p>All of these commands are also available with evennia, to serve the same functionality related to your Evennia directory. So:</p></li>
<li><p>git evennia status</p></li>
<li><p>git evennia branch</p></li>
<li><p>git evennia checkout branch</p></li>
<li><p>git evennia pull: Pull the latest Evennia code.</p></li>
</ul>
</section>
<section id="settings-used">
<h2>Settings Used<a class="headerlink" href="#settings-used" title="Permalink to this headline"></a></h2>
<p>The utility uses the existing GAME_DIR and EVENNIA_DIR settings from <a class="reference external" href="http://settings.py">settings.py</a>. You should not need to alter these if you have a standard directory setup, they ought to exist without any setup required from you.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/utils/git_integration/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</section>
</section>
</div>
</div>
</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="Contrib-Name-Generator.html" title="Random Name Generator"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Fieldfill.html" title="Easy fillable form"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">In-game Git Integration</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,173 @@
<!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>
<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="Roleplaying base system for Evennia" href="Contrib-RPSystem.html" />
<link rel="prev" title="Dice roller" href="Contrib-Dice.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="Contrib-RPSystem.html" title="Roleplaying base system for Evennia"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Dice.html" title="Dice roller"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Dice.html"
title="previous chapter">Dice roller</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-RPSystem.html"
title="next chapter">Roleplaying base system for Evennia</a></p>
<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="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>
</div>
</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="Contrib-RPSystem.html" title="Roleplaying base system for Evennia"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Dice.html" title="Dice roller"
>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="Contribs-Overview.html" >Contribs</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

@ -0,0 +1,196 @@
<!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>Basic 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>
<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="Map Builder" href="Contrib-Mapbuilder.html" />
<link rel="prev" title="Extended Room" href="Contrib-Extended-Room.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="Contrib-Mapbuilder.html" title="Map Builder"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Extended-Room.html" title="Extended Room"
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="Contribs-Overview.html" accesskey="U">Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Basic Map</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Basic Map</a><ul>
<li><a class="reference internal" href="#installation">Installation:</a></li>
<li><a class="reference internal" href="#settings">Settings:</a></li>
<li><a class="reference internal" href="#features">Features:</a><ul>
<li><a class="reference internal" href="#ascii-map-and-evennia-supports-utf-8-characters-and-even-emojis">ASCII map (and evennia supports UTF-8 characters and even emojis)</a></li>
<li><a class="reference internal" href="#new-command">New command</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Extended-Room.html"
title="previous chapter">Extended Room</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Mapbuilder.html"
title="next chapter">Map Builder</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Ingame-Map-Display.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-Ingame-Map-Display.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="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="basic-map">
<h1>Basic Map<a class="headerlink" href="#basic-map" title="Permalink to this headline"></a></h1>
<p>Contribution - helpme 2022</p>
<p>This adds an ascii <code class="docutils literal notranslate"><span class="pre">map</span></code> to a given room which can be viewed with the <code class="docutils literal notranslate"><span class="pre">map</span></code> command.
You can easily alter it to add special characters, room colors etc. The map shown is
dynamically generated on use, and supports all compass directions and up/down. Other
directions are ignored.</p>
<p>If you dont expect the map to be updated frequently, you could choose to save the
calculated map as a .ndb value on the room and render that instead of running mapping
calculations anew each time.</p>
<section id="installation">
<h2>Installation:<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Adding the <code class="docutils literal notranslate"><span class="pre">MapDisplayCmdSet</span></code> to the default character cmdset will add the <code class="docutils literal notranslate"><span class="pre">map</span></code> command.</p>
<p>Specifically, 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.grid.ingame_map_display</span> <span class="kn">import</span> <span class="n">MapDisplayCmdSet</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">MapDisplayCmdSet</span><span class="p">)</span> <span class="c1"># &lt;---</span>
</pre></div>
</div>
<p>Then <code class="docutils literal notranslate"><span class="pre">reload</span></code> to make the new commands available.</p>
</section>
<section id="settings">
<h2>Settings:<a class="headerlink" href="#settings" title="Permalink to this headline"></a></h2>
<p>In order to change your default map size, you can add to <code class="docutils literal notranslate"><span class="pre">mygame/server/settings.py</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">BASIC_MAP_SIZE</span> <span class="o">=</span> <span class="mi">5</span> <span class="c1"># This changes the default map width/height.</span>
</pre></div>
</div>
</section>
<section id="features">
<h2>Features:<a class="headerlink" href="#features" title="Permalink to this headline"></a></h2>
<section id="ascii-map-and-evennia-supports-utf-8-characters-and-even-emojis">
<h3>ASCII map (and evennia supports UTF-8 characters and even emojis)<a class="headerlink" href="#ascii-map-and-evennia-supports-utf-8-characters-and-even-emojis" title="Permalink to this headline"></a></h3>
<p>This produces an ASCII map for players of configurable size.</p>
</section>
<section id="new-command">
<h3>New command<a class="headerlink" href="#new-command" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">CmdMap</span></code> - view the map</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/ingame_map_display/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>
</div>
</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="Contrib-Mapbuilder.html" title="Map Builder"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Extended-Room.html" title="Extended Room"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Basic 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

@ -0,0 +1,369 @@
<!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>Dialogues in events &#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>
<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="A voice operated elevator using events" href="Contrib-Ingame-Python-Tutorial-Elevator.html" />
<link rel="prev" title="Evennia in-game Python system" href="Contrib-Ingame-Python.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="Contrib-Ingame-Python-Tutorial-Elevator.html" title="A voice operated elevator using events"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Ingame-Python.html" title="Evennia in-game Python system"
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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="Contrib-Ingame-Python.html" accesskey="U">Evennia in-game Python system</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Dialogues in events</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Dialogues in events</a><ul>
<li><a class="reference internal" href="#a-first-example-with-a-first-character">A first example with a first character</a></li>
<li><a class="reference internal" href="#the-same-callback-for-several-keywords">The same callback for several keywords</a></li>
<li><a class="reference internal" href="#a-longer-callback">A longer callback</a></li>
<li><a class="reference internal" href="#tutorial-f-a-q">Tutorial F.A.Q.</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Ingame-Python.html"
title="previous chapter">Evennia in-game Python system</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Ingame-Python-Tutorial-Elevator.html"
title="next chapter">A voice operated elevator using events</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Ingame-Python-Tutorial-Dialogue.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-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>
</div>
</div>
<div class="bodywrapper">
<div class="body" role="main">
<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>
<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>
<blockquote>
<div><p>What will we try to do?</p>
</div></blockquote>
<p>In this tutorial, we are going to create a basic dialogue to have several characters automatically
respond to specific messages said by others.</p>
<section id="a-first-example-with-a-first-character">
<h2>A first example with a first character<a class="headerlink" href="#a-first-example-with-a-first-character" title="Permalink to this headline"></a></h2>
<p>Lets create a character to begin with.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>@charcreate a merchant
</pre></div>
</div>
<p>This will create a merchant in the room where you currently are. It doesnt have anything, like a
description, you can decorate it a bit if you like.</p>
<p>As said above, the in-game Python system consists in linking objects with arbitrary code. This code
will be executed in some circumstances. Here, the circumstance is “when someone says something in
the same room”, and might be more specific like “when someone says hello”. Well decide what code
to run (well actually type the code in-game). Using the vocabulary of the in-game Python system,
well create a callback: a callback is just a set of lines of code that will run under some
conditions.</p>
<p>You can have an overview of every “conditions” in which callbacks can be created using the <code class="docutils literal notranslate"><span class="pre">&#64;call</span></code>
command (short for <code class="docutils literal notranslate"><span class="pre">&#64;callback</span></code>). You need to give it an object as argument. Here for instance, we
could do:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>@call a merchant
</pre></div>
</div>
<p>You should see a table with three columns, showing the list of events existing on our newly-created
merchant. There are quite a lot of them, as it is, althougn no line of code has been set yet. For
our system, you might be more interested by the line describing the <code class="docutils literal notranslate"><span class="pre">say</span></code> event:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>| say | 0 (0) | After another character has said something in |
| | | the character&#39;s room. |
</pre></div>
</div>
<p>Well create a callback on the <code class="docutils literal notranslate"><span class="pre">say</span></code> event, called when we say “hello” in the merchants room:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>@call/add a merchant = say hello
</pre></div>
</div>
<p>Before seeing what this command displays, lets see the command syntax itself:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">&#64;call</span></code> is the command name, <code class="docutils literal notranslate"><span class="pre">/add</span></code> is a switch. You can read the help of the command to get the
help of available switches and a brief overview of syntax.</p></li>
<li><p>We then enter the objects name, here “a merchant”. You can enter the ID too (“#3” in my case),
which is useful to edit the object when youre not in the same room. You can even enter part of the
name, as usual.</p></li>
<li><p>An equal sign, a simple separator.</p></li>
<li><p>The events name. Here, its “say”. The available events are displayed when you use <code class="docutils literal notranslate"><span class="pre">&#64;call</span></code>
without switch.</p></li>
<li><p>After a space, we enter the conditions in which this callback should be called. Here, the
conditions represent what the other character should say. We enter “hello”. Meaning that if
someone says something containing “hello” in the room, the callback we are now creating will be
called.</p></li>
</ul>
<p>When you enter this command, you should see something like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">After</span> <span class="n">another</span> <span class="n">character</span> <span class="n">has</span> <span class="n">said</span> <span class="n">something</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">character</span><span class="s1">&#39;s room.</span>
<span class="n">This</span> <span class="n">event</span> <span class="ow">is</span> <span class="n">called</span> <span class="n">right</span> <span class="n">after</span> <span class="n">another</span> <span class="n">character</span> <span class="n">has</span> <span class="n">said</span>
<span class="n">something</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">same</span> <span class="n">location</span><span class="o">.</span> <span class="n">The</span> <span class="n">action</span> <span class="n">cannot</span> <span class="n">be</span> <span class="n">prevented</span>
<span class="n">at</span> <span class="n">this</span> <span class="n">moment</span><span class="o">.</span> <span class="n">Instead</span><span class="p">,</span> <span class="n">this</span> <span class="n">event</span> <span class="ow">is</span> <span class="n">ideal</span> <span class="n">to</span> <span class="n">create</span> <span class="n">keywords</span>
<span class="n">that</span> <span class="n">would</span> <span class="n">trigger</span> <span class="n">a</span> <span class="n">character</span> <span class="p">(</span><span class="n">like</span> <span class="n">a</span> <span class="n">NPC</span><span class="p">)</span> <span class="ow">in</span> <span class="n">doing</span> <span class="n">something</span>
<span class="k">if</span> <span class="n">a</span> <span class="n">specific</span> <span class="n">phrase</span> <span class="ow">is</span> <span class="n">spoken</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">same</span> <span class="n">location</span><span class="o">.</span>
<span class="n">To</span> <span class="n">use</span> <span class="n">this</span> <span class="n">event</span><span class="p">,</span> <span class="n">you</span> <span class="n">have</span> <span class="n">to</span> <span class="n">specify</span> <span class="n">a</span> <span class="nb">list</span> <span class="n">of</span> <span class="n">keywords</span> <span class="k">as</span>
<span class="n">parameters</span> <span class="n">that</span> <span class="n">should</span> <span class="n">be</span> <span class="n">present</span><span class="p">,</span> <span class="k">as</span> <span class="n">separate</span> <span class="n">words</span><span class="p">,</span> <span class="ow">in</span> <span class="n">the</span>
<span class="n">spoken</span> <span class="n">phrase</span><span class="o">.</span> <span class="n">For</span> <span class="n">instance</span><span class="p">,</span> <span class="n">you</span> <span class="n">can</span> <span class="nb">set</span> <span class="n">a</span> <span class="n">callback</span> <span class="n">that</span> <span class="n">would</span>
<span class="n">fire</span> <span class="k">if</span> <span class="n">the</span> <span class="n">phrase</span> <span class="n">spoken</span> <span class="n">by</span> <span class="n">the</span> <span class="n">character</span> <span class="n">contains</span> <span class="s2">&quot;menu&quot;</span> <span class="ow">or</span>
<span class="s2">&quot;dinner&quot;</span> <span class="ow">or</span> <span class="s2">&quot;lunch&quot;</span><span class="p">:</span>
<span class="nd">@call</span><span class="o">/</span><span class="n">add</span> <span class="o">...</span> <span class="o">=</span> <span class="n">say</span> <span class="n">menu</span><span class="p">,</span> <span class="n">dinner</span><span class="p">,</span> <span class="n">lunch</span>
<span class="n">Then</span> <span class="k">if</span> <span class="n">one</span> <span class="n">of</span> <span class="n">the</span> <span class="n">words</span> <span class="ow">is</span> <span class="n">present</span> <span class="ow">in</span> <span class="n">what</span> <span class="n">the</span> <span class="n">character</span> <span class="n">says</span><span class="p">,</span>
<span class="n">this</span> <span class="n">callback</span> <span class="n">will</span> <span class="n">fire</span><span class="o">.</span>
<span class="n">Variables</span> <span class="n">you</span> <span class="n">can</span> <span class="n">use</span> <span class="ow">in</span> <span class="n">this</span> <span class="n">event</span><span class="p">:</span>
<span class="n">speaker</span><span class="p">:</span> <span class="n">the</span> <span class="n">character</span> <span class="n">speaking</span> <span class="ow">in</span> <span class="n">this</span> <span class="n">room</span><span class="o">.</span>
<span class="n">character</span><span class="p">:</span> <span class="n">the</span> <span class="n">character</span> <span class="n">connected</span> <span class="n">to</span> <span class="n">this</span> <span class="n">event</span><span class="o">.</span>
<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>
</pre></div>
</div>
<p>Thats some list of information. Whats most important to us now is:</p>
<ul class="simple">
<li><p>The “say” event is called whenever someone else speaks in the room.</p></li>
<li><p>We can set callbacks to fire when specific keywords are present in the phrase by putting them as
additional parameters. Here we have set this parameter to “hello”. We can have several keywords
separated by a comma (well see this in more details later).</p></li>
<li><p>We have three default variables we can use in this callback: <code class="docutils literal notranslate"><span class="pre">speaker</span></code> which contains the
character who speaks, <code class="docutils literal notranslate"><span class="pre">character</span></code> which contains the character whos modified by the in-game Python
system (here, or merchant), and <code class="docutils literal notranslate"><span class="pre">message</span></code> which contains the spoken phrase.</p></li>
</ul>
<p>This concept of variables is important. If it makes things more simple to you, think of them as
parameters in a function: they can be used inside of the function body because they have been set
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="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>
<p>For our first test, lets type something like:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">character</span><span class="o">.</span><span class="n">location</span><span class="o">.</span><span class="n">msg_contents</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{character}</span><span class="s2"> shrugs and says: &#39;well, yes, hello to you!&#39;&quot;</span><span class="p">,</span>
<span class="n">mapping</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span><span class="n">character</span><span class="o">=</span><span class="n">character</span><span class="p">))</span>
</pre></div>
</div>
<p>Once you have entered this line, you can type <code class="docutils literal notranslate"><span class="pre">:wq</span></code> to save the editor and quit it.</p>
<p>And now if you use the “say” command with a message containing “hello”:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">You</span> <span class="n">say</span><span class="p">,</span> <span class="s2">&quot;Hello sir merchant!&quot;</span>
<span class="n">a</span> <span class="n">merchant</span><span class="p">(</span><span class="c1">#3) shrugs and says: &#39;well, yes, hello to you!&#39;</span>
</pre></div>
</div>
<p>If you say something that doesnt contain “hello”, our callback wont execute.</p>
<p><strong>In summary</strong>:</p>
<ol class="simple">
<li><p>When we say something in the room, using the “say” command, the “say” event of all characters
(except us) is called.</p></li>
<li><p>The in-game Python system looks at what we have said, and checks whether one of our callbacks in
the “say” event contains a keyword that we have spoken.</p></li>
<li><p>If so, call it, defining the event variables as we have seen.</p></li>
<li><p>The callback is then executed as normal Python code. Here we have called the <code class="docutils literal notranslate"><span class="pre">msg_contents</span></code>
method on the characters location (probably a room) to display a message to the entire room. We
have also used mapping to easily display the characters name. This is not specific to the in-game
Python system. If you feel overwhelmed by the code weve used, just shorten it and use something
more simple, for instance:</p></li>
</ol>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">speaker</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;You have said something to me.&quot;</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="the-same-callback-for-several-keywords">
<h2>The same callback for several keywords<a class="headerlink" href="#the-same-callback-for-several-keywords" title="Permalink to this headline"></a></h2>
<p>Its easy to create a callback that will be triggered if the sentence contains one of several
keywords.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>@call/add merchant = say trade, trader, goods
</pre></div>
</div>
<p>And in the editor that opens:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">character</span><span class="o">.</span><span class="n">location</span><span class="o">.</span><span class="n">msg_contents</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{character}</span><span class="s2"> says: &#39;Ho well, trade&#39;s fine as long as roads are</span>
<span class="n">safe</span><span class="o">.</span><span class="s1">&#39;&quot;, mapping=dict(character=character))</span>
</pre></div>
</div>
<p>Then you can say something with either “trade”, “trader” or “goods” in your sentence, which should
call the callback:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">You</span> <span class="n">say</span><span class="p">,</span> <span class="s2">&quot;and how is your trade going?&quot;</span>
<span class="n">a</span> <span class="n">merchant</span><span class="p">(</span><span class="c1">#3) says: &#39;Ho well, trade&#39;s fine as long as roads are safe.&#39;</span>
</pre></div>
</div>
<p>We can set several keywords when adding the callback. We just need to separate them with commas.</p>
</section>
<section id="a-longer-callback">
<h2>A longer callback<a class="headerlink" href="#a-longer-callback" title="Permalink to this headline"></a></h2>
<p>So far, we have only set one line in our callbacks. Which is useful, but we often need more. For
an entire dialogue, you might want to do a bit more than that.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>@call/add merchant = say bandit, bandits
</pre></div>
</div>
<p>And in the editor you can paste the following lines:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">character</span><span class="o">.</span><span class="n">location</span><span class="o">.</span><span class="n">msg_contents</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{character}</span><span class="s2"> says: &#39;Bandits he?&#39;&quot;</span><span class="p">,</span>
<span class="n">mapping</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span><span class="n">character</span><span class="o">=</span><span class="n">character</span><span class="p">))</span>
<span class="n">character</span><span class="o">.</span><span class="n">location</span><span class="o">.</span><span class="n">msg_contents</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{character}</span><span class="s2"> scratches his head, considering.&quot;</span><span class="p">,</span>
<span class="n">mapping</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span><span class="n">character</span><span class="o">=</span><span class="n">character</span><span class="p">))</span>
<span class="n">character</span><span class="o">.</span><span class="n">location</span><span class="o">.</span><span class="n">msg_contents</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{character}</span><span class="s2"> whispers: &#39;Aye, saw some of them, north from here. No</span>
<span class="n">trouble</span> <span class="n">o</span><span class="s1">&#39; mine, but...&#39;</span><span class="s2">&quot;, mapping=dict(character=character))</span>
<span class="n">speaker</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{character}</span><span class="s2"> looks at you more</span>
<span class="n">closely</span><span class="o">.</span><span class="s2">&quot;.format(character=character.get_display_name(speaker)))</span>
<span class="n">speaker</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{character}</span><span class="s2"> continues in a low voice: &#39;Ain&#39;t my place to say, but if you need to find</span>
<span class="s1">&#39;em, they&#39;</span><span class="n">re</span> <span class="n">encamped</span> <span class="n">some</span> <span class="n">distance</span> <span class="n">away</span> <span class="kn">from</span> <span class="nn">the</span> <span class="n">road</span><span class="p">,</span> <span class="n">I</span> <span class="n">guess</span> <span class="n">near</span> <span class="n">a</span> <span class="n">cave</span> <span class="ow">or</span>
<span class="n">something</span><span class="o">.</span><span class="s1">&#39;.&quot;.format(character=character.get_display_name(speaker)))</span>
</pre></div>
</div>
<p>Now try to ask the merchant about bandits:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">You</span> <span class="n">say</span><span class="p">,</span> <span class="s2">&quot;have you seen bandits?&quot;</span>
<span class="n">a</span> <span class="n">merchant</span><span class="p">(</span><span class="c1">#3) says: &#39;Bandits he?&#39;</span>
<span class="n">a</span> <span class="n">merchant</span><span class="p">(</span><span class="c1">#3) scratches his head, considering.</span>
<span class="n">a</span> <span class="n">merchant</span><span class="p">(</span><span class="c1">#3) whispers: &#39;Aye, saw some of them, north from here. No trouble o&#39; mine, but...&#39;</span>
<span class="n">a</span> <span class="n">merchant</span><span class="p">(</span><span class="c1">#3) looks at you more closely.</span>
<span class="n">a</span> <span class="n">merchant</span><span class="p">(</span><span class="c1">#3) continues in a low voice: &#39;Ain&#39;t my place to say, but if you need to find &#39;em,</span>
<span class="n">they</span><span class="s1">&#39;re encamped some distance away from the road, I guess near a cave or something.&#39;</span><span class="o">.</span>
</pre></div>
</div>
<p>Notice here that the first lines of dialogue are spoken to the entire room, but then the merchant is
talking directly to the speaker, and only the speaker hears it. Theres no real limit to what you
can do with this.</p>
<ul class="simple">
<li><p>You can set a mood system, storing attributes in the NPC itself to tell you in what mood he is,
which will influence the information he will give… perhaps the accuracy of it as well.</p></li>
<li><p>You can add random phrases spoken in some context.</p></li>
<li><p>You can use other actions (youre not limited to having the merchant say something, you can ask
him to move, gives you something, attack if you have a combat system, or whatever else).</p></li>
<li><p>The callbacks are in pure Python, so you can write conditions or loops.</p></li>
<li><p>You can add in “pauses” between some instructions using chained events. This tutorial wont
describe how to do that however. You already have a lot to play with.</p></li>
</ul>
</section>
<section id="tutorial-f-a-q">
<h2>Tutorial F.A.Q.<a class="headerlink" href="#tutorial-f-a-q" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p><strong>Q:</strong> can I create several characters who would answer to specific dialogue?</p></li>
<li><p><strong>A:</strong> of course. Te in-game Python system is so powerful because you can set unique code for
various objects. You can have several characters answering to different things. You can even have
different characters in the room answering to greetings. All callbacks will be executed one after
another.</p></li>
<li><p><strong>Q:</strong> can I have two characters answering to the same dialogue in exactly the same way?</p></li>
<li><p><strong>A:</strong> Its possible but not so easy to do. Usually, event grouping is set in code, and depends
on different games. However, if it is for some infrequent occurrences, its easy to do using
[chained
events](<a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia/contrib/ingame_python/README.md#chained-">https://github.com/evennia/evennia/blob/master/evennia/contrib/ingame_python/README.md#chained-</a>
events).</p></li>
<li><p><strong>Q:</strong> is it possible to deploy callbacks on all characters sharing the same prototype?</p></li>
<li><p><strong>A:</strong> not out of the box. This depends on individual settings in code. One can imagine that all
characters of some type would share some events, but this is game-specific. Rooms of the same zone
could share the same events as well. It is possible to do but requires modification of the source
code.</p></li>
<li><p>Next tutorial: [adding a voice-operated elevator with events](A-voice-operated-elevator-using-
events).</p></li>
</ul>
</section>
</section>
</div>
</div>
</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="Contrib-Ingame-Python-Tutorial-Elevator.html" title="A voice operated elevator using events"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Ingame-Python.html" title="Evennia in-game Python system"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="Contrib-Ingame-Python.html" >Evennia in-game Python system</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Dialogues in events</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,557 @@
<!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>A voice operated elevator using events &#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>
<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="Menu-based login system" href="Contrib-Menu-Login.html" />
<link rel="prev" title="Dialogues in events" href="Contrib-Ingame-Python-Tutorial-Dialogue.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="Contrib-Menu-Login.html" title="Menu-based login system"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Ingame-Python-Tutorial-Dialogue.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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="Contrib-Ingame-Python.html" accesskey="U">Evennia in-game Python system</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>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">A voice operated elevator using events</a><ul>
<li><a class="reference internal" href="#our-study-case">Our study case</a></li>
<li><a class="reference internal" href="#creating-the-rooms-and-exits-we-need">Creating the rooms and exits we need</a></li>
<li><a class="reference internal" href="#our-first-callback-in-the-elevator">Our first callback in the elevator</a></li>
<li><a class="reference internal" href="#our-entire-callback-in-the-elevator">Our entire callback in the elevator</a></li>
<li><a class="reference internal" href="#adding-a-pause-in-our-callback">Adding a pause in our callback</a></li>
<li><a class="reference internal" href="#changing-exit-messages">Changing exit messages</a></li>
<li><a class="reference internal" href="#tutorial-f-a-q">Tutorial F.A.Q.</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Ingame-Python-Tutorial-Dialogue.html"
title="previous chapter">Dialogues in events</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Menu-Login.html"
title="next chapter">Menu-based login system</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Ingame-Python-Tutorial-Elevator.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-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>
</div>
</div>
<div class="bodywrapper">
<div class="body" role="main">
<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>
<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
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.</p>
<blockquote>
<div><p>What will we try to do?</p>
</div></blockquote>
<p>In this tutorial, we are going to create a simple voice-operated elevator. In terms of features, we
will:</p>
<ul class="simple">
<li><p>Explore events with parameters.</p></li>
<li><p>Work on more interesting callbacks.</p></li>
<li><p>Learn about chained events.</p></li>
<li><p>Play with variable modification in callbacks.</p></li>
</ul>
<section id="our-study-case">
<h2>Our study case<a class="headerlink" href="#our-study-case" title="Permalink to this headline"></a></h2>
<p>Lets summarize what we want to achieve first. We would like to create a room that will represent
the inside of our elevator. In this room, a character could just say “1”, “2” or “3”, and the
elevator will start moving. The doors will close and open on the new floor (the exits leading in
and out of the elevator will be modified).</p>
<p>We will work on basic features first, and then will adjust some, showing you how easy and powerfully
independent actions can be configured through the in-game Python system.</p>
</section>
<section id="creating-the-rooms-and-exits-we-need">
<h2>Creating the rooms and exits we need<a class="headerlink" href="#creating-the-rooms-and-exits-we-need" title="Permalink to this headline"></a></h2>
<p>Well create an elevator right in our room (generally called “Limbo”, of ID 2). You could easily
adapt the following instructions if you already have some rooms and exits, of course, just remember
to check the IDs.</p>
<blockquote>
<div><p>Note: the in-game Python system uses IDs for a lot of things. While it is not mandatory, it is
good practice to know the IDs you have for your callbacks, because it will make manipulation much
quicker. There are other ways to identify objects, but as they depend on many factors, IDs are
usually the safest path in our callbacks.</p>
</div></blockquote>
<p>Lets go into limbo (<code class="docutils literal notranslate"><span class="pre">#2</span></code>) to add our elevator. Well add it to the north. To create this room,
in-game you could type:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>tunnel n = Inside of an elevator
</pre></div>
</div>
<p>The game should respond by telling you:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Created room Inside of an elevator(#3) of type typeclasses.rooms.Room.
Created Exit from Limbo to Inside of an elevator: north(#4) (n).
Created Exit back from Inside of an elevator to Limbo: south(#5) (s).
</pre></div>
</div>
<p>Note the given IDs:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">#2</span></code> is limbo, the first room the system created.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">#3</span></code> is our room inside of an elevator.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">#4</span></code> is the north exit from Limbo to our elevator.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">#5</span></code> is the south exit from an elevator to Limbo.</p></li>
</ul>
<p>Keep these IDs somewhere for the demonstration. You will shortly see why they are important.</p>
<blockquote>
<div><p>Why have we created exits to our elevator and back to Limbo? Isnt the elevator supposed to move?</p>
</div></blockquote>
<p>It is. But we need to have exits that will represent the way inside the elevator and out. What we
will do, at every floor, will be to change these exits so they become connected to the right room.
Youll see this process a bit later.</p>
<p>We have two more rooms to create: our floor 2 and 3. This time, well use <code class="docutils literal notranslate"><span class="pre">dig</span></code>, because we dont
need exits leading there, not yet anyway.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>dig The second floor
dig The third floor
</pre></div>
</div>
<p>Evennia should answer with:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Created room The second floor(#6) of type typeclasses.rooms.Room.
Created room The third floor(#7) of type typeclasses.rooms.Room.
</pre></div>
</div>
<p>Add these IDs to your list, we will use them too.</p>
</section>
<section id="our-first-callback-in-the-elevator">
<h2>Our first callback in the elevator<a class="headerlink" href="#our-first-callback-in-the-elevator" title="Permalink to this headline"></a></h2>
<p>Lets go to the elevator (you could use <code class="docutils literal notranslate"><span class="pre">tel</span> <span class="pre">#3</span></code> if you have the same IDs I have).</p>
<p>This is our elevator room. It looks a bit empty, feel free to add a prettier description or other
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="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
possible events in this room.</p>
<p>In the table, you should see the “say” event, which is called when somebody says something in the
room. So well need to add a callback to this event. Dont worry if youre a bit lost, just follow
the following steps, the way they connect together will become more obvious.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>call/add here = say 1, 2, 3
</pre></div>
</div>
<ol class="simple">
<li><p>We need to add a callback. A callback contains the code that will be executed at a given time.
So we use the <code class="docutils literal notranslate"><span class="pre">call/add</span></code> command and switch.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">here</span></code> is our object, the room in which we are.</p></li>
<li><p>An equal sign.</p></li>
<li><p>The name of the event to which the callback should be connected. Here, the event is “say”.
Meaning this callback will be executed every time somebody says something in the room.</p></li>
<li><p>But we add an event parameter to indicate the keywords said in the room that should execute our
callback. Otherwise, our callback would be called every time somebody speaks, no matter what. Here
we limit, indicating our callback should be executed only if the spoken message contains “1”, “2” or
“3”.</p></li>
</ol>
<p>An editor should open, inviting you to enter the Python code that should be executed. The first
thing to remember is to read the text provided (it can contain important information) and, most of
all, the list of variables that are available in this callback:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Variables</span> <span class="n">you</span> <span class="n">can</span> <span class="n">use</span> <span class="ow">in</span> <span class="n">this</span> <span class="n">event</span><span class="p">:</span>
<span class="n">character</span><span class="p">:</span> <span class="n">the</span> <span class="n">character</span> <span class="n">having</span> <span class="n">spoken</span> <span class="ow">in</span> <span class="n">this</span> <span class="n">room</span><span class="o">.</span>
<span class="n">room</span><span class="p">:</span> <span class="n">the</span> <span class="n">room</span> <span class="n">connected</span> <span class="n">to</span> <span class="n">this</span> <span class="n">event</span><span class="o">.</span>
<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="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>
<p>This is important, in order to know what variables we can use in our callback out-of-the-box. Lets
write a single line to be sure our callback is called when we expect it to:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">character</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;You just said </span><span class="si">{</span><span class="n">message</span><span class="si">}</span><span class="s2">.&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>You can paste this line in-game, then type the <code class="docutils literal notranslate"><span class="pre">:wq</span></code> command to exit the editor and save your
modifications.</p>
<p>Lets check. Try to say “hello” in the room. You should see the standard message, but nothing
more. Now try to say “1”. Below the standard message, you should see:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>You just said 1.
</pre></div>
</div>
<p>You can try it. Our callback is only called when we say “1”, “2” or “3”. Which is just what we
want.</p>
<p>Lets go back in our code editor and add something more useful.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>call/edit here = say
</pre></div>
</div>
<blockquote>
<div><p>Notice that we used the “edit” switch this time, since the callback exists, we just want to edit
it.</p>
</div></blockquote>
<p>The editor opens again. Lets empty it first:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>:DD
</pre></div>
</div>
<p>And turn off automatic indentation, which will help us:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>:=
</pre></div>
</div>
<blockquote>
<div><p>Auto-indentation is an interesting feature of the code editor, but wed better not use it at this
point, it will make copy/pasting more complicated.</p>
</div></blockquote>
</section>
<section id="our-entire-callback-in-the-elevator">
<h2>Our entire callback in the elevator<a class="headerlink" href="#our-entire-callback-in-the-elevator" title="Permalink to this headline"></a></h2>
<p>So heres the time to truly code our callback in-game. Heres a little reminder:</p>
<ol class="simple">
<li><p>We have all the IDs of our three rooms and two exits.</p></li>
<li><p>When we say “1”, “2” or “3”, the elevator should move to the right room, that is change the
exits. Remember, we already have the exits, we just need to change their location and destination.</p></li>
</ol>
<p>Its a good idea to try to write this callback yourself, but dont feel bad about checking the
solution right now. Heres a possible code that you could paste in the code editor:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># First let&#39;s have some constants</span>
<span class="n">ELEVATOR</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="n">FLOORS</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;1&quot;</span><span class="p">:</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">2</span><span class="p">),</span>
<span class="s2">&quot;2&quot;</span><span class="p">:</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">6</span><span class="p">),</span>
<span class="s2">&quot;3&quot;</span><span class="p">:</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">7</span><span class="p">),</span>
<span class="p">}</span>
<span class="n">TO_EXIT</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span>
<span class="n">BACK_EXIT</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
<span class="c1"># Now we check that the elevator isn&#39;t already at this floor</span>
<span class="n">floor</span> <span class="o">=</span> <span class="n">FLOORS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
<span class="k">if</span> <span class="n">floor</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">character</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;Which floor do you want?&quot;</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">TO_EXIT</span><span class="o">.</span><span class="n">location</span> <span class="ow">is</span> <span class="n">floor</span><span class="p">:</span>
<span class="n">character</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;The elevator already is at this floor.&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># &#39;floor&#39; contains the new room where the elevator should be</span>
<span class="n">room</span><span class="o">.</span><span class="n">msg_contents</span><span class="p">(</span><span class="s2">&quot;The doors of the elevator close with a clank.&quot;</span><span class="p">)</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>
<span class="n">BACK_EXIT</span><span class="o">.</span><span class="n">destination</span> <span class="o">=</span> <span class="n">floor</span>
<span class="n">room</span><span class="o">.</span><span class="n">msg_contents</span><span class="p">(</span><span class="s2">&quot;The doors of the elevator open to </span><span class="si">{floor}</span><span class="s2">.&quot;</span><span class="p">,</span>
<span class="n">mapping</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span><span class="n">floor</span><span class="o">=</span><span class="n">floor</span><span class="p">))</span>
</pre></div>
</div>
<p>Lets review this longer callback:</p>
<ol class="simple">
<li><p>We first obtain the objects of both exits and our three floors. We use the <code class="docutils literal notranslate"><span class="pre">get()</span></code> eventfunc,
which is a shortcut to obtaining objects. We usually use it to retrieve specific objects with an
ID. We put the floors in a dictionary. The keys of the dictionary are the floor number (as str),
the values are room objects.</p></li>
<li><p>Remember, the <code class="docutils literal notranslate"><span class="pre">message</span></code> variable contains the message spoken in the room. So either “1”, “2”, or
“3”. We still need to check it, however, because if the character says something like “1 2” in the
room, our callback will be executed. Lets be sure what she says is a floor number.</p></li>
<li><p>We then check if the elevator is already at this floor. Notice that we use <code class="docutils literal notranslate"><span class="pre">TO_EXIT.location</span></code>.
<code class="docutils literal notranslate"><span class="pre">TO_EXIT</span></code> contains our “north” exit, leading inside of our elevator. Therefore, its <code class="docutils literal notranslate"><span class="pre">location</span></code> will
be the room where the elevator currently is.</p></li>
<li><p>If the floor is a different one, have the elevator “move”, changing just the location and
destination of both exits.</p>
<ul class="simple">
<li><p>The <code class="docutils literal notranslate"><span class="pre">BACK_EXIT</span></code> (that is “north”) should change its location. The elevator shouldnt be
accessible through our old floor.</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">TO_EXIT</span></code> (that is “south”, the exit leading out of the elevator) should have a different
destination. When we go out of the elevator, we should find ourselves in the new floor, not the old
one.</p></li>
</ul>
</li>
</ol>
<p>Feel free to expand on this example, changing messages, making further checks. Usage and practice
are keys.</p>
<p>You can quit the editor as usual with <code class="docutils literal notranslate"><span class="pre">:wq</span></code> and test it out.</p>
</section>
<section id="adding-a-pause-in-our-callback">
<h2>Adding a pause in our callback<a class="headerlink" href="#adding-a-pause-in-our-callback" title="Permalink to this headline"></a></h2>
<p>Lets improve our callback. One thing thats worth adding would be a pause: for the time being,
when we say the floor number in the elevator, the doors close and open right away. It would be
better to have a pause of several seconds. More logical.</p>
<p>This is a great opportunity to learn about chained events. Chained events are very useful to create
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 <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>
</ul>
<p>Other than that, a chained event can be connected to a callback as usual. Well create a chained
event in our elevator, that will only contain the code necessary to open the doors to the new floor.</p>
<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 <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>
<span class="n">TO_EXIT</span><span class="o">.</span><span class="n">destination</span> <span class="o">=</span> <span class="n">ELEVATOR</span>
<span class="n">BACK_EXIT</span><span class="o">.</span><span class="n">location</span> <span class="o">=</span> <span class="n">ELEVATOR</span>
<span class="n">BACK_EXIT</span><span class="o">.</span><span class="n">destination</span> <span class="o">=</span> <span class="n">floor</span>
<span class="n">room</span><span class="o">.</span><span class="n">msg_contents</span><span class="p">(</span><span class="s2">&quot;The doors of the elevator open to </span><span class="si">{floor}</span><span class="s2">.&quot;</span><span class="p">,</span>
<span class="n">mapping</span><span class="o">=</span><span class="nb">dict</span><span class="p">(</span><span class="n">floor</span><span class="o">=</span><span class="n">floor</span><span class="p">))</span>
</pre></div>
</div>
<p>Paste this code into the editor, then use <code class="docutils literal notranslate"><span class="pre">:wq</span></code> to save and quit the editor.</p>
<p>Now lets edit our callback in the “say” event. Well have to change it a bit:</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 <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
</pre></div>
</div>
<p>Remove the current code and disable auto-indentation again:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>:DD
:=
</pre></div>
</div>
<p>And you can paste instead the following code. Notice the differences with our first attempt:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># First let&#39;s have some constants</span>
<span class="n">ELEVATOR</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="n">FLOORS</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;1&quot;</span><span class="p">:</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">2</span><span class="p">),</span>
<span class="s2">&quot;2&quot;</span><span class="p">:</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">6</span><span class="p">),</span>
<span class="s2">&quot;3&quot;</span><span class="p">:</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">7</span><span class="p">),</span>
<span class="p">}</span>
<span class="n">TO_EXIT</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span>
<span class="n">BACK_EXIT</span> <span class="o">=</span> <span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
<span class="c1"># Now we check that the elevator isn&#39;t already at this floor</span>
<span class="n">floor</span> <span class="o">=</span> <span class="n">FLOORS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
<span class="k">if</span> <span class="n">floor</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">character</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;Which floor do you want?&quot;</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">BACK_EXIT</span><span class="o">.</span><span class="n">location</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">character</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;The elevator is between floors.&quot;</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">TO_EXIT</span><span class="o">.</span><span class="n">location</span> <span class="ow">is</span> <span class="n">floor</span><span class="p">:</span>
<span class="n">character</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">&quot;The elevator already is at this floor.&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># &#39;floor&#39; contains the new room where the elevator should be</span>
<span class="n">room</span><span class="o">.</span><span class="n">msg_contents</span><span class="p">(</span><span class="s2">&quot;The doors of the elevator close with a clank.&quot;</span><span class="p">)</span>
<span class="n">TO_EXIT</span><span class="o">.</span><span class="n">location</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">BACK_EXIT</span><span class="o">.</span><span class="n">location</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">call_event</span><span class="p">(</span><span class="n">room</span><span class="p">,</span> <span class="s2">&quot;chain_1&quot;</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span>
</pre></div>
</div>
<p>What changed?</p>
<ol class="simple">
<li><p>We added a little test to make sure the elevator wasnt already moving. If it is, the
<code class="docutils literal notranslate"><span class="pre">BACK_EXIT.location</span></code> (the “south” exit leading out of the elevator) should be <code class="docutils literal notranslate"><span class="pre">None</span></code>. Well remove
the exit while the elevator is moving.</p></li>
<li><p>When the doors close, we set both exits <code class="docutils literal notranslate"><span class="pre">location</span></code> to <code class="docutils literal notranslate"><span class="pre">None</span></code>. Which “removes” them from their
room but doesnt destroy them. The exits still exist but they dont connect anything. If you say
“2” in the elevator and look around while the elevator is moving, you wont see any exits.</p></li>
<li><p>Instead of opening the doors immediately, we call <code class="docutils literal notranslate"><span class="pre">call_event</span></code>. We give it the object containing
the event to be called (here, our elevator), the name of the event to be called (here, “chain_1”)
and the number of seconds from now when the event should be called (here, <code class="docutils literal notranslate"><span class="pre">15</span></code>).</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">chain_1</span></code> callback we have created contains the code to “re-open” the elevator doors. That
is, besides displaying a message, it reset the exits <code class="docutils literal notranslate"><span class="pre">location</span></code> and <code class="docutils literal notranslate"><span class="pre">destination</span></code>.</p></li>
</ol>
<p>If you try to say “3” in the elevator, you should see the doors closing. Look around you and you
wont see any exit. Then, 15 seconds later, the doors should open, and you can leave the elevator
to go to the third floor. While the elevator is moving, the exit leading to it will be
inaccessible.</p>
<blockquote>
<div><p>Note: we dont define the variables again in our chained event, we just call them. When we
execute <code class="docutils literal notranslate"><span class="pre">call_event</span></code>, a copy of our current variables is placed in the database. These variables
will be restored and accessible again when the chained event is called.</p>
</div></blockquote>
<p>You can use the <code class="docutils literal notranslate"><span class="pre">call/tasks</span></code> command to see the tasks waiting to be executed. For instance, say “2”
in the room, notice the doors closing, and then type the <code class="docutils literal notranslate"><span class="pre">call/tasks</span></code> command. You will see a task
in the elevator, waiting to call the <code class="docutils literal notranslate"><span class="pre">chain_1</span></code> event.</p>
</section>
<section id="changing-exit-messages">
<h2>Changing exit messages<a class="headerlink" href="#changing-exit-messages" title="Permalink to this headline"></a></h2>
<p>Heres another nice little feature of events: you can modify the message of a single exit without
altering the others. In this case, when someone goes north into our elevator, wed like to see
something like: “someone walks into the elevator.” Something similar for the back exit would be
great too.</p>
<p>Inside of the elevator, you can look at the available events on the exit leading outside (south).</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>call south
</pre></div>
</div>
<p>You should see two interesting rows in this table:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">|</span> <span class="n">msg_arrive</span> <span class="o">|</span> <span class="mi">0</span> <span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">|</span> <span class="n">Customize</span> <span class="n">the</span> <span class="n">message</span> <span class="n">when</span> <span class="n">a</span> <span class="n">character</span> <span class="o">|</span>
<span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="n">arrives</span> <span class="n">through</span> <span class="n">this</span> <span class="n">exit</span><span class="o">.</span> <span class="o">|</span>
<span class="o">|</span> <span class="n">msg_leave</span> <span class="o">|</span> <span class="mi">0</span> <span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">|</span> <span class="n">Customize</span> <span class="n">the</span> <span class="n">message</span> <span class="n">when</span> <span class="n">a</span> <span class="n">character</span> <span class="n">leaves</span> <span class="o">|</span>
<span class="o">|</span> <span class="o">|</span> <span class="o">|</span> <span class="n">through</span> <span class="n">this</span> <span class="n">exit</span><span class="o">.</span> <span class="o">|</span>
</pre></div>
</div>
<p>So we can change the message others see when a character leaves, by editing the “msg_leave” event.
Lets do that:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>call/add south = msg_leave
</pre></div>
</div>
<p>Take the time to read the help. It gives you all the information you should need. Well need to
change the “message” variable, and use custom mapping (between braces) to alter the message. Were
given an example, lets use it. In the code editor, you can paste the following line:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">{character}</span><span class="s2"> walks out of the elevator.&quot;</span>
</pre></div>
</div>
<p>Again, save and quit the editor by entering <code class="docutils literal notranslate"><span class="pre">:wq</span></code>. You can create a new character to see it leave.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>charcreate A beggar
tel #8 = here
</pre></div>
</div>
<p>(Obviously, adapt the ID if necessary.)</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>py self.search(&quot;beggar&quot;).move_to(self.search(&quot;south&quot;))
</pre></div>
</div>
<p>This is a crude way to force our beggar out of the elevator, but it allows us to test. You should
see:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>A beggar(#8) walks out of the elevator.
</pre></div>
</div>
<p>Great! Lets do the same thing for the exit leading inside of the elevator. Follow the beggar,
then edit “msg_leave” of “north”:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>call/add north = msg_leave
</pre></div>
</div>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">{character}</span><span class="s2"> walks into the elevator.&quot;</span>
</pre></div>
</div>
<p>Again, you can force our beggar to move and see the message we have just set. This modification
applies to these two exits, obviously: the custom message wont be used for other exits. Since we
use the same exits for every floor, this will be available no matter at what floor the elevator is,
which is pretty neat!</p>
</section>
<section id="tutorial-f-a-q">
<h2>Tutorial F.A.Q.<a class="headerlink" href="#tutorial-f-a-q" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p><strong>Q:</strong> what happens if the game reloads or shuts down while a task is waiting to happen?</p></li>
<li><p><strong>A:</strong> if your game reloads while a task is in pause (like our elevator between floors), when the
game is accessible again, the task will be called (if necessary, with a new time difference to take
into account the reload). If the server shuts down, obviously, the task will not be called, but
will be stored and executed when the server is up again.</p></li>
<li><p><strong>Q:</strong> can I use all kinds of variables in my callback? Whether chained or not?</p></li>
<li><p><strong>A:</strong> you can use every variable type you like in your original callback. However, if you
execute <code class="docutils literal notranslate"><span class="pre">call_event</span></code>, since your variables are stored in the database, they will need to respect the
constraints on persistent attributes. A callback will not be stored in this way, for instance.
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 <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
will default to 0, meaning the chained event will be called right away). This will not create a
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
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
shown in the next tutorial.</p></li>
</ul>
</section>
</section>
</div>
</div>
</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="Contrib-Menu-Login.html" title="Menu-based login system"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Ingame-Python-Tutorial-Dialogue.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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="Contrib-Ingame-Python.html" >Evennia in-game Python system</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>
</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>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,186 @@
<!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>
<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 Multidescer" href="Contrib-Multidescer.html" />
<link rel="prev" title="Gendersub" href="Contrib-Gendersub.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="Contrib-Multidescer.html" title="Evennia Multidescer"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Gendersub.html" title="Gendersub"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Gendersub.html"
title="previous chapter">Gendersub</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Multidescer.html"
title="next chapter">Evennia Multidescer</a></p>
<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="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>
<li><p>CmdMail (IC + OOC mail, sent between players)</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># mygame/commands/default_cmds.py</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.game_systems</span> <span class="kn">import</span> <span class="n">mail</span>
<span class="c1"># in AccountCmdSet.at_cmdset_creation:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">mail</span><span class="o">.</span><span class="n">CmdMail</span><span class="p">())</span>
</pre></div>
</div>
</li>
<li><p>CmdMailCharacter (optional, IC only mail, sent between characters)</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># mygame/commands/default_cmds.py</span>
<span class="kn">from</span> <span class="nn">evennia.contrib.game_systems</span> <span class="kn">import</span> <span class="n">mail</span>
<span class="c1"># in CharacterCmdSet.at_cmdset_creation:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">mail</span><span class="o">.</span><span class="n">CmdMailCharacter</span><span class="p">())</span>
</pre></div>
</div>
</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>
</div>
</div>
</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="Contrib-Multidescer.html" title="Evennia Multidescer"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Gendersub.html" title="Gendersub"
>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="Contribs-Overview.html" >Contribs</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,423 @@
<!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>
<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="SimpleDoor" href="Contrib-Simpledoor.html" />
<link rel="prev" title="Basic Map" href="Contrib-Ingame-Map-Display.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="Contrib-Simpledoor.html" title="SimpleDoor"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Ingame-Map-Display.html" title="Basic 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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Map Builder</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="#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>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Ingame-Map-Display.html"
title="previous chapter">Basic Map</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Simpledoor.html"
title="next chapter">SimpleDoor</a></p>
<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="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 id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<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 id="usage">
<h2>Usage:<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<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 id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h2>
<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">
<h3>Example One<a class="headerlink" href="#example-one" 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">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">
<h3>Example Two<a class="headerlink" href="#example-two" title="Permalink to this headline"></a></h3>
<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>
</section>
</div>
</div>
</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="Contrib-Simpledoor.html" title="SimpleDoor"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Ingame-Map-Display.html" title="Basic 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="Contribs-Overview.html" >Contribs</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,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>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>
<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="Legacy Comms-commands" href="Contrib-Mux-Comms-Cmds.html" />
<link rel="prev" title="A voice operated elevator using events" href="Contrib-Ingame-Python-Tutorial-Elevator.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="Contrib-Mux-Comms-Cmds.html" title="Legacy Comms-commands"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Ingame-Python-Tutorial-Elevator.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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Ingame-Python-Tutorial-Elevator.html"
title="previous chapter">A voice operated elevator using events</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Mux-Comms-Cmds.html"
title="next chapter">Legacy Comms-commands</a></p>
<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="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;evennia.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>
</div>
</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="Contrib-Mux-Comms-Cmds.html" title="Legacy Comms-commands"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Ingame-Python-Tutorial-Elevator.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="Contribs-Overview.html" >Contribs</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,159 @@
<!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>
<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="Red Button example" href="Contrib-Red-Button.html" />
<link rel="prev" title="EvAdventure" href="Contrib-Evadventure.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="Contrib-Red-Button.html" title="Red Button example"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Evadventure.html" title="EvAdventure"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Evadventure.html"
title="previous chapter">EvAdventure</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Red-Button.html"
title="next chapter">Red Button example</a></p>
<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="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>
</div>
</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="Contrib-Red-Button.html" title="Red Button example"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Evadventure.html" title="EvAdventure"
>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="Contribs-Overview.html" >Contribs</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,163 @@
<!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>
<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="Puzzles System" href="Contrib-Puzzles.html" />
<link rel="prev" title="In-Game Mail system" href="Contrib-Mail.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="Contrib-Puzzles.html" title="Puzzles System"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Mail.html" title="In-Game Mail system"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Mail.html"
title="previous chapter">In-Game Mail system</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Puzzles.html"
title="next chapter">Puzzles System</a></p>
<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="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>
</div>
</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="Contrib-Puzzles.html" title="Puzzles System"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Mail.html" title="In-Game Mail system"
>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="Contribs-Overview.html" >Contribs</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,209 @@
<!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>
<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="Unix-like Command style" href="Contrib-Unixcommand.html" />
<link rel="prev" title="Menu-based login system" href="Contrib-Menu-Login.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="Contrib-Unixcommand.html" title="Unix-like Command style"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Menu-Login.html" title="Menu-based login system"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Menu-Login.html"
title="previous chapter">Menu-based login system</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Unixcommand.html"
title="next chapter">Unix-like Command style</a></p>
<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="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>
</div>
</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="Contrib-Unixcommand.html" title="Unix-like Command style"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Menu-Login.html" title="Menu-based login system"
>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="Contribs-Overview.html" >Contribs</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

@ -0,0 +1,415 @@
<!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>Random Name Generator &#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>
<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="Pseudo-random generator and registry" href="Contrib-Random-String-Generator.html" />
<link rel="prev" title="In-game Git Integration" href="Contrib-Git-Integration.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="Contrib-Random-String-Generator.html" title="Pseudo-random generator and registry"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Git-Integration.html" title="In-game Git Integration"
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="Contribs-Overview.html" accesskey="U">Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Random Name Generator</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Random Name Generator</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="#available-settings">Available Settings</a></li>
<li><a class="reference internal" href="#generating-real-names">Generating Real Names</a><ul>
<li><a class="reference internal" href="#adding-your-own-names">Adding your own names</a></li>
</ul>
</li>
<li><a class="reference internal" href="#generating-fantasy-names">Generating Fantasy Names</a><ul>
<li><a class="reference internal" href="#multi-word-fantasy-names">Multi-Word Fantasy Names</a><ul>
<li><a class="reference internal" href="#the-simple-approach">The simple approach</a></li>
<li><a class="reference internal" href="#nakku-silversmith">“Nakku Silversmith”</a></li>
<li><a class="reference internal" href="#elarion-dyrinea-thror-obinson">Elarion dYrinea, Thror Obinson</a></li>
</ul>
</li>
<li><a class="reference internal" href="#custom-fantasy-name-style-rules">Custom Fantasy Name style rules</a><ul>
<li><a class="reference internal" href="#syllable">syllable</a></li>
<li><a class="reference internal" href="#consonants">consonants</a></li>
<li><a class="reference internal" href="#start-and-end">start and end</a></li>
<li><a class="reference internal" href="#vowels">vowels</a></li>
<li><a class="reference internal" href="#length">length</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Git-Integration.html"
title="previous chapter">In-game Git Integration</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Random-String-Generator.html"
title="next chapter">Pseudo-random generator and registry</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contrib-Name-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-Name-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="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="random-name-generator">
<h1>Random Name Generator<a class="headerlink" href="#random-name-generator" title="Permalink to this headline"></a></h1>
<p>Contribution by InspectorCaracal (2022)</p>
<p>A module for generating random names, both real-world and fantasy. Real-world
names can be generated either as first (personal) names, family (last) names, or
full names (first, optional middles, and last). The name data is from <a class="reference external" href="https://www.behindthename.com/">Behind the Name</a>
and used under the <a class="reference external" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0 license</a>.</p>
<p>Fantasy names are generated from basic phonetic rules, using CVC syllable syntax.</p>
<p>Both real-world and fantasy name generation can be extended to include additional
information via your games <code class="docutils literal notranslate"><span class="pre">settings.py</span></code></p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>This is a stand-alone utility. Just import this module (<code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">evennia.contrib.utils</span> <span class="pre">import</span> <span class="pre">name_generator</span></code>) and use its functions wherever you like.</p>
</section>
<section id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<p>Import the module where you need it with the following:</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib.utils.name_generator</span> <span class="kn">import</span> <span class="n">namegen</span>
</pre></div>
</div>
<p>By default, all of the functions will return a string with one generated name.
If you specify more than one, or pass <code class="docutils literal notranslate"><span class="pre">return_list=True</span></code> as a keyword argument, the returned value will be a list of strings.</p>
<p>The module is especially useful for naming newly-created NPCs, like so:</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="n">npc_name</span> <span class="o">=</span> <span class="n">namegen</span><span class="o">.</span><span class="n">full_name</span><span class="p">()</span>
<span class="n">npc_obj</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="n">npc_name</span><span class="p">,</span> <span class="n">typeclass</span><span class="o">=</span><span class="s2">&quot;typeclasses.characters.NPC&quot;</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="available-settings">
<h2>Available Settings<a class="headerlink" href="#available-settings" title="Permalink to this headline"></a></h2>
<p>These settings can all be defined in your games <code class="docutils literal notranslate"><span class="pre">server/conf/settings.py</span></code> file.</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">NAMEGEN_FIRST_NAMES</span></code> adds a new list of first (personal) names.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">NAMEGEN_LAST_NAMES</span></code> adds a new list of last (family) names.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">NAMEGEN_REPLACE_LISTS</span></code> - set to <code class="docutils literal notranslate"><span class="pre">True</span></code> if you want to use only the names defined in your settings.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">NAMEGEN_FANTASY_RULES</span></code> lets you add new phonetic rules for generating entirely made-up names. See the section “Custom Fantasy Name style rules” for details on how this should look.</p></li>
</ul>
<p>Examples:</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="n">NAMEGEN_FIRST_NAMES</span> <span class="o">=</span> <span class="p">[</span>
<span class="p">(</span><span class="s2">&quot;Evennia&quot;</span><span class="p">,</span> <span class="s1">&#39;mf&#39;</span><span class="p">),</span>
<span class="p">(</span><span class="s2">&quot;Green Tea&quot;</span><span class="p">,</span> <span class="s1">&#39;f&#39;</span><span class="p">),</span>
<span class="p">]</span>
<span class="n">NAMEGEN_LAST_NAMES</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;Beeblebrox&quot;</span><span class="p">,</span> <span class="s2">&quot;Son of Odin&quot;</span> <span class="p">]</span>
<span class="n">NAMEGEN_FANTASY_RULES</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;example_style&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">&quot;syllable&quot;</span><span class="p">:</span> <span class="s2">&quot;(C)VC&quot;</span><span class="p">,</span>
<span class="s2">&quot;consonants&quot;</span><span class="p">:</span> <span class="p">[</span> <span class="s1">&#39;z&#39;</span><span class="p">,</span><span class="s1">&#39;z&#39;</span><span class="p">,</span><span class="s1">&#39;ph&#39;</span><span class="p">,</span><span class="s1">&#39;sh&#39;</span><span class="p">,</span><span class="s1">&#39;r&#39;</span><span class="p">,</span><span class="s1">&#39;n&#39;</span> <span class="p">],</span>
<span class="s2">&quot;start&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;m&#39;</span><span class="p">],</span>
<span class="s2">&quot;end&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;x&#39;</span><span class="p">,</span><span class="s1">&#39;n&#39;</span><span class="p">],</span>
<span class="s2">&quot;vowels&quot;</span><span class="p">:</span> <span class="p">[</span> <span class="s2">&quot;e&quot;</span><span class="p">,</span><span class="s2">&quot;e&quot;</span><span class="p">,</span><span class="s2">&quot;e&quot;</span><span class="p">,</span><span class="s2">&quot;a&quot;</span><span class="p">,</span><span class="s2">&quot;i&quot;</span><span class="p">,</span><span class="s2">&quot;i&quot;</span><span class="p">,</span><span class="s2">&quot;u&quot;</span><span class="p">,</span><span class="s2">&quot;o&quot;</span><span class="p">,</span> <span class="p">],</span>
<span class="s2">&quot;length&quot;</span><span class="p">:</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">4</span><span class="p">),</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</section>
<section id="generating-real-names">
<h2>Generating Real Names<a class="headerlink" href="#generating-real-names" title="Permalink to this headline"></a></h2>
<p>The contrib offers three functions for generating random real-world names:
<code class="docutils literal notranslate"><span class="pre">first_name()</span></code>, <code class="docutils literal notranslate"><span class="pre">last_name()</span></code>, and <code class="docutils literal notranslate"><span class="pre">full_name()</span></code>. If you want more than one name
generated at once, you can use the <code class="docutils literal notranslate"><span class="pre">num</span></code> keyword argument to specify how many.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">namegen</span><span class="o">.</span><span class="n">first_name</span><span class="p">(</span><span class="n">num</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
<span class="go">[&#39;Genesis&#39;, &#39;Tali&#39;, &#39;Budur&#39;, &#39;Dominykas&#39;, &#39;Kamau&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">namegen</span><span class="o">.</span><span class="n">first_name</span><span class="p">(</span><span class="n">gender</span><span class="o">=</span><span class="s1">&#39;m&#39;</span><span class="p">)</span>
<span class="go">&#39;Blanchard&#39;</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">first_name</span></code> function also takes a <code class="docutils literal notranslate"><span class="pre">gender</span></code> keyword argument to filter names
by gender association. f for feminine, m for masculine, mf for feminine
<em>and</em> masculine, or the default <code class="docutils literal notranslate"><span class="pre">None</span></code> to match any gendering.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">full_name</span></code> function also takes the <code class="docutils literal notranslate"><span class="pre">gender</span></code> keyword, as well as <code class="docutils literal notranslate"><span class="pre">parts</span></code> which
defines how many names make up the full name. The minimum is two: a first name and
a last name. You can also generate names with the family name first by setting
the keyword arg <code class="docutils literal notranslate"><span class="pre">surname_first</span></code> to <code class="docutils literal notranslate"><span class="pre">True</span></code></p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">namegen</span><span class="o">.</span><span class="n">full_name</span><span class="p">()</span>
<span class="go">&#39;Keeva Bernat&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">namegen</span><span class="o">.</span><span class="n">full_name</span><span class="p">(</span><span class="n">parts</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span>
<span class="go">&#39;Suzu Shabnam Kafka Baier&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">namegen</span><span class="o">.</span><span class="n">full_name</span><span class="p">(</span><span class="n">parts</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">surname_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">&#39;Ó Muircheartach Torunn Dyson&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">namegen</span><span class="o">.</span><span class="n">full_name</span><span class="p">(</span><span class="n">gender</span><span class="o">=</span><span class="s1">&#39;f&#39;</span><span class="p">)</span>
<span class="go">&#39;Wikolia Ó Deasmhumhnaigh&#39;</span>
</pre></div>
</div>
<section id="adding-your-own-names">
<h3>Adding your own names<a class="headerlink" href="#adding-your-own-names" title="Permalink to this headline"></a></h3>
<p>You can add additional names with the settings <code class="docutils literal notranslate"><span class="pre">NAMEGEN_FIRST_NAMES</span></code> and
<code class="docutils literal notranslate"><span class="pre">NAMEGEN_LAST_NAMES</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">NAMEGEN_FIRST_NAMES</span></code> should be a list of tuples, where the first value is the name
and then second value is the gender flag - m for masculine-only, f for feminine-
only, and mf for either one.</p>
<p><code class="docutils literal notranslate"><span class="pre">NAMEGEN_LAST_NAMES</span></code> should be a list of strings, where each item is an available
surname.</p>
<p>Examples:</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="n">NAMEGEN_FIRST_NAMES</span> <span class="o">=</span> <span class="p">[</span>
<span class="p">(</span><span class="s2">&quot;Evennia&quot;</span><span class="p">,</span> <span class="s1">&#39;mf&#39;</span><span class="p">),</span>
<span class="p">(</span><span class="s2">&quot;Green Tea&quot;</span><span class="p">,</span> <span class="s1">&#39;f&#39;</span><span class="p">),</span>
<span class="p">]</span>
<span class="n">NAMEGEN_LAST_NAMES</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;Beeblebrox&quot;</span><span class="p">,</span> <span class="s2">&quot;Son of Odin&quot;</span> <span class="p">]</span>
</pre></div>
</div>
<p>Set <code class="docutils literal notranslate"><span class="pre">NAMEGEN_REPLACE_LISTS</span> <span class="pre">=</span> <span class="pre">True</span></code> if you want your custom lists above to entirely replace the built-in lists rather than extend them.</p>
</section>
</section>
<section id="generating-fantasy-names">
<h2>Generating Fantasy Names<a class="headerlink" href="#generating-fantasy-names" title="Permalink to this headline"></a></h2>
<p>Generating completely made-up names is done with the <code class="docutils literal notranslate"><span class="pre">fantasy_name</span></code> function. The
contrib comes with three built-in styles of names which you can use, or you can
put a dictionary of custom name rules into <code class="docutils literal notranslate"><span class="pre">settings.py</span></code></p>
<p>Generating a fantasy name takes the ruleset key as the “style” keyword, and can
return either a single name or multiple names. By default, it will return a
single name in the built-in “harsh” style. The contrib also comes with “fluid” and “alien” styles.</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">namegen</span><span class="o">.</span><span class="n">fantasy_name</span><span class="p">()</span>
<span class="go">&#39;Vhon&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">namegen</span><span class="o">.</span><span class="n">fantasy_name</span><span class="p">(</span><span class="n">num</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s2">&quot;harsh&quot;</span><span class="p">)</span>
<span class="go">[&#39;Kha&#39;, &#39;Kizdhu&#39;, &#39;Godögäk&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">namegen</span><span class="o">.</span><span class="n">fantasy_name</span><span class="p">(</span><span class="n">num</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s2">&quot;fluid&quot;</span><span class="p">)</span>
<span class="go">[&#39;Aewalisash&#39;, &#39;Ayi&#39;, &#39;Iaa&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">namegen</span><span class="o">.</span><span class="n">fantasy_name</span><span class="p">(</span><span class="n">num</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s2">&quot;alien&quot;</span><span class="p">)</span>
<span class="go">[&quot;Qz&#39;vko&#39;&quot;, &quot;Xv&#39;w&#39;hk&#39;hxyxyz&quot;, &quot;Wxqv&#39;hv&#39;k&quot;, &quot;Wh&#39;k&quot;, &quot;Xbx&#39;qk&#39;vz&quot;]</span>
</pre></div>
</div>
<section id="multi-word-fantasy-names">
<h3>Multi-Word Fantasy Names<a class="headerlink" href="#multi-word-fantasy-names" title="Permalink to this headline"></a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">fantasy_name</span></code> function will only generate one name-word at a time, so for multi-word names
youll need to combine pieces together. Depending on what kind of end result you want, there are
several approaches.</p>
<section id="the-simple-approach">
<h4>The simple approach<a class="headerlink" href="#the-simple-approach" title="Permalink to this headline"></a></h4>
<p>If all you need is for it to have multiple parts, you can generate multiple names at once and <code class="docutils literal notranslate"><span class="pre">join</span></code> them.</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">name</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">namegen</span><span class="o">.</span><span class="n">fantasy_name</span><span class="p">(</span><span class="n">num</span><span class="o">=</span><span class="mi">2</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">name</span>
<span class="go">&#39;Dezhvözh Khäk&#39;</span>
</pre></div>
</div>
<p>If you want a little more variation between first/last names, you can also generate names for
different styles and then combine them.</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">first</span> <span class="o">=</span> <span class="n">namegen</span><span class="o">.</span><span class="n">fantasy_name</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s2">&quot;fluid&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">last</span> <span class="o">=</span> <span class="n">namegen</span><span class="o">.</span><span class="n">fantasy_name</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s2">&quot;harsh&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">first</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">last</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">name</span>
<span class="go">&#39;Ofasa Käkudhu&#39;</span>
</pre></div>
</div>
</section>
<section id="nakku-silversmith">
<h4>“Nakku Silversmith”<a class="headerlink" href="#nakku-silversmith" title="Permalink to this headline"></a></h4>
<p>One common fantasy name practice is profession- or title-based surnames. To achieve this effect,
you can use the <code class="docutils literal notranslate"><span class="pre">last_name</span></code> function with a custom list of last names and combine it with your generated
fantasy name.</p>
<p>Example:</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="n">NAMEGEN_LAST_NAMES</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;Silversmith&quot;</span><span class="p">,</span> <span class="s2">&quot;the Traveller&quot;</span><span class="p">,</span> <span class="s2">&quot;Destroyer of Worlds&quot;</span> <span class="p">]</span>
<span class="n">NAMEGEN_REPLACE_LISTS</span> <span class="o">=</span> <span class="kc">True</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">first</span> <span class="o">=</span> <span class="n">namegen</span><span class="o">.</span><span class="n">fantasy_name</span><span class="p">()</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">last</span> <span class="o">=</span> <span class="n">namegen</span><span class="o">.</span><span class="n">last_name</span><span class="p">()</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">first</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">last</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">name</span>
<span class="s1">&#39;Tözhkheko the Traveller&#39;</span>
</pre></div>
</div>
</section>
<section id="elarion-dyrinea-thror-obinson">
<h4>Elarion dYrinea, Thror Obinson<a class="headerlink" href="#elarion-dyrinea-thror-obinson" title="Permalink to this headline"></a></h4>
<p>Another common flavor of fantasy names is to use a surname suffix or prefix. For that, youll
need to add in the extra bit yourself.</p>
<p>Examples:</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">names</span> <span class="o">=</span> <span class="n">namegen</span><span class="o">.</span><span class="n">fantasy_name</span><span class="p">(</span><span class="n">num</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">names</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2"> za&#39;</span><span class="si">{</span><span class="n">names</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">name</span>
<span class="go">&quot;Tithe za&#39;Dhudozkok&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">names</span> <span class="o">=</span> <span class="n">namegen</span><span class="o">.</span><span class="n">fantasy_name</span><span class="p">(</span><span class="n">num</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">names</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">names</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">son&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">name</span>
<span class="go">&#39;Kön Ködhöddoson&#39;</span>
</pre></div>
</div>
</section>
</section>
<section id="custom-fantasy-name-style-rules">
<h3>Custom Fantasy Name style rules<a class="headerlink" href="#custom-fantasy-name-style-rules" title="Permalink to this headline"></a></h3>
<p>The style rules are contained in a dictionary of dictionaries, where the style name
is the key and the style rules are the dictionary value.</p>
<p>The following is how you would add a custom style to <code class="docutils literal notranslate"><span class="pre">settings.py</span></code>:</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="n">NAMEGEN_FANTASY_RULES</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;example_style&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">&quot;syllable&quot;</span><span class="p">:</span> <span class="s2">&quot;(C)VC&quot;</span><span class="p">,</span>
<span class="s2">&quot;consonants&quot;</span><span class="p">:</span> <span class="p">[</span> <span class="s1">&#39;z&#39;</span><span class="p">,</span><span class="s1">&#39;z&#39;</span><span class="p">,</span><span class="s1">&#39;ph&#39;</span><span class="p">,</span><span class="s1">&#39;sh&#39;</span><span class="p">,</span><span class="s1">&#39;r&#39;</span><span class="p">,</span><span class="s1">&#39;n&#39;</span> <span class="p">],</span>
<span class="s2">&quot;start&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;m&#39;</span><span class="p">],</span>
<span class="s2">&quot;end&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;x&#39;</span><span class="p">,</span><span class="s1">&#39;n&#39;</span><span class="p">],</span>
<span class="s2">&quot;vowels&quot;</span><span class="p">:</span> <span class="p">[</span> <span class="s2">&quot;e&quot;</span><span class="p">,</span><span class="s2">&quot;e&quot;</span><span class="p">,</span><span class="s2">&quot;e&quot;</span><span class="p">,</span><span class="s2">&quot;a&quot;</span><span class="p">,</span><span class="s2">&quot;i&quot;</span><span class="p">,</span><span class="s2">&quot;i&quot;</span><span class="p">,</span><span class="s2">&quot;u&quot;</span><span class="p">,</span><span class="s2">&quot;o&quot;</span><span class="p">,</span> <span class="p">],</span>
<span class="s2">&quot;length&quot;</span><span class="p">:</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">4</span><span class="p">),</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Then you could generate names following that ruleset with <code class="docutils literal notranslate"><span class="pre">namegen.fantasy_name(style=&quot;example_style&quot;)</span></code>.</p>
<p>The keys <code class="docutils literal notranslate"><span class="pre">syllable</span></code>, <code class="docutils literal notranslate"><span class="pre">consonants</span></code>, <code class="docutils literal notranslate"><span class="pre">vowels</span></code>, and <code class="docutils literal notranslate"><span class="pre">length</span></code> must be present, and <code class="docutils literal notranslate"><span class="pre">length</span></code> must be the minimum and maximum syllable counts. <code class="docutils literal notranslate"><span class="pre">start</span></code> and <code class="docutils literal notranslate"><span class="pre">end</span></code> are optional.</p>
<section id="syllable">
<h4>syllable<a class="headerlink" href="#syllable" title="Permalink to this headline"></a></h4>
<p>The “syllable” field defines the structure of each syllable. C is consonant, V is vowel,
and parentheses mean its optional. So, the example <code class="docutils literal notranslate"><span class="pre">(C)VC</span></code> means that every syllable
will always have a vowel followed by a consonant, and will <em>sometimes</em> have another
consonant at the beginning. e.g. <code class="docutils literal notranslate"><span class="pre">en</span></code>, <code class="docutils literal notranslate"><span class="pre">bak</span></code></p>
<p><em>Note:</em> While its not standard, the contrib lets you nest parentheses, with each layer
being less likely to show up. Additionally, any other characters put into the syllable
structure - e.g. an apostrophe - will be read and inserted as written. The
“alien” style rules in the module gives an example of both: the syllable structure is <code class="docutils literal notranslate"><span class="pre">C(C(V))(')(C)</span></code>
which results in syllables such as <code class="docutils literal notranslate"><span class="pre">khq</span></code>, <code class="docutils literal notranslate"><span class="pre">xho'q</span></code>, and <code class="docutils literal notranslate"><span class="pre">q'</span></code> with a much lower frequency of vowels than
<code class="docutils literal notranslate"><span class="pre">C(C)(V)(')(C)</span></code> would have given.</p>
</section>
<section id="consonants">
<h4>consonants<a class="headerlink" href="#consonants" title="Permalink to this headline"></a></h4>
<p>A simple list of consonant phonemes that can be chosen from. Multi-character strings are
perfectly acceptable, such as “th”, but each one will be treated as a single consonant.</p>
<p>The function uses a naive form of weighting, where you make a phoneme more likely to
occur by putting more copies of it into the list.</p>
</section>
<section id="start-and-end">
<h4>start and end<a class="headerlink" href="#start-and-end" title="Permalink to this headline"></a></h4>
<p>These are <strong>optional</strong> lists for the first and last letters of a syllable, if theyre
a consonant. You can add on additional consonants which can only occur at the beginning
or end of a syllable, or you can add extra copies of already-defined consonants to
increase the frequency of them at the start/end of syllables.</p>
<p>For example, in the <code class="docutils literal notranslate"><span class="pre">example_style</span></code> above, we have a <code class="docutils literal notranslate"><span class="pre">start</span></code> of m, and <code class="docutils literal notranslate"><span class="pre">end</span></code> of x and n.
Taken with the rest of the consonants/vowels, this means you can have the syllables of <code class="docutils literal notranslate"><span class="pre">mez</span></code>
but not <code class="docutils literal notranslate"><span class="pre">zem</span></code>, and you can have <code class="docutils literal notranslate"><span class="pre">phex</span></code> or <code class="docutils literal notranslate"><span class="pre">phen</span></code> but not <code class="docutils literal notranslate"><span class="pre">xeph</span></code> or <code class="docutils literal notranslate"><span class="pre">neph</span></code>.</p>
<p>They can be left out of custom rulesets entirely.</p>
</section>
<section id="vowels">
<h4>vowels<a class="headerlink" href="#vowels" title="Permalink to this headline"></a></h4>
<p>Vowels is a simple list of vowel phonemes - exactly like consonants, but instead used for the
vowel selection. Single-or multi-character strings are equally fine. It uses the same naive weighting system
as consonants - you can increase the frequency of any given vowel by putting it into the list multiple times.</p>
</section>
<section id="length">
<h4>length<a class="headerlink" href="#length" title="Permalink to this headline"></a></h4>
<p>A tuple with the minimum and maximum number of syllables a name can have.</p>
<p>When setting this, keep in mind how long your syllables can get! 4 syllables might
not seem like very many, but if you have a ©(V)VC structure with one- and
two-letter phonemes, you can get up to eight characters per syllable.</p>
<hr class="docutils" />
<p><small>This document page is generated from <code class="docutils literal notranslate"><span class="pre">evennia/contrib/utils/name_generator/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>
</section>
</section>
</section>
</section>
</div>
</div>
</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="Contrib-Random-String-Generator.html" title="Pseudo-random generator and registry"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Git-Integration.html" title="In-game Git Integration"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Random Name Generator</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,212 @@
<!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>
<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="Turn based battle system framework" href="Contrib-Turnbattle.html" />
<link rel="prev" title="Evennia Multidescer" href="Contrib-Multidescer.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="Contrib-Turnbattle.html" title="Turn based battle system framework"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Multidescer.html" title="Evennia Multidescer"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Multidescer.html"
title="previous chapter">Evennia Multidescer</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Turnbattle.html"
title="next chapter">Turn based battle system framework</a></p>
<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="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>
</div>
</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="Contrib-Turnbattle.html" title="Turn based battle system framework"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Multidescer.html" title="Evennia Multidescer"
>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="Contribs-Overview.html" >Contribs</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,399 @@
<!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>
<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="Traits" href="Contrib-Traits.html" />
<link rel="prev" title="Health Bar" href="Contrib-Health-Bar.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="Contrib-Traits.html" title="Traits"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Health-Bar.html" title="Health Bar"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Health-Bar.html"
title="previous chapter">Health Bar</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Traits.html"
title="next chapter">Traits</a></p>
<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="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>
</div>
</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="Contrib-Traits.html" title="Traits"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Health-Bar.html" title="Health Bar"
>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="Contribs-Overview.html" >Contribs</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,199 @@
<!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>
<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="Easy menu selection tree" href="Contrib-Tree-Select.html" />
<link rel="prev" title="Random Name Generator" href="Contrib-Name-Generator.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="Contrib-Tree-Select.html" title="Easy menu selection tree"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Name-Generator.html" title="Random Name Generator"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Name-Generator.html"
title="previous chapter">Random Name Generator</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Tree-Select.html"
title="next chapter">Easy menu selection tree</a></p>
<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="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>
</div>
</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="Contrib-Tree-Select.html" title="Easy menu selection tree"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Name-Generator.html" title="Random Name Generator"
>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="Contribs-Overview.html" >Contribs</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,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>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>
<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="Talkative NPC example" href="Contrib-Talking-Npc.html" />
<link rel="prev" title="TutorialMirror" href="Contrib-Mirror.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="Contrib-Talking-Npc.html" title="Talkative NPC example"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Mirror.html" title="TutorialMirror"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Mirror.html"
title="previous chapter">TutorialMirror</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Talking-Npc.html"
title="next chapter">Talkative NPC example</a></p>
<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="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>
</div>
</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="Contrib-Talking-Npc.html" title="Talkative NPC example"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Mirror.html" title="TutorialMirror"
>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="Contribs-Overview.html" >Contribs</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,186 @@
<!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>
<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="Slow Exit" href="Contrib-Slow-Exit.html" />
<link rel="prev" title="Map Builder" href="Contrib-Mapbuilder.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="Contrib-Slow-Exit.html" title="Slow Exit"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Mapbuilder.html" title="Map Builder"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Mapbuilder.html"
title="previous chapter">Map Builder</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Slow-Exit.html"
title="next chapter">Slow Exit</a></p>
<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="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>
</div>
</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="Contrib-Slow-Exit.html" title="Slow Exit"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Mapbuilder.html" title="Map Builder"
>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="Contribs-Overview.html" >Contribs</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,198 @@
<!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>
<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="Wilderness system" href="Contrib-Wilderness.html" />
<link rel="prev" title="SimpleDoor" href="Contrib-Simpledoor.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="Contrib-Wilderness.html" title="Wilderness system"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Simpledoor.html" title="SimpleDoor"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Simpledoor.html"
title="previous chapter">SimpleDoor</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Wilderness.html"
title="next chapter">Wilderness system</a></p>
<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="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>
</div>
</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="Contrib-Wilderness.html" title="Wilderness system"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Simpledoor.html" title="SimpleDoor"
>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="Contribs-Overview.html" >Contribs</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,160 @@
<!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>
<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 Tutorial World" href="Contrib-Tutorial-World.html" />
<link rel="prev" title="Red Button example" href="Contrib-Red-Button.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="Contrib-Tutorial-World.html" title="Evennia Tutorial World"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Red-Button.html" title="Red Button example"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Red-Button.html"
title="previous chapter">Red Button example</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Tutorial-World.html"
title="next chapter">Evennia Tutorial World</a></p>
<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="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>
</div>
</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="Contrib-Tutorial-World.html" title="Evennia Tutorial World"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Red-Button.html" title="Red Button example"
>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="Contribs-Overview.html" >Contribs</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,570 @@
<!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>
<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="Batch processor examples" href="Contrib-Batchprocessor.html" />
<link rel="prev" title="Roleplaying base system for Evennia" href="Contrib-RPSystem.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="Contrib-Batchprocessor.html" title="Batch processor examples"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-RPSystem.html" title="Roleplaying base system for Evennia"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-RPSystem.html"
title="previous chapter">Roleplaying base system for Evennia</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Batchprocessor.html"
title="next chapter">Batch processor examples</a></p>
<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="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>
</div>
</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="Contrib-Batchprocessor.html" title="Batch processor examples"
>next</a> |</li>
<li class="right" >
<a href="Contrib-RPSystem.html" title="Roleplaying base system for Evennia"
>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="Contribs-Overview.html" >Contribs</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,288 @@
<!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>
<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="How To Contribute And Get Help" href="../Contributing.html" />
<link rel="prev" title="Pseudo-random generator and registry" href="Contrib-Random-String-Generator.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="../Contributing.html" title="How To Contribute And Get Help"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Random-String-Generator.html" title="Pseudo-random generator and registry"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Random-String-Generator.html"
title="previous chapter">Pseudo-random generator and registry</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="../Contributing.html"
title="next chapter">How To Contribute And Get Help</a></p>
<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="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>
</div>
</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="../Contributing.html" title="How To Contribute And Get Help"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Random-String-Generator.html" title="Pseudo-random generator and registry"
>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="Contribs-Overview.html" >Contribs</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,186 @@
<!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>
<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="Extended Room" href="Contrib-Extended-Room.html" />
<link rel="prev" title="Puzzles System" href="Contrib-Puzzles.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="Contrib-Extended-Room.html" title="Extended Room"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Puzzles.html" title="Puzzles System"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Puzzles.html"
title="previous chapter">Puzzles System</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Extended-Room.html"
title="next chapter">Extended Room</a></p>
<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="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>
</div>
</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="Contrib-Extended-Room.html" title="Extended Room"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Puzzles.html" title="Puzzles System"
>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="Contribs-Overview.html" >Contribs</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,238 @@
<!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>
<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="Input/Output Auditing" href="Contrib-Auditing.html" />
<link rel="prev" title="Talkative NPC example" href="Contrib-Talking-Npc.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="Contrib-Auditing.html" title="Input/Output Auditing"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Talking-Npc.html" title="Talkative NPC example"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Talking-Npc.html"
title="previous chapter">Talkative NPC example</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Auditing.html"
title="next chapter">Input/Output Auditing</a></p>
<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="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>
</div>
</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="Contrib-Auditing.html" title="Input/Output Auditing"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Talking-Npc.html" title="Talkative NPC example"
>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="Contribs-Overview.html" >Contribs</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,204 @@
<!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 &#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>
<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="EvscapeRoom" href="Contrib-Evscaperoom.html" />
<link rel="prev" title="Legacy Comms-commands" href="Contrib-Mux-Comms-Cmds.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="Contrib-Evscaperoom.html" title="EvscapeRoom"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Mux-Comms-Cmds.html" title="Legacy Comms-commands"
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="Contribs-Overview.html" accesskey="U">Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Unix-like Command style</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Unix-like Command style</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Mux-Comms-Cmds.html"
title="previous chapter">Legacy Comms-commands</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-Evscaperoom.html"
title="next chapter">EvscapeRoom</a></p>
<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="bodywrapper">
<div class="body" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="unix-like-command-style">
<h1>Unix-like Command style<a class="headerlink" href="#unix-like-command-style" 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>
</div>
</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="Contrib-Evscaperoom.html" title="EvscapeRoom"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Mux-Comms-Cmds.html" title="Legacy Comms-commands"
>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="Contribs-Overview.html" >Contribs</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Unix-like Command style</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,254 @@
<!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>
<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="XYZgrid" href="Contrib-XYZGrid.html" />
<link rel="prev" title="Slow Exit" href="Contrib-Slow-Exit.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="Contrib-XYZGrid.html" title="XYZgrid"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Contrib-Slow-Exit.html" title="Slow Exit"
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="Contribs-Overview.html" accesskey="U">Contribs</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="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>
<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>
<h4>Previous topic</h4>
<p class="topless"><a href="Contrib-Slow-Exit.html"
title="previous chapter">Slow Exit</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-XYZGrid.html"
title="next chapter">XYZgrid</a></p>
<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="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>
</div>
</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="Contrib-XYZGrid.html" title="XYZgrid"
>next</a> |</li>
<li class="right" >
<a href="Contrib-Slow-Exit.html" title="Slow Exit"
>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="Contribs-Overview.html" >Contribs</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>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,762 @@
<!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>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>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="AWSstorage system" href="Contrib-AWSStorage.html" />
<link rel="prev" title="Setting up PyCharm with Evennia" href="../Coding/Setting-up-PyCharm.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="Contrib-AWSStorage.html" title="AWSstorage system"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="../Coding/Setting-up-PyCharm.html" title="Setting up PyCharm with Evennia"
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="">Contribs</a></li>
</ul>
<div class="develop">develop branch</div>
</div>
<div class="document">
<div class="documentwrapper">
<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>
<h3><a href="../index.html">Table of Contents</a></h3>
<ul>
<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-components">Contrib: <code class="docutils literal notranslate"><span class="pre">components</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#the-components-contrib">The Components Contrib</a><ul>
<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>
<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="#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="#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-ingame-map-display">Contrib: <code class="docutils literal notranslate"><span class="pre">ingame_map_display</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="#rpg">rpg</a><ul>
<li><a class="reference internal" href="#contrib-buffs">Contrib: <code class="docutils literal notranslate"><span class="pre">buffs</span></code></a></li>
<li><a class="reference internal" href="#contrib-character-creator">Contrib: <code class="docutils literal notranslate"><span class="pre">character_creator</span></code></a></li>
<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="#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-evadventure">Contrib: <code class="docutils literal notranslate"><span class="pre">evadventure</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="#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-git-integration">Contrib: <code class="docutils literal notranslate"><span class="pre">git_integration</span></code></a></li>
<li><a class="reference internal" href="#contrib-name-generator">Contrib: <code class="docutils literal notranslate"><span class="pre">name_generator</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>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="../Coding/Setting-up-PyCharm.html"
title="previous chapter">Setting up PyCharm with Evennia</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Contrib-AWSStorage.html"
title="next chapter">AWSstorage system</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/Contribs/Contribs-Overview.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="Contribs-Overview.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="bodywrapper">
<div class="body" role="main">
<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>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="Contrib-AWSStorage.html">AWSstorage system</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Building-Menu.html">Building menu</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Color-Markups.html">Additional Color markups</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Components.html">Components</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Components.html#the-components-contrib">The Components Contrib</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Components.html#pros">Pros</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Components.html#cons">Cons</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Components.html#how-to-install">How to install</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Components.html#full-example">Full Example</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Custom-Gametime.html">Custom gameime</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Email-Login.html">Email-based login system</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Ingame-Python.html">Evennia in-game Python system</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Menu-Login.html">Menu-based login system</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Mux-Comms-Cmds.html">Legacy Comms-commands</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Unixcommand.html">Unix-like Command style</a></li>
</ul>
</div>
<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="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="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="contrib-components">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">components</span></code><a class="headerlink" href="#contrib-components" title="Permalink to this headline"></a></h3>
<p><strong>Contrib by ChrisLR 2021</strong></p>
</section>
</section>
</section>
<section class="tex2jax_ignore mathjax_ignore" id="the-components-contrib">
<h1>The Components Contrib<a class="headerlink" href="#the-components-contrib" title="Permalink to this headline"></a></h1>
<p><a class="reference internal" href="Contrib-Components.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.base_systems.components.html#evennia-contrib-base-systems-components"><span class="std std-ref">Browse the Code</span></a></p>
<section id="contrib-custom-gametime">
<h2>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></h2>
<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">
<h2>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></h2>
<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">
<h2>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></h2>
<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">
<h2>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></h2>
<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">
<h2>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></h2>
<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">
<h2>Contrib: <code class="docutils literal notranslate"><span class="pre">unixcommand</span></code><a class="headerlink" href="#contrib-unixcommand" title="Permalink to this headline"></a></h2>
<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 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>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Evscaperoom.html">EvscapeRoom</a></li>
</ul>
</div>
<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>
<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>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Barter.html">Barter system</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Clothing.html">Clothing</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Cooldowns.html">Cooldowns</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Crafting.html">Crafting system</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Gendersub.html">Gendersub</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Mail.html">In-Game Mail system</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Multidescer.html">Evennia Multidescer</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Puzzles.html">Puzzles System</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Turnbattle.html">Turn based battle system framework</a></li>
</ul>
</div>
<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="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="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 to model 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="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="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="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="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="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="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>
<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>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Extended-Room.html">Extended Room</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Ingame-Map-Display.html">Basic Map</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Mapbuilder.html">Map Builder</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Simpledoor.html">SimpleDoor</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Slow-Exit.html">Slow Exit</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Wilderness.html">Wilderness system</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-XYZGrid.html">XYZgrid</a></li>
</ul>
</div>
<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="contrib-ingame-map-display">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">ingame_map_display</span></code><a class="headerlink" href="#contrib-ingame-map-display" title="Permalink to this headline"></a></h3>
<p><em>Contribution - helpme 2022</em></p>
<p>This adds an ascii <code class="docutils literal notranslate"><span class="pre">map</span></code> to a given room which can be viewed with the <code class="docutils literal notranslate"><span class="pre">map</span></code> command.
You can easily alter it to add special characters, room colors etc. The map shown is
dynamically generated on use, and supports all compass directions and up/down. Other
directions are ignored.</p>
<p><a class="reference internal" href="Contrib-Ingame-Map-Display.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.grid.ingame_map_display.html#evennia-contrib-grid-ingame-map-display"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<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="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="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="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="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>
<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>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Buffs.html">Buffs</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Character-Creator.html">Character Creator contrib</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Dice.html">Dice roller</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Health-Bar.html">Health Bar</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-RPSystem.html">Roleplaying base system for Evennia</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Traits.html">Traits</a></li>
</ul>
</div>
<section id="contrib-buffs">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">buffs</span></code><a class="headerlink" href="#contrib-buffs" title="Permalink to this headline"></a></h3>
<p><em>Contribution by Tegiminis 2022</em></p>
<p>A buff is a timed object, attached to a game entity. It is capable of modifying values, triggering code, or both.
It is a common design pattern in RPGs, particularly action games.</p>
<p><a class="reference internal" href="Contrib-Buffs.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.rpg.buffs.html#evennia-contrib-rpg-buffs"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="contrib-character-creator">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">character_creator</span></code><a class="headerlink" href="#contrib-character-creator" title="Permalink to this headline"></a></h3>
<p><em>Commands for managing and initiating an in-game character-creation menu.</em></p>
<p>Contribution by InspectorCaracal, 2022</p>
<p><a class="reference internal" href="Contrib-Character-Creator.html"><span class="doc std std-doc">Read the documentation</span></a> - <span class="xref myst">Browse the Code</span></p>
</section>
<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="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="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="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="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>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Batchprocessor.html">Batch processor examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Bodyfunctions.html">Script example</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Evadventure.html">EvAdventure</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Mirror.html">TutorialMirror</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Red-Button.html">Red Button example</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Talking-Npc.html">Talkative NPC example</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Tutorial-World.html">Evennia Tutorial World</a></li>
</ul>
</div>
<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="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-evadventure">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">evadventure</span></code><a class="headerlink" href="#contrib-evadventure" title="Permalink to this headline"></a></h3>
<p><em>Contrib by Griatch 2022</em></p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>NOTE - this tutorial is WIP and NOT complete! It was put on hold to focus on
releasing Evennia 1.0. You will still learn things from it, but dont expect
perfection.</p>
</div>
<p><a class="reference internal" href="Contrib-Evadventure.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.tutorials.evadventure.html#evennia-contrib-tutorials-evadventure"><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>
<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>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Auditing.html">Input/Output Auditing</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Fieldfill.html">Easy fillable form</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Git-Integration.html">In-game Git Integration</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Name-Generator.html">Random Name Generator</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Random-String-Generator.html">Pseudo-random generator and registry</a></li>
<li class="toctree-l1"><a class="reference internal" href="Contrib-Tree-Select.html">Easy menu selection tree</a></li>
</ul>
</div>
<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="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="contrib-git-integration">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">git_integration</span></code><a class="headerlink" href="#contrib-git-integration" title="Permalink to this headline"></a></h3>
<p><em>Contribution by helpme (2022)</em></p>
<p>A module to integrate a stripped-down version of git within the game, allowing developers to view their git status, change branches, and pull updated code of both their local mygame repo and Evennia core. After a successful pull or checkout, the git command will reload the game: Manual restarts may be required to to apply certain changes that would impact persistent scripts etc.</p>
<p><a class="reference internal" href="Contrib-Git-Integration.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.utils.git_integration.html#evennia-contrib-utils-git-integration"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<section id="contrib-name-generator">
<h3>Contrib: <code class="docutils literal notranslate"><span class="pre">name_generator</span></code><a class="headerlink" href="#contrib-name-generator" title="Permalink to this headline"></a></h3>
<p><em>Contribution by InspectorCaracal (2022)</em></p>
<p>A module for generating random names, both real-world and fantasy. Real-world
names can be generated either as first (personal) names, family (last) names, or
full names (first, optional middles, and last). The name data is from <a class="reference external" href="https://www.behindthename.com/">Behind the Name</a>
and used under the <a class="reference external" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0 license</a>.</p>
<p><a class="reference internal" href="Contrib-Name-Generator.html"><span class="doc std std-doc">Read the documentation</span></a> - <a class="reference internal" href="../api/evennia.contrib.utils.name_generator.html#evennia-contrib-utils-name-generator"><span class="std std-ref">Browse the Code</span></a></p>
</section>
<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="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>
<hr class="docutils" />
<p><small>This document page is auto-generated. Manual changes
will be overwritten.</small></p>
</section>
</section>
</section>
</div>
</div>
</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="Contrib-AWSStorage.html" title="AWSstorage system"
>next</a> |</li>
<li class="right" >
<a href="../Coding/Setting-up-PyCharm.html" title="Setting up PyCharm with Evennia"
>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="">Contribs</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>