mirror of
https://github.com/evennia/evennia.git
synced 2026-03-18 05:46:31 +01:00
615 lines
No EOL
42 KiB
HTML
615 lines
No EOL
42 KiB
HTML
|
||
<!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.commands.command — Evennia latest 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.commands.default" href="evennia.commands.default.html" />
|
||
<link rel="prev" title="evennia.commands.cmdsethandler" href="evennia.commands.cmdsethandler.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="evennia.commands.default.html" title="evennia.commands.default"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.commands.cmdsethandler.html" title="evennia.commands.cmdsethandler"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia latest</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.commands.html" accesskey="U">evennia.commands</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.commands.command</a></li>
|
||
</ul>
|
||
</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="evennia.commands.cmdsethandler.html"
|
||
title="previous chapter">evennia.commands.cmdsethandler</a></p>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="evennia.commands.default.html"
|
||
title="next chapter">evennia.commands.default</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/api/evennia.commands.command.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="evennia.commands.command.html">latest (main branch)</a></li>
|
||
|
||
<li><a href="../../3.x/index.html">v3.0.0 branch (outdated)</a></li>
|
||
|
||
<li><a href="../../2.x/index.html">v2.0.0 branch (outdated)</a></li>
|
||
|
||
<li><a href="../../1.x/index.html">v1.0.0 branch (outdated)</a></li>
|
||
|
||
<li><a href="../../0.x/index.html">v0.9.5 branch (outdated)</a></li>
|
||
|
||
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="module-evennia.commands.command">
|
||
<span id="evennia-commands-command"></span><h1>evennia.commands.command<a class="headerlink" href="#module-evennia.commands.command" title="Permalink to this headline">¶</a></h1>
|
||
<p>The base Command class.</p>
|
||
<p>All commands in Evennia inherit from the ‘Command’ class in this module.</p>
|
||
<dl class="py exception">
|
||
<dt id="evennia.commands.command.InterruptCommand">
|
||
<em class="property">exception </em><code class="sig-prename descclassname">evennia.commands.command.</code><code class="sig-name descname">InterruptCommand</code><a class="reference internal" href="../_modules/evennia/commands/command.html#InterruptCommand"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.InterruptCommand" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">Exception</span></code></p>
|
||
<p>Cleanly interrupt a command.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="evennia.commands.command.CommandMeta">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.commands.command.</code><code class="sig-name descname">CommandMeta</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#CommandMeta"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.CommandMeta" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">type</span></code></p>
|
||
<p>The metaclass cleans up all properties on the class</p>
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.CommandMeta.__init__">
|
||
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#CommandMeta.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.CommandMeta.__init__" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="evennia.commands.command.Command">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.commands.command.</code><code class="sig-name descname">Command</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
||
<p>(you may see this if a child command had no help text defined)</p>
|
||
<dl class="simple">
|
||
<dt>Usage:</dt><dd><p>command [args]</p>
|
||
</dd>
|
||
</dl>
|
||
<p>This is the base command class. Inherit from this
|
||
to create new commands.</p>
|
||
<p>The cmdhandler makes the following variables available to the
|
||
command methods (so you can always assume them to be there):</p>
|
||
<p>self.caller - the game object calling the command
|
||
self.cmdstring - the command name used to trigger this command (allows</p>
|
||
<blockquote>
|
||
<div><p>you to know which alias was used, for example)</p>
|
||
</div></blockquote>
|
||
<dl class="simple">
|
||
<dt>self.args - everything supplied to the command following the cmdstring</dt><dd><p>(this is usually what is parsed in self.parse())</p>
|
||
</dd>
|
||
<dt>self.cmdset - the merged cmdset from which this command was matched (useful only</dt><dd><p>seldomly, notably for help-type commands, to create dynamic
|
||
help entries and lists)</p>
|
||
</dd>
|
||
</dl>
|
||
<p>self.cmdset_source - the specific cmdset this command was matched from.
|
||
self.obj - the object on which this command is defined. If a default command,</p>
|
||
<blockquote>
|
||
<div><p>this is usually the same as caller.</p>
|
||
</div></blockquote>
|
||
<dl class="simple">
|
||
<dt>self.raw_string - the full raw string input, including the command name,</dt><dd><p>any args and no parsing.</p>
|
||
</dd>
|
||
</dl>
|
||
<p>The following class properties can/should be defined on your child class:</p>
|
||
<p>key - identifier for command (e.g. “look”)
|
||
aliases - (optional) list of aliases (e.g. [“l”, “loo”])
|
||
locks - lock string (default is “cmd:all()”)
|
||
help_category - how to organize this help entry in help system</p>
|
||
<blockquote>
|
||
<div><p>(default is “General”)</p>
|
||
</div></blockquote>
|
||
<p>auto_help - defaults to True. Allows for turning off auto-help generation
|
||
arg_regex - (optional) raw string regex defining how the argument part of</p>
|
||
<blockquote>
|
||
<div><p>the command should look in order to match for this command
|
||
(e.g. must it be a space between cmdname and arg?)</p>
|
||
</div></blockquote>
|
||
<dl class="simple">
|
||
<dt>auto_help_display_key - (optional) if given, this replaces the string shown</dt><dd><p>in the auto-help listing. This is particularly useful for system-commands
|
||
whose actual key is not really meaningful.</p>
|
||
</dd>
|
||
</dl>
|
||
<p>(Note that if auto_help is on, this initial string is also used by the
|
||
system to create the help entry for the command, so it’s a good idea to
|
||
format it similar to this one). This behavior can be changed by
|
||
overriding the method ‘get_help’ of a command: by default, this
|
||
method returns cmd.__doc__ (that is, this very docstring, or
|
||
the docstring of your command). You can, however, extend or
|
||
replace this without disabling auto_help.</p>
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.key">
|
||
<code class="sig-name descname">key</code><em class="property"> = 'command'</em><a class="headerlink" href="#evennia.commands.command.Command.key" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.aliases">
|
||
<code class="sig-name descname">aliases</code><em class="property"> = []</em><a class="headerlink" href="#evennia.commands.command.Command.aliases" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.locks">
|
||
<code class="sig-name descname">locks</code><em class="property"> = 'cmd:all();'</em><a class="headerlink" href="#evennia.commands.command.Command.locks" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.help_category">
|
||
<code class="sig-name descname">help_category</code><em class="property"> = 'general'</em><a class="headerlink" href="#evennia.commands.command.Command.help_category" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.auto_help">
|
||
<code class="sig-name descname">auto_help</code><em class="property"> = True</em><a class="headerlink" href="#evennia.commands.command.Command.auto_help" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.is_exit">
|
||
<code class="sig-name descname">is_exit</code><em class="property"> = False</em><a class="headerlink" href="#evennia.commands.command.Command.is_exit" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.arg_regex">
|
||
<code class="sig-name descname">arg_regex</code><em class="property"> = re.compile('^[ /]|\\n|$', re.IGNORECASE)</em><a class="headerlink" href="#evennia.commands.command.Command.arg_regex" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.msg_all_sessions">
|
||
<code class="sig-name descname">msg_all_sessions</code><em class="property"> = False</em><a class="headerlink" href="#evennia.commands.command.Command.msg_all_sessions" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.retain_instance">
|
||
<code class="sig-name descname">retain_instance</code><em class="property"> = False</em><a class="headerlink" href="#evennia.commands.command.Command.retain_instance" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.__init__">
|
||
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.__init__" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>The lockhandler works the same as for objects.
|
||
optional kwargs will be set as properties on the Command at runtime,
|
||
overloading evential same-named class properties.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.lockhandler">
|
||
<code class="sig-name descname">lockhandler</code><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.lockhandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.lockhandler" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.set_key">
|
||
<code class="sig-name descname">set_key</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">new_key</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.set_key"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.set_key" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Update key.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>new_key</strong> (<em>str</em>) – The new key.</p>
|
||
</dd>
|
||
</dl>
|
||
<p class="rubric">Notes</p>
|
||
<p>This is necessary to use to make sure the optimization
|
||
caches are properly updated as well.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.set_aliases">
|
||
<code class="sig-name descname">set_aliases</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">new_aliases</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.set_aliases"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.set_aliases" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Replace aliases with new ones.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>new_aliases</strong> (<em>str</em><em> or </em><em>list</em>) – Either a ;-separated string
|
||
or a list of aliases. These aliases will replace the
|
||
existing ones, if any.</p>
|
||
</dd>
|
||
</dl>
|
||
<p class="rubric">Notes</p>
|
||
<p>This is necessary to use to make sure the optimization
|
||
caches are properly updated as well.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.match">
|
||
<code class="sig-name descname">match</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">cmdname</span></em>, <em class="sig-param"><span class="n">include_prefixes</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.match"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.match" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>This is called by the system when searching the available commands,
|
||
in order to determine if this is the one we wanted. cmdname was
|
||
previously extracted from the raw string by the system.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>cmdname</strong> (<em>str</em>) – Always lowercase when reaching this point.</p>
|
||
</dd>
|
||
</dl>
|
||
<dl class="simple">
|
||
<dt>Kwargs:</dt><dd><dl class="simple">
|
||
<dt>include_prefixes (bool): If false, will compare against the _noprefix</dt><dd><p>variants of commandnames.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd>
|
||
</dl>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p><em>result (bool)</em> – Match result.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.access">
|
||
<code class="sig-name descname">access</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">srcobj</span></em>, <em class="sig-param"><span class="n">access_type</span><span class="o">=</span><span class="default_value">'cmd'</span></em>, <em class="sig-param"><span class="n">default</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.access"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.access" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>This hook is called by the cmdhandler to determine if srcobj
|
||
is allowed to execute this command. It should return a boolean
|
||
value and is not normally something that need to be changed since
|
||
it’s using the Evennia permission system directly.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>srcobj</strong> (<em>Object</em>) – Object trying to gain permission</p></li>
|
||
<li><p><strong>access_type</strong> (<em>str</em><em>, </em><em>optional</em>) – The lock type to check.</p></li>
|
||
<li><p><strong>default</strong> (<em>bool</em><em>, </em><em>optional</em>) – The fallback result if no lock
|
||
of matching <strong>access_type</strong> is found on this Command.</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.msg">
|
||
<code class="sig-name descname">msg</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">text</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">to_obj</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">from_obj</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">session</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.msg"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.msg" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>This is a shortcut instead of calling msg() directly on an
|
||
object - it will detect if caller is an Object or an Account and
|
||
also appends self.session automatically if self.msg_all_sessions is False.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>text</strong> (<em>str</em><em>, </em><em>optional</em>) – Text string of message to send.</p></li>
|
||
<li><p><strong>to_obj</strong> (<em>Object</em><em>, </em><em>optional</em>) – Target object of message. Defaults to self.caller.</p></li>
|
||
<li><p><strong>from_obj</strong> (<em>Object</em><em>, </em><em>optional</em>) – Source of message. Defaults to to_obj.</p></li>
|
||
<li><p><strong>session</strong> (<a class="reference internal" href="evennia.server.session.html#evennia.server.session.Session" title="evennia.server.session.Session"><em>Session</em></a><em>, </em><em>optional</em>) – Supply data only to a unique
|
||
session (ignores the value of <strong>self.msg_all_sessions</strong>).</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments</dt>
|
||
<dd class="field-even"><ul class="simple">
|
||
<li><p><strong>options</strong> (<em>dict</em>) – Options to the protocol.</p></li>
|
||
<li><p><strong>any</strong> (<em>any</em>) – All other keywords are interpreted as th
|
||
name of send-instructions.</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.execute_cmd">
|
||
<code class="sig-name descname">execute_cmd</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">raw_string</span></em>, <em class="sig-param"><span class="n">session</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">obj</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.execute_cmd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.execute_cmd" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>A shortcut of execute_cmd on the caller. It appends the
|
||
session automatically.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>raw_string</strong> (<em>str</em>) – Execute this string as a command input.</p></li>
|
||
<li><p><strong>session</strong> (<a class="reference internal" href="evennia.server.session.html#evennia.server.session.Session" title="evennia.server.session.Session"><em>Session</em></a><em>, </em><em>optional</em>) – If not given, the current command’s Session will be used.</p></li>
|
||
<li><p><strong>obj</strong> (<em>Object</em><em> or </em><em>Account</em><em>, </em><em>optional</em>) – Object or Account on which to call the execute_cmd.
|
||
If not given, self.caller will be used.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments</dt>
|
||
<dd class="field-even"><ul class="simple">
|
||
<li><p><strong>keyword arguments will be added to the found command</strong> (<em>Other</em>) – </p></li>
|
||
<li><p><strong>instace as variables before it executes. This is</strong> (<a class="reference internal" href="evennia.scripts.models.html#evennia.scripts.models.ScriptDB.object" title="evennia.scripts.models.ScriptDB.object"><em>object</em></a>) – </p></li>
|
||
<li><p><strong>by default Evennia but may be used to set flags and</strong> (<em>unused</em>) – </p></li>
|
||
<li><p><strong>operating paramaters for commands at run-time.</strong> (<em>change</em>) – </p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.at_pre_cmd">
|
||
<code class="sig-name descname">at_pre_cmd</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.at_pre_cmd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.at_pre_cmd" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>This hook is called before self.parse() on all commands. If
|
||
this hook returns anything but False/None, the command
|
||
sequence is aborted.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.at_post_cmd">
|
||
<code class="sig-name descname">at_post_cmd</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.at_post_cmd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.at_post_cmd" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>This hook is called after the command has finished executing
|
||
(after self.func()).</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.parse">
|
||
<code class="sig-name descname">parse</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.parse"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.parse" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Once the cmdhandler has identified this as the command we
|
||
want, this function is run. If many of your commands have a
|
||
similar syntax (for example ‘cmd arg1 = arg2’) you should
|
||
simply define this once and just let other commands of the
|
||
same form inherit from this. See the docstring of this module
|
||
for which object properties are available to use (notably
|
||
self.args).</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.get_command_info">
|
||
<code class="sig-name descname">get_command_info</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.get_command_info"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.get_command_info" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>This is the default output of func() if no func() overload is done.
|
||
Provided here as a separate method so that it can be called for debugging
|
||
purposes when making commands.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.func">
|
||
<code class="sig-name descname">func</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.func"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.func" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>This is the actual executing part of the command. It is
|
||
called directly after self.parse(). See the docstring of this
|
||
module for which object properties are available (beyond those
|
||
set in self.parse())</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.get_extra_info">
|
||
<code class="sig-name descname">get_extra_info</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">caller</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.get_extra_info"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.get_extra_info" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Display some extra information that may help distinguish this
|
||
command from others, for instance, in a disambiguity prompt.</p>
|
||
<p>If this command is a potential match in an ambiguous
|
||
situation, one distinguishing feature may be its attachment to
|
||
a nearby object, so we include this if available.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>caller</strong> (<a class="reference internal" href="evennia.typeclasses.models.html#evennia.typeclasses.models.TypedObject" title="evennia.typeclasses.models.TypedObject"><em>TypedObject</em></a>) – The caller who typed an ambiguous</p></li>
|
||
<li><p><strong>handed to the search function.</strong> (<em>term</em>) – </p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p>A string with identifying information to disambiguate the
|
||
object, conventionally with a preceding space.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.get_help">
|
||
<code class="sig-name descname">get_help</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">caller</span></em>, <em class="sig-param"><span class="n">cmdset</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.get_help"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.get_help" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Return the help message for this command and this caller.</p>
|
||
<p>By default, return self.__doc__ (the docstring just under
|
||
the class definition). You can override this behavior,
|
||
though, and even customize it depending on the caller, or other
|
||
commands the caller can use.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>caller</strong> (<em>Object</em><em> or </em><em>Account</em>) – the caller asking for help on the command.</p></li>
|
||
<li><p><strong>cmdset</strong> (<a class="reference internal" href="evennia.commands.cmdset.html#evennia.commands.cmdset.CmdSet" title="evennia.commands.cmdset.CmdSet"><em>CmdSet</em></a>) – the command set (if you need additional commands).</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><em>docstring (str)</em> – the help text to provide the caller for this command.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.web_get_detail_url">
|
||
<code class="sig-name descname">web_get_detail_url</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.web_get_detail_url"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.web_get_detail_url" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Returns the URI path for a View that allows users to view details for
|
||
this object.</p>
|
||
<p>ex. Oscar (Character) = ‘/characters/oscar/1/’</p>
|
||
<p>For this to work, the developer must have defined a named view somewhere
|
||
in urls.py that follows the format ‘modelname-action’, so in this case
|
||
a named view of ‘character-detail’ would be referenced by this method.</p>
|
||
<p>ex.</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">url</span><span class="p">(</span><span class="sa">r</span><span class="s1">'characters/(?P<slug>[\w\d\-]+)/(?P<pk>[0-9]+)/$'</span><span class="p">,</span>
|
||
<span class="n">CharDetailView</span><span class="o">.</span><span class="n">as_view</span><span class="p">(),</span> <span class="n">name</span><span class="o">=</span><span class="s1">'character-detail'</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>If no View has been created and defined in urls.py, returns an
|
||
HTML anchor.</p>
|
||
<p>This method is naive and simply returns a path. Securing access to
|
||
the actual view and limiting who can view this object is the developer’s
|
||
responsibility.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p><em>path (str)</em> – URI path to object detail page, if defined.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.web_get_admin_url">
|
||
<code class="sig-name descname">web_get_admin_url</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.web_get_admin_url"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.web_get_admin_url" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Returns the URI path for the Django Admin page for this object.</p>
|
||
<p>ex. Account#1 = ‘/admin/accounts/accountdb/1/change/’</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p><em>path (str)</em> – URI path to Django Admin page for object.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.client_width">
|
||
<code class="sig-name descname">client_width</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.client_width"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.client_width" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Get the client screenwidth for the session using this command.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p><em>client width (int)</em> – The width (in characters) of the client window.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.styled_table">
|
||
<code class="sig-name descname">styled_table</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.styled_table"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.styled_table" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Create an EvTable styled by on user preferences.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>*args</strong> (<em>str</em>) – Column headers. If not colored explicitly, these will get colors
|
||
from user options.</p>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments</dt>
|
||
<dd class="field-even"><p><strong>any</strong> (<em>str</em><em>, </em><em>int</em><em> or </em><em>dict</em>) – EvTable options, including, optionally a <strong>table</strong> dict
|
||
detailing the contents of the table.</p>
|
||
</dd>
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p><p><em>table (EvTable)</em> –</p>
|
||
<dl class="simple">
|
||
<dt>An initialized evtable entity, either complete (if using <strong>table</strong> kwarg)</dt><dd><p>or incomplete and ready for use with <strong>.add_row</strong> or <strong>.add_collumn</strong>.</p>
|
||
</dd>
|
||
</dl>
|
||
</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.styled_header">
|
||
<code class="sig-name descname">styled_header</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.styled_header"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.styled_header" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Create a pretty header.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.styled_separator">
|
||
<code class="sig-name descname">styled_separator</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.styled_separator"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.styled_separator" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Create a separator.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.commands.command.Command.styled_footer">
|
||
<code class="sig-name descname">styled_footer</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/commands/command.html#Command.styled_footer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.commands.command.Command.styled_footer" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Create a pretty footer.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.lock_storage">
|
||
<code class="sig-name descname">lock_storage</code><em class="property"> = 'cmd:all();'</em><a class="headerlink" href="#evennia.commands.command.Command.lock_storage" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.save_for_next">
|
||
<code class="sig-name descname">save_for_next</code><em class="property"> = False</em><a class="headerlink" href="#evennia.commands.command.Command.save_for_next" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.commands.command.Command.search_index_entry">
|
||
<code class="sig-name descname">search_index_entry</code><em class="property"> = {'aliases': '', 'category': 'general', 'key': 'command', 'no_prefix': ' ', 'tags': '', 'text': '\n ## Base command\n\n (you may see this if a child command had no help text defined)\n\n Usage:\n command [args]\n\n This is the base command class. Inherit from this\n to create new commands.\n\n The cmdhandler makes the following variables available to the\n command methods (so you can always assume them to be there):\n\n self.caller - the game object calling the command\n self.cmdstring - the command name used to trigger this command (allows\n you to know which alias was used, for example)\n self.args - everything supplied to the command following the cmdstring\n (this is usually what is parsed in self.parse())\n self.cmdset - the merged cmdset from which this command was matched (useful only\n seldomly, notably for help-type commands, to create dynamic\n help entries and lists)\n self.cmdset_source - the specific cmdset this command was matched from.\n self.obj - the object on which this command is defined. If a default command,\n this is usually the same as caller.\n self.raw_string - the full raw string input, including the command name,\n any args and no parsing.\n\n The following class properties can/should be defined on your child class:\n\n key - identifier for command (e.g. "look")\n aliases - (optional) list of aliases (e.g. ["l", "loo"])\n locks - lock string (default is "cmd:all()")\n help_category - how to organize this help entry in help system\n (default is "General")\n auto_help - defaults to True. Allows for turning off auto-help generation\n arg_regex - (optional) raw string regex defining how the argument part of\n the command should look in order to match for this command\n (e.g. must it be a space between cmdname and arg?)\n auto_help_display_key - (optional) if given, this replaces the string shown\n in the auto-help listing. This is particularly useful for system-commands\n whose actual key is not really meaningful.\n\n (Note that if auto_help is on, this initial string is also used by the\n system to create the help entry for the command, so it\'s a good idea to\n format it similar to this one). This behavior can be changed by\n overriding the method \'get_help\' of a command: by default, this\n method returns cmd.__doc__ (that is, this very docstring, or\n the docstring of your command). You can, however, extend or\n replace this without disabling auto_help.\n '}</em><a class="headerlink" href="#evennia.commands.command.Command.search_index_entry" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</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="evennia.commands.default.html" title="evennia.commands.default"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.commands.cmdsethandler.html" title="evennia.commands.cmdsethandler"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia latest</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.commands.html" >evennia.commands</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.commands.command</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
|
||
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2023, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
|
||
</div>
|
||
</body>
|
||
</html> |