evennia/docs/1.0-dev/Components/Accounts.html

217 lines
16 KiB
HTML
Raw Normal View History

2020-06-13 00:36:45 +02:00
<!DOCTYPE html>
2020-10-15 01:31:30 +02:00
<html>
2020-06-15 21:52:33 +02:00
<head>
<meta charset="utf-8" />
2021-05-16 00:06:01 +02:00
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
2020-06-15 21:52:33 +02:00
<title>Accounts &#8212; Evennia 1.0-dev documentation</title>
2020-07-14 00:21:00 +02:00
<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>
2021-10-26 21:41:11 +02:00
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"processClass": "tex2jax_process|mathjax_process|math|output_area"}})</script>
2020-07-14 00:21:00 +02:00
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
2020-06-15 21:52:33 +02:00
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
2020-07-14 00:21:00 +02:00
<a href="../genindex.html" title="General Index"
2020-06-15 21:52:33 +02:00
accesskey="I">index</a></li>
<li class="right" >
2020-07-14 00:21:00 +02:00
<a href="../py-modindex.html" title="Python Module Index"
2020-06-15 21:52:33 +02:00
>modules</a> |</li>
2020-10-15 01:31:30 +02:00
<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="">Accounts</a></li>
2020-06-15 21:52:33 +02:00
</ul>
2021-06-23 18:58:26 +02:00
<div class="develop">develop branch</div>
2020-06-15 21:52:33 +02:00
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
2020-06-13 00:36:45 +02:00
2021-10-26 21:41:11 +02:00
<section class="tex2jax_ignore mathjax_ignore" id="accounts">
2020-06-13 00:36:45 +02:00
<h1>Accounts<a class="headerlink" href="#accounts" title="Permalink to this headline"></a></h1>
2021-10-26 21:41:11 +02:00
<p>All <em>users</em> (real people) that starts a game <a class="reference internal" href="Sessions.html"><span class="doc std std-doc">Session</span></a> on Evennia are doing so through an
2020-06-13 00:36:45 +02:00
object called <em>Account</em>. The Account object has no in-game representation, it represents a unique
2021-10-26 21:41:11 +02:00
game account. In order to actually get on the game the Account must <em>puppet</em> an <a class="reference internal" href="Objects.html"><span class="doc std std-doc">Object</span></a>
(normally a <a class="reference internal" href="Objects.html#characters"><span class="std std-doc">Character</span></a>).</p>
2020-06-13 00:36:45 +02:00
<p>Exactly how many Sessions can interact with an Account and its Puppets at once is determined by
2021-10-26 21:41:11 +02:00
Evennias <a class="reference internal" href="Sessions.html#multisession-mode"><span class="std std-doc">MULTISESSION_MODE</span></a> setting.</p>
2020-06-13 00:36:45 +02:00
<p>Apart from storing login information and other account-specific data, the Account object is what is
2021-10-26 21:41:11 +02:00
chatting on <a class="reference internal" href="Communications.html"><span class="doc std std-doc">Channels</span></a>. It is also a good place to store <a class="reference internal" href="Locks.html"><span class="doc std std-doc">Permissions</span></a> to be
2020-06-13 00:36:45 +02:00
consistent between different in-game characters as well as configuration options. The Account
2021-10-26 21:41:11 +02:00
object also has its own <a class="reference internal" href="Command-Sets.html"><span class="doc std std-doc">CmdSet</span></a>, the <code class="docutils literal notranslate"><span class="pre">AccountCmdSet</span></code>.</p>
2020-06-13 00:36:45 +02:00
<p>Logged into default evennia, you can use the <code class="docutils literal notranslate"><span class="pre">ooc</span></code> command to leave your current
2021-10-26 21:41:11 +02:00
<a class="reference internal" href="Objects.html"><span class="doc std std-doc">character</span></a> and go into OOC mode. You are quite limited in this mode, basically it works
2020-06-13 00:36:45 +02:00
like a simple chat program. It acts as a staging area for switching between Characters (if your
game supports that) or as a safety mode if your Character gets deleted. Use <code class="docutils literal notranslate"><span class="pre">ic</span></code> to attempt to
(re)puppet a Character.</p>
<p>Note that the Account object can have, and often does have, a different set of
2021-10-26 21:41:11 +02:00
<a class="reference internal" href="Permissions.html"><span class="doc std std-doc">Permissions</span></a> from the Character they control. Normally you should put your
2020-06-13 00:36:45 +02:00
permissions on the Account level - this will overrule permissions set on the Character level. For
the permissions of the Character to come into play the default <code class="docutils literal notranslate"><span class="pre">quell</span></code> command can be used. This
allows for exploring the game using a different permission set (but you cant escalate your
permissions this way - for hierarchical permissions like <code class="docutils literal notranslate"><span class="pre">Builder</span></code>, <code class="docutils literal notranslate"><span class="pre">Admin</span></code> etc, the <em>lower</em> of the
permissions on the Character/Account will always be used).</p>
2021-05-16 00:06:01 +02:00
<section id="how-to-create-your-own-account-types">
2020-06-13 00:36:45 +02:00
<h2>How to create your own Account types<a class="headerlink" href="#how-to-create-your-own-account-types" title="Permalink to this headline"></a></h2>
<p>You will usually not want more than one Account typeclass for all new accounts (but you could in
principle create a system that changes an accounts typeclass dynamically).</p>
<p>An Evennia Account is, per definition, a Python class that includes <code class="docutils literal notranslate"><span class="pre">evennia.DefaultAccount</span></code> among
its parents. In <code class="docutils literal notranslate"><span class="pre">mygame/typeclasses/accounts.py</span></code> there is an empty class ready for you to modify.
Evennia defaults to using this (it inherits directly from <code class="docutils literal notranslate"><span class="pre">DefaultAccount</span></code>).</p>
<p>Heres an example of modifying the default Account class in code:</p>
2021-10-26 21:41:11 +02:00
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="c1"># in mygame/typeclasses/accounts.py</span>
2020-06-13 00:36:45 +02:00
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">DefaultAccount</span>
<span class="k">class</span> <span class="nc">Account</span><span class="p">(</span><span class="n">DefaultAccount</span><span class="p">):</span> <span class="c1"># [...]</span>
<span class="n">at_account_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="s2">&quot;this is called only once, when account is first created&quot;</span>
2020-12-20 14:36:24 +01:00
<span class="bp">self</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">real_name</span> <span class="o">=</span> <span class="kc">None</span> <span class="c1"># this is set later self.db.real_address = None # &quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">config_1</span> <span class="o">=</span> <span class="kc">True</span> <span class="c1"># default config self.db.config_2 = False # &quot;</span>
2020-06-13 00:36:45 +02:00
<span class="bp">self</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">config_3</span> <span class="o">=</span> <span class="mi">1</span> <span class="c1"># &quot;</span>
2021-10-26 21:41:11 +02:00
<span class="c1"># ... whatever else our game needs to know ``` Reload the server with `reload`.</span>
2020-06-13 00:36:45 +02:00
</pre></div>
2021-10-26 21:41:11 +02:00
</div>
2020-06-13 00:36:45 +02:00
<p>… However, if you use <code class="docutils literal notranslate"><span class="pre">examine</span> <span class="pre">*self</span></code> (the asterisk makes you examine your Account object rather
than your Character), you wont see your new Attributes yet. This is because <code class="docutils literal notranslate"><span class="pre">at_account_creation</span></code>
is only called the very <em>first</em> time the Account is called and your Account object already exists
(any new Accounts that connect will see them though). To update yourself you need to make sure to
re-fire the hook on all the Accounts you have already created. Here is an example of how to do this
using <code class="docutils literal notranslate"><span class="pre">py</span></code>:</p>
<p><code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">[account.at_account_creation()</span> <span class="pre">for</span> <span class="pre">account</span> <span class="pre">in</span> <span class="pre">evennia.managers.accounts.all()]</span></code></p>
<p>You should now see the Attributes on yourself.</p>
<blockquote>
<div><p>If you wanted Evennia to default to a completely <em>different</em> Account class located elsewhere, you
must point Evennia to it. Add <code class="docutils literal notranslate"><span class="pre">BASE_ACCOUNT_TYPECLASS</span></code> to your settings file, and give the python
path to your custom class as its value. By default this points to <code class="docutils literal notranslate"><span class="pre">typeclasses.accounts.Account</span></code>,
the empty template we used above.</p>
</div></blockquote>
2021-05-16 00:06:01 +02:00
</section>
<section id="properties-on-accounts">
2020-06-13 00:36:45 +02:00
<h2>Properties on Accounts<a class="headerlink" href="#properties-on-accounts" title="Permalink to this headline"></a></h2>
2021-10-26 21:41:11 +02:00
<p>Beyond those properties assigned to all typeclassed objects (see <a class="reference internal" href="Typeclasses.html"><span class="doc std std-doc">Typeclasses</span></a>), the
2020-06-13 00:36:45 +02:00
Account also has the following custom properties:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">user</span></code> - a unique link to a <code class="docutils literal notranslate"><span class="pre">User</span></code> Django object, representing the logged-in user.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">obj</span></code> - an alias for <code class="docutils literal notranslate"><span class="pre">character</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">name</span></code> - an alias for <code class="docutils literal notranslate"><span class="pre">user.username</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">sessions</span></code> - an instance of
<a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia.objects.objects#objectsessionhandler">ObjectSessionHandler</a>
managing all connected Sessions (physical connections) this object listens to (Note: In older
2020-06-16 22:49:43 +02:00
versions of Evennia, this was a list). The so-called <code class="docutils literal notranslate"><span class="pre">session-id</span></code> (used in many places) is found
as
2020-06-13 00:36:45 +02:00
a property <code class="docutils literal notranslate"><span class="pre">sessid</span></code> on each Session instance.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">is_superuser</span></code> (bool: True/False) - if this account is a superuser.</p></li>
</ul>
<p>Special handlers:</p>
<ul class="simple">
2021-10-26 21:41:11 +02:00
<li><p><code class="docutils literal notranslate"><span class="pre">cmdset</span></code> - This holds all the current <a class="reference internal" href="Commands.html"><span class="doc std std-doc">Commands</span></a> of this Account. By default these are
2020-06-13 00:36:45 +02:00
the commands found in the cmdset defined by <code class="docutils literal notranslate"><span class="pre">settings.CMDSET_ACCOUNT</span></code>.</p></li>
2021-10-26 21:41:11 +02:00
<li><p><code class="docutils literal notranslate"><span class="pre">nicks</span></code> - This stores and handles <a class="reference internal" href="Nicks.html"><span class="doc std std-doc">Nicks</span></a>, in the same way as nicks it works on Objects.
2020-06-16 22:49:43 +02:00
For Accounts, nicks are primarily used to store custom aliases for
2021-10-26 21:41:11 +02:00
<a class="reference internal" href="Channels.html"><span class="doc std std-doc">Channels</span></a>.</p></li>
2020-06-13 00:36:45 +02:00
</ul>
<p>Selection of special methods (see <code class="docutils literal notranslate"><span class="pre">evennia.DefaultAccount</span></code> for details):</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">get_puppet</span></code> - get a currently puppeted object connected to the Account and a given session id, if
any.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">puppet_object</span></code> - connect a session to a puppetable Object.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">unpuppet_object</span></code> - disconnect a session from a puppetable Object.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">msg</span></code> - send text to the Account</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">execute_cmd</span></code> - runs a command as if this Account did it.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">search</span></code> - search for Accounts.</p></li>
</ul>
2021-05-16 00:06:01 +02:00
</section>
</section>
2020-06-13 00:36:45 +02:00
2020-10-15 01:31:30 +02:00
<div class="clearer"></div>
2020-06-13 00:36:45 +02:00
</div>
</div>
</div>
2020-06-15 21:52:33 +02:00
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
2020-07-14 00:21:00 +02:00
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
2020-06-15 21:52:33 +02:00
</a></p>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
2020-07-14 00:21:00 +02:00
<form class="search" action="../search.html" method="get">
2020-06-15 21:52:33 +02:00
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
2020-07-14 00:21:00 +02:00
<p><h3><a href="../index.html">Table of Contents</a></h3>
2020-06-15 21:52:33 +02:00
<ul>
<li><a class="reference internal" href="#">Accounts</a><ul>
<li><a class="reference internal" href="#how-to-create-your-own-account-types">How to create your own Account types</a></li>
<li><a class="reference internal" href="#properties-on-accounts">Properties on Accounts</a></li>
</ul>
</li>
</ul>
2020-06-13 00:36:45 +02:00
2020-06-15 21:52:33 +02:00
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
2020-07-14 00:21:00 +02:00
<li><a href="../_sources/Components/Accounts.md.txt"
2020-06-15 21:52:33 +02:00
rel="nofollow">Show Page Source</a></li>
</ul>
2021-03-06 01:37:43 +01:00
</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>
2021-08-06 00:47:51 +02:00
<li>
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
2021-08-06 00:53:44 +02:00
<a href="https://evennia.blogspot.com/">Blog</a>
2021-03-06 01:37:43 +01:00
</li>
</ul>
2020-06-15 21:52:33 +02:00
<h3>Versions</h3>
<ul>
<li><a href="Accounts.html">1.0-dev (develop branch)</a></li>
2021-10-26 21:41:11 +02:00
<li><a href="../../0.95/index.html">0.95 (v0.9.5 branch)</a></li>
2020-06-15 21:52:33 +02:00
</ul>
2020-06-14 21:48:02 +02:00
2020-06-15 21:52:33 +02:00
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
2020-07-14 00:21:00 +02:00
<a href="../genindex.html" title="General Index"
2020-06-15 21:52:33 +02:00
>index</a></li>
<li class="right" >
2020-07-14 00:21:00 +02:00
<a href="../py-modindex.html" title="Python Module Index"
2020-06-15 21:52:33 +02:00
>modules</a> |</li>
2020-10-15 01:31:30 +02:00
<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="">Accounts</a></li>
2020-06-15 21:52:33 +02:00
</ul>
2021-06-23 18:58:26 +02:00
<div class="develop">develop branch</div>
2020-06-15 21:52:33 +02:00
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2020, The Evennia developer community.
2020-10-15 01:31:30 +02:00
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
2020-06-15 21:52:33 +02:00
</div>
</body>
2020-06-13 00:36:45 +02:00
</html>