mirror of
https://github.com/evennia/evennia.git
synced 2026-03-17 05:16:31 +01:00
281 lines
18 KiB
HTML
281 lines
18 KiB
HTML
|
|
<!DOCTYPE html>
|
|||
|
|
|
|||
|
|
<html lang="en" data-content_root="../">
|
|||
|
|
<head>
|
|||
|
|
<meta charset="utf-8" />
|
|||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
|
|||
|
|
|
|||
|
|
<title>Nicks — Evennia latest documentation</title>
|
|||
|
|
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=d75fae25" />
|
|||
|
|
<link rel="stylesheet" type="text/css" href="../_static/nature.css?v=279e0f84" />
|
|||
|
|
<link rel="stylesheet" type="text/css" href="../_static/custom.css?v=e4a91a55" />
|
|||
|
|
<script src="../_static/documentation_options.js?v=c6e86fd7"></script>
|
|||
|
|
<script src="../_static/doctools.js?v=9bcbadda"></script>
|
|||
|
|
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
|
|||
|
|
<link rel="icon" href="../_static/favicon.ico"/>
|
|||
|
|
<link rel="index" title="Index" href="../genindex.html" />
|
|||
|
|
<link rel="search" title="Search" href="../search.html" />
|
|||
|
|
<link rel="next" title="Tags" href="Tags.html" />
|
|||
|
|
<link rel="prev" title="Attributes" href="Attributes.html" />
|
|||
|
|
</head><body>
|
|||
|
|
<div class="related" role="navigation" aria-label="Related">
|
|||
|
|
<h3>Navigation</h3>
|
|||
|
|
<ul>
|
|||
|
|
<li class="right" style="margin-right: 10px">
|
|||
|
|
<a href="../genindex.html" title="General Index"
|
|||
|
|
accesskey="I">index</a></li>
|
|||
|
|
<li class="right" >
|
|||
|
|
<a href="../py-modindex.html" title="Python Module Index"
|
|||
|
|
>modules</a> |</li>
|
|||
|
|
<li class="right" >
|
|||
|
|
<a href="Tags.html" title="Tags"
|
|||
|
|
accesskey="N">next</a> |</li>
|
|||
|
|
<li class="right" >
|
|||
|
|
<a href="Attributes.html" title="Attributes"
|
|||
|
|
accesskey="P">previous</a> |</li>
|
|||
|
|
<li class="nav-item nav-item-0"><a href="../index.html">Evennia</a> »</li>
|
|||
|
|
<li class="nav-item nav-item-1"><a href="Components-Overview.html" accesskey="U">Core Components</a> »</li>
|
|||
|
|
<li class="nav-item nav-item-this"><a href="">Nicks</a></li>
|
|||
|
|
</ul>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="document">
|
|||
|
|
<div class="documentwrapper">
|
|||
|
|
<div class="bodywrapper">
|
|||
|
|
<div class="body" role="main">
|
|||
|
|
|
|||
|
|
<section class="tex2jax_ignore mathjax_ignore" id="nicks">
|
|||
|
|
<h1>Nicks<a class="headerlink" href="#nicks" title="Link to this heading">¶</a></h1>
|
|||
|
|
<p><em>Nicks</em>, short for <em>Nicknames</em> is a system allowing an object (usually a <a class="reference internal" href="Accounts.html"><span class="std std-doc">Account</span></a>) to
|
|||
|
|
assign custom replacement names for other game entities.</p>
|
|||
|
|
<p>Nicks are not to be confused with <em>Aliases</em>. Setting an Alias on a game entity actually changes an
|
|||
|
|
inherent attribute on that entity, and everyone in the game will be able to use that alias to
|
|||
|
|
address the entity thereafter. A <em>Nick</em> on the other hand, is used to map a different way <em>you
|
|||
|
|
alone</em> can refer to that entity. Nicks are also commonly used to replace your input text which means
|
|||
|
|
you can create your own aliases to default commands.</p>
|
|||
|
|
<p>Default Evennia use Nicks in three flavours that determine when Evennia actually tries to do the
|
|||
|
|
substitution.</p>
|
|||
|
|
<ul class="simple">
|
|||
|
|
<li><p>inputline - replacement is attempted whenever you write anything on the command line. This is the
|
|||
|
|
default.</p></li>
|
|||
|
|
<li><p>objects - replacement is only attempted when referring to an object</p></li>
|
|||
|
|
<li><p>accounts - replacement is only attempted when referring an account</p></li>
|
|||
|
|
</ul>
|
|||
|
|
<p>Here’s how to use it in the default command set (using the <code class="docutils literal notranslate"><span class="pre">nick</span></code> command):</p>
|
|||
|
|
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> nick ls = look
|
|||
|
|
</pre></div>
|
|||
|
|
</div>
|
|||
|
|
<p>This is a good one for unix/linux users who are accustomed to using the <code class="docutils literal notranslate"><span class="pre">ls</span></code> command in their daily
|
|||
|
|
life. It is equivalent to <code class="docutils literal notranslate"><span class="pre">nick/inputline</span> <span class="pre">ls</span> <span class="pre">=</span> <span class="pre">look</span></code>.</p>
|
|||
|
|
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> nick/object mycar2 = The red sports car
|
|||
|
|
</pre></div>
|
|||
|
|
</div>
|
|||
|
|
<p>With this example, substitutions will only be done specifically for commands expecting an object
|
|||
|
|
reference, such as</p>
|
|||
|
|
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> look mycar2
|
|||
|
|
</pre></div>
|
|||
|
|
</div>
|
|||
|
|
<p>becomes equivalent to “<code class="docutils literal notranslate"><span class="pre">look</span> <span class="pre">The</span> <span class="pre">red</span> <span class="pre">sports</span> <span class="pre">car</span></code>”.</p>
|
|||
|
|
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> nick/accounts tom = Thomas Johnsson
|
|||
|
|
</pre></div>
|
|||
|
|
</div>
|
|||
|
|
<p>This is useful for commands searching for accounts explicitly:</p>
|
|||
|
|
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> @find *tom
|
|||
|
|
</pre></div>
|
|||
|
|
</div>
|
|||
|
|
<p>One can use nicks to speed up input. Below we add ourselves a quicker way to build red buttons. In
|
|||
|
|
the future just writing <em>rb</em> will be enough to execute that whole long string.</p>
|
|||
|
|
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> nick rb = @create button:examples.red_button.RedButton
|
|||
|
|
</pre></div>
|
|||
|
|
</div>
|
|||
|
|
<p>Nicks could also be used as the start for building a “recog” system suitable for an RP mud.</p>
|
|||
|
|
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> nick/account Arnold = The mysterious hooded man
|
|||
|
|
</pre></div>
|
|||
|
|
</div>
|
|||
|
|
<p>The nick replacer also supports unix-style <em>templating</em>:</p>
|
|||
|
|
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> nick build $1 $2 = @create/drop $1;$2
|
|||
|
|
</pre></div>
|
|||
|
|
</div>
|
|||
|
|
<p>This will catch space separated arguments and store them in the the tags <code class="docutils literal notranslate"><span class="pre">$1</span></code> and <code class="docutils literal notranslate"><span class="pre">$2</span></code>, to be
|
|||
|
|
inserted in the replacement string. This example allows you to do <code class="docutils literal notranslate"><span class="pre">build</span> <span class="pre">box</span> <span class="pre">crate</span></code> and have Evennia
|
|||
|
|
see <code class="docutils literal notranslate"><span class="pre">@create/drop</span> <span class="pre">box;crate</span></code>. You may use any <code class="docutils literal notranslate"><span class="pre">$</span></code> numbers between 1 and 99, but the markers must
|
|||
|
|
match between the nick pattern and the replacement.</p>
|
|||
|
|
<blockquote>
|
|||
|
|
<div><p>If you want to catch “the rest” of a command argument, make sure to put a <code class="docutils literal notranslate"><span class="pre">$</span></code> tag <em>with no spaces
|
|||
|
|
to the right of it</em> - it will then receive everything up until the end of the line.</p>
|
|||
|
|
</div></blockquote>
|
|||
|
|
<p>You can also use <a class="reference external" href="http://www.linfo.org/wildcard.html">shell-type wildcards</a>:</p>
|
|||
|
|
<ul class="simple">
|
|||
|
|
<li><p>* - matches everything.</p></li>
|
|||
|
|
<li><p>? - matches a single character.</p></li>
|
|||
|
|
<li><p>[seq] - matches everything in the sequence, e.g. [xyz] will match both x, y and z</p></li>
|
|||
|
|
<li><p>[!seq] - matches everything <em>not</em> in the sequence. e.g. [!xyz] will match all but x,y z.</p></li>
|
|||
|
|
</ul>
|
|||
|
|
<section id="coding-with-nicks">
|
|||
|
|
<h2>Coding with nicks<a class="headerlink" href="#coding-with-nicks" title="Link to this heading">¶</a></h2>
|
|||
|
|
<p>Nicks are stored as the <code class="docutils literal notranslate"><span class="pre">Nick</span></code> database model and are referred from the normal Evennia
|
|||
|
|
<a class="reference internal" href="Objects.html"><span class="std std-doc">object</span></a> through the <code class="docutils literal notranslate"><span class="pre">nicks</span></code> property - this is known as the <em>NickHandler</em>. The NickHandler
|
|||
|
|
offers effective error checking, searches and conversion.</p>
|
|||
|
|
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="c1"># A command/channel nick:</span>
|
|||
|
|
<span class="n">obj</span><span class="o">.</span><span class="n">nicks</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"greetjack"</span><span class="p">,</span> <span class="s2">"tell Jack = Hello pal!"</span><span class="p">)</span>
|
|||
|
|
|
|||
|
|
<span class="c1"># An object nick: </span>
|
|||
|
|
<span class="n">obj</span><span class="o">.</span><span class="n">nicks</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"rose"</span><span class="p">,</span> <span class="s2">"The red flower"</span><span class="p">,</span> <span class="n">nick_type</span><span class="o">=</span><span class="s2">"object"</span><span class="p">)</span>
|
|||
|
|
|
|||
|
|
<span class="c1"># An account nick:</span>
|
|||
|
|
<span class="n">obj</span><span class="o">.</span><span class="n">nicks</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"tom"</span><span class="p">,</span> <span class="s2">"Tommy Hill"</span><span class="p">,</span> <span class="n">nick_type</span><span class="o">=</span><span class="s2">"account"</span><span class="p">)</span>
|
|||
|
|
|
|||
|
|
<span class="c1"># My own custom nick type (handled by my own game code somehow):</span>
|
|||
|
|
<span class="n">obj</span><span class="o">.</span><span class="n">nicks</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"hood"</span><span class="p">,</span> <span class="s2">"The hooded man"</span><span class="p">,</span> <span class="n">nick_type</span><span class="o">=</span><span class="s2">"my_identsystem"</span><span class="p">)</span>
|
|||
|
|
|
|||
|
|
<span class="c1"># get back the translated nick:</span>
|
|||
|
|
<span class="n">full_name</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">nicks</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rose"</span><span class="p">,</span> <span class="n">nick_type</span><span class="o">=</span><span class="s2">"object"</span><span class="p">)</span>
|
|||
|
|
|
|||
|
|
<span class="c1"># delete a previous set nick</span>
|
|||
|
|
<span class="nb">object</span><span class="o">.</span><span class="n">nicks</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="s2">"rose"</span><span class="p">,</span> <span class="n">nick_type</span><span class="o">=</span><span class="s2">"object"</span><span class="p">)</span>
|
|||
|
|
</pre></div>
|
|||
|
|
</div>
|
|||
|
|
<p>In a command definition you can reach the nick handler through <code class="docutils literal notranslate"><span class="pre">self.caller.nicks</span></code>. See the <code class="docutils literal notranslate"><span class="pre">nick</span></code>
|
|||
|
|
command in <code class="docutils literal notranslate"><span class="pre">evennia/commands/default/general.py</span></code> for more examples.</p>
|
|||
|
|
<p>As a last note, The Evennia <a class="reference internal" href="Channels.html"><span class="std std-doc">channel</span></a> alias systems are using nicks with the
|
|||
|
|
<code class="docutils literal notranslate"><span class="pre">nick_type="channel"</span></code> in order to allow users to create their own custom aliases to channels.</p>
|
|||
|
|
</section>
|
|||
|
|
<section id="advanced-note">
|
|||
|
|
<h2>Advanced note<a class="headerlink" href="#advanced-note" title="Link to this heading">¶</a></h2>
|
|||
|
|
<p>Internally, nicks are <a class="reference internal" href="Attributes.html"><span class="std std-doc">Attributes</span></a> saved with the <code class="docutils literal notranslate"><span class="pre">db_attrype</span></code> set to “nick” (normal
|
|||
|
|
Attributes has this set to <code class="docutils literal notranslate"><span class="pre">None</span></code>).</p>
|
|||
|
|
<p>The nick stores the replacement data in the Attribute.db_value field as a tuple with four fields
|
|||
|
|
<code class="docutils literal notranslate"><span class="pre">(regex_nick,</span> <span class="pre">template_string,</span> <span class="pre">raw_nick,</span> <span class="pre">raw_template)</span></code>. Here <code class="docutils literal notranslate"><span class="pre">regex_nick</span></code> is the converted regex
|
|||
|
|
representation of the <code class="docutils literal notranslate"><span class="pre">raw_nick</span></code> and the <code class="docutils literal notranslate"><span class="pre">template-string</span></code> is a version of the <code class="docutils literal notranslate"><span class="pre">raw_template</span></code>
|
|||
|
|
prepared for efficient replacement of any <code class="docutils literal notranslate"><span class="pre">$</span></code>- type markers. The <code class="docutils literal notranslate"><span class="pre">raw_nick</span></code> and <code class="docutils literal notranslate"><span class="pre">raw_template</span></code> are
|
|||
|
|
basically the unchanged strings you enter to the <code class="docutils literal notranslate"><span class="pre">nick</span></code> command (with unparsed <code class="docutils literal notranslate"><span class="pre">$</span></code> etc).</p>
|
|||
|
|
<p>If you need to access the tuple for some reason, here’s how:</p>
|
|||
|
|
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nb">tuple</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">nicks</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nickname"</span><span class="p">,</span> <span class="n">return_tuple</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
|||
|
|
<span class="c1"># or, alternatively</span>
|
|||
|
|
<span class="nb">tuple</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">nicks</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nickname"</span><span class="p">,</span> <span class="n">return_obj</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">value</span>
|
|||
|
|
</pre></div>
|
|||
|
|
</div>
|
|||
|
|
</section>
|
|||
|
|
</section>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<div class="clearer"></div>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="sphinxsidebar" role="navigation" aria-label="Main">
|
|||
|
|
<div class="sphinxsidebarwrapper">
|
|||
|
|
<p class="logo"><a href="../index.html">
|
|||
|
|
<img class="logo" src="../_static/evennia_logo.png" alt="Logo of Evennia"/>
|
|||
|
|
</a></p>
|
|||
|
|
<search id="searchbox" style="display: none" role="search">
|
|||
|
|
<h3 id="searchlabel">Quick search</h3>
|
|||
|
|
<div class="searchformwrapper">
|
|||
|
|
<form class="search" action="../search.html" method="get">
|
|||
|
|
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
|||
|
|
<input type="submit" value="Go" />
|
|||
|
|
</form>
|
|||
|
|
</div>
|
|||
|
|
</search>
|
|||
|
|
<script>document.getElementById('searchbox').style.display = "block"</script>
|
|||
|
|
<h3><a href="../index.html">Table of Contents</a></h3>
|
|||
|
|
<ul>
|
|||
|
|
<li><a class="reference internal" href="#">Nicks</a><ul>
|
|||
|
|
<li><a class="reference internal" href="#coding-with-nicks">Coding with nicks</a></li>
|
|||
|
|
<li><a class="reference internal" href="#advanced-note">Advanced note</a></li>
|
|||
|
|
</ul>
|
|||
|
|
</li>
|
|||
|
|
</ul>
|
|||
|
|
|
|||
|
|
<div>
|
|||
|
|
<h4>Previous topic</h4>
|
|||
|
|
<p class="topless"><a href="Attributes.html"
|
|||
|
|
title="previous chapter">Attributes</a></p>
|
|||
|
|
</div>
|
|||
|
|
<div>
|
|||
|
|
<h4>Next topic</h4>
|
|||
|
|
<p class="topless"><a href="Tags.html"
|
|||
|
|
title="next chapter">Tags</a></p>
|
|||
|
|
</div>
|
|||
|
|
<div role="note" aria-label="source link">
|
|||
|
|
<!--h3>This Page</h3-->
|
|||
|
|
<ul class="this-page-menu">
|
|||
|
|
<li><a href="../_sources/Components/Nicks.md.txt"
|
|||
|
|
rel="nofollow">Show Page Source</a></li>
|
|||
|
|
</ul>
|
|||
|
|
</div><h3>Links</h3>
|
|||
|
|
<ul>
|
|||
|
|
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
|
|||
|
|
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
|
|||
|
|
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
|
|||
|
|
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
|||
|
|
<li>
|
|||
|
|
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
|||
|
|
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
|||
|
|
<a href="https://evennia.blogspot.com/">Blog</a>
|
|||
|
|
</li>
|
|||
|
|
</ul>
|
|||
|
|
<h3>Doc Versions</h3>
|
|||
|
|
<ul>
|
|||
|
|
|
|||
|
|
<li>
|
|||
|
|
<a href="https://www.evennia.com/docs/latest/index.html">latest (main branch)</a>
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
|
|||
|
|
<li>
|
|||
|
|
<a href="https://www.evennia.com/docs/5.x/index.html">v5.0.0 branch (outdated)</a>
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
<li>
|
|||
|
|
<a href="https://www.evennia.com/docs/4.x/index.html">v4.0.0 branch (outdated)</a>
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
<li>
|
|||
|
|
<a href="https://www.evennia.com/docs/3.x/index.html">v3.0.0 branch (outdated)</a>
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
<li>
|
|||
|
|
<a href="https://www.evennia.com/docs/2.x/index.html">v2.0.0 branch (outdated)</a>
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
<li>
|
|||
|
|
<a href="https://www.evennia.com/docs/1.x/index.html">v1.0.0 branch (outdated)</a>
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
<li>
|
|||
|
|
<a href="https://www.evennia.com/docs/0.x/index.html">v0.9.5 branch (outdated)</a>
|
|||
|
|
</li>
|
|||
|
|
|
|||
|
|
</ul>
|
|||
|
|
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="clearer"></div>
|
|||
|
|
</div>
|
|||
|
|
<div class="related" role="navigation" aria-label="Related">
|
|||
|
|
<h3>Navigation</h3>
|
|||
|
|
<ul>
|
|||
|
|
<li class="right" style="margin-right: 10px">
|
|||
|
|
<a href="../genindex.html" title="General Index"
|
|||
|
|
>index</a></li>
|
|||
|
|
<li class="right" >
|
|||
|
|
<a href="../py-modindex.html" title="Python Module Index"
|
|||
|
|
>modules</a> |</li>
|
|||
|
|
<li class="right" >
|
|||
|
|
<a href="Tags.html" title="Tags"
|
|||
|
|
>next</a> |</li>
|
|||
|
|
<li class="right" >
|
|||
|
|
<a href="Attributes.html" title="Attributes"
|
|||
|
|
>previous</a> |</li>
|
|||
|
|
<li class="nav-item nav-item-0"><a href="../index.html">Evennia</a> »</li>
|
|||
|
|
<li class="nav-item nav-item-1"><a href="Components-Overview.html" >Core Components</a> »</li>
|
|||
|
|
<li class="nav-item nav-item-this"><a href="">Nicks</a></li>
|
|||
|
|
</ul>
|
|||
|
|
</div>
|
|||
|
|
<div class="footer" role="contentinfo">
|
|||
|
|
© Copyright 2024, The Evennia developer community.
|
|||
|
|
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
|
|||
|
|
</div>
|
|||
|
|
</body>
|
|||
|
|
</html>
|