<spanid="evennia-utils-evmenu"></span><h1>evennia.utils.evmenu<aclass="headerlink"href="#module-evennia.utils.evmenu"title="Permalink to this headline">¶</a></h1>
<p>EvMenu</p>
<p>This implements a full menu system for Evennia.</p>
<p>To start the menu, just import the EvMenu class from this module.
<dt><strong>text</strong> (str, tuple or None): Text shown at this node. If a tuple, the</dt><dd><p>second element in the tuple holds either a string or a dict. If a string,
this is the help text to show when <strong>auto_help</strong> is active for the menu and
the user presses <strong>h</strong>. If a dict, this is a mapping of <strong>‘help topic’: ‘help text’</strong> to
show in that menu. This can be used to show information without having to
<spanclass="p">{</span><spanclass="s2">"desc"</span><spanclass="p">:</span><spanclass="s2">"Go to node 3."</span><spanclass="p">,</span>
# allows to perform different actions depending on
# what is inserted.
# this catches everything starting with foo
> foo*: handle_foo_message()
# regex are also allowed (this catches number inputs)
> [0-9]+?: handle_numbers()
# this catches the empty return
>: start
# this catches everything else
> *: handle_message(from_node=node1)
## node node2
Text for Node2. Just go back.
## options
>: start
## node abort
This exits the menu since there is no **## options** section.
</pre></div>
</div>
<p>Each menu node is defined by a <strong># node <name></strong> containing the text of the node,
followed by <strong>## options</strong> Also <strong>## NODE</strong> and <strong>## OPTIONS</strong> work. No python code
logics is allowed in the template, this code is not evaluated but parsed. More
advanced dynamic usage requires a full node-function (which can be added to the
generated dict, as said).</p>
<p>Adding <strong>(..)</strong> to a goto treats it as a callable and it must then be included in
the <strong>goto_callable</strong> mapping. Only named keywords (or no args at all) are
allowed, these will be added to the <strong>**kwargs</strong> going into the callable. Quoting
strings is only needed if wanting to pass strippable spaces, otherwise the
key:values will be converted to strings/numbers with literal_eval before passed
into the callable.</p>
<p>The > option takes a glob or regex to perform different actions depending
on user input. Make sure to sort these in increasing order of generality since
they will be tested in sequence.</p>
<hrclass="docutils"/>
<dlclass="py exception">
<dtid="evennia.utils.evmenu.EvMenuError">
<emclass="property">exception </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">EvMenuError</code><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenuError"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuError"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">EvMenuGotoAbortMessage</code><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenuGotoAbortMessage"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuGotoAbortMessage"title="Permalink to this definition">¶</a></dt>
<p>This can be raised by a goto-callable to abort the goto flow. The message
stored with the executable will be sent to the caller who will remain on
the current node. This can be used to pass single-line returns without
re-running the entire node with text and options.</p>
<pclass="rubric">Example</p>
<p>raise EvMenuGotoMessage(“That makes no sense.”)</p>
</dd></dl>
<dlclass="py class">
<dtid="evennia.utils.evmenu.CmdEvMenuNode">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">CmdEvMenuNode</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdEvMenuNode"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode"title="Permalink to this definition">¶</a></dt>
<p>Command to handle all user input targeted at the menu while the menu is active.</p>
<dlclass="py attribute">
<dtid="evennia.utils.evmenu.CmdEvMenuNode.key">
<codeclass="sig-name descname">key</code><emclass="property"> = '__noinput_command'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">aliases</code><emclass="property"> = ['__nomatch_command']</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.aliases"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="py attribute">
<dtid="evennia.utils.evmenu.CmdEvMenuNode.locks">
<codeclass="sig-name descname">locks</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.locks"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'menu'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.help_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">auto_help_display_key</code><emclass="property"> = '<menu commands>'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.auto_help_display_key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">get_help</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdEvMenuNode.get_help"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.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>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="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> (<aclass="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>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>docstring (str)</em>– the help text to provide the caller for this command.</p>
</dd>
</dl>
</dd></dl>
<dlclass="py method">
<dtid="evennia.utils.evmenu.CmdEvMenuNode.func">
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdEvMenuNode.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.func"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '__nomatch_command', 'category': 'menu', 'key': '__noinput_command', 'no_prefix': ' __nomatch_command', 'tags': '', 'text': '\n Command to handle all user input targeted at the menu while the menu is active.\n\n '}</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdEvMenuNode.search_index_entry"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="py class">
<dtid="evennia.utils.evmenu.EvMenuCmdSet">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">EvMenuCmdSet</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">cmdsetobj</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">key</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenuCmdSet"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet"title="Permalink to this definition">¶</a></dt>
<p>The Menu cmdset replaces the current cmdset.</p>
<dlclass="py attribute">
<dtid="evennia.utils.evmenu.EvMenuCmdSet.key">
<codeclass="sig-name descname">key</code><emclass="property"> = 'menu_cmdset'</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">priority</code><emclass="property"> = 1</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.priority"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">mergetype</code><emclass="property"> = 'Replace'</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.mergetype"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_objs</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.no_objs"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_exits</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.no_exits"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_channels</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.no_channels"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_cmdset_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenuCmdSet.at_cmdset_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.at_cmdset_creation"title="Permalink to this definition">¶</a></dt>
<dd><p>Called when creating the set.</p>
</dd></dl>
<dlclass="py attribute">
<dtid="evennia.utils.evmenu.EvMenuCmdSet.path">
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.utils.evmenu.EvMenuCmdSet'</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenuCmdSet.path"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">node_border_char</code><emclass="property"> = '_'</em><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.node_border_char"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="py method">
<dtid="evennia.utils.evmenu.EvMenu.__init__">
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">caller</span></em>, <emclass="sig-param"><spanclass="n">menudata</span></em>, <emclass="sig-param"><spanclass="n">startnode</span><spanclass="o">=</span><spanclass="default_value">'start'</span></em>, <emclass="sig-param"><spanclass="n">cmdset_mergetype</span><spanclass="o">=</span><spanclass="default_value">'Replace'</span></em>, <emclass="sig-param"><spanclass="n">cmdset_priority</span><spanclass="o">=</span><spanclass="default_value">1</span></em>, <emclass="sig-param"><spanclass="n">auto_quit</span><spanclass="o">=</span><spanclass="default_value">True</span></em>, <emclass="sig-param"><spanclass="n">auto_look</span><spanclass="o">=</span><spanclass="default_value">True</span></em>, <emclass="sig-param"><spanclass="n">auto_help</span><spanclass="o">=</span><spanclass="default_value">True</span></em>, <emclass="sig-param"><spanclass="n">cmd_on_exit</span><spanclass="o">=</span><spanclass="default_value">'look'</span></em>, <emclass="sig-param"><spanclass="n">persistent</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <emclass="sig-param"><spanclass="n">startnode_input</span><spanclass="o">=</span><spanclass="default_value">''</span></em>, <emclass="sig-param"><spanclass="n">session</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">debug</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize the menu tree and start the caller onto the first node.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>caller</strong> (<em>Object</em><em>, </em><em>Account</em><em> or </em><aclass="reference internal"href="evennia.server.session.html#evennia.server.session.Session"title="evennia.server.session.Session"><em>Session</em></a>) – The user of the menu.</p></li>
<li><p><strong>menudata</strong> (<em>str</em><em>, </em><em>module</em><em> or </em><em>dict</em>) – The full or relative path to the module
holding the menu tree data. All global functions in this module
whose name doesn’t start with ‘_ ‘ will be parsed as menu nodes.
Also the module itself is accepted as input. Finally, a dictionary
menu tree can be given directly. This must then be a mapping
<strong>{“nodekey”:callable,…}</strong> where <strong>callable</strong> must be called as
and return the data expected of a menu node. This allows for
dynamic menu creation.</p></li>
<li><p><strong>startnode</strong> (<em>str</em><em>, </em><em>optional</em>) – The starting node name in the menufile.</p></li>
<li><p><strong>cmdset_mergetype</strong> (<em>str</em><em>, </em><em>optional</em>) –‘Replace’ (default) means the menu
commands will be exclusive - no other normal commands will
be usable while the user is in the menu. ‘Union’ means the
menu commands will be integrated with the existing commands
(it will merge with <strong>merge_priority</strong>), if so, make sure that
the menu’s command names don’t collide with existing commands
in an unexpected way. Also the CMD_NOMATCH and CMD_NOINPUT will
be overloaded by the menu cmdset. Other cmdser mergetypes
has little purpose for the menu.</p></li>
<li><p><strong>cmdset_priority</strong> (<em>int</em><em>, </em><em>optional</em>) – The merge priority for the
menu command set. The default (1) is usually enough for most
types of menus.</p></li>
<li><p><strong>auto_quit</strong> (<em>bool</em><em>, </em><em>optional</em>) – Allow user to use “q”, “quit” or
“exit” to leave the menu at any point. Recommended during
development!</p></li>
<li><p><strong>auto_look</strong> (<em>bool</em><em>, </em><em>optional</em>) – Automatically make “looK” or “l” to
re-show the last node. Turning this off means you have to handle
re-showing nodes yourself, but may be useful if you need to
use “l” for some other purpose.</p></li>
<li><p><strong>auto_help</strong> (<em>bool</em><em>, </em><em>optional</em>) – Automatically make “help” or “h” show
the current help entry for the node. If turned off, eventual
help must be handled manually, but it may be useful if you
need ‘h’ for some other purpose, for example.</p></li>
<li><p><strong>cmd_on_exit</strong> (<em>callable</em><em>, </em><em>str</em><em> or </em><em>None</em><em>, </em><em>optional</em>) – When exiting the menu
(either by reaching a node with no options or by using the
in-built quit command (activated with <strong>allow_quit</strong>), this
callback function or command string will be executed.
The callback function takes two parameters, the caller then the
EvMenu object. This is called after cleanup is complete.
Set to None to not call any command.</p></li>
<li><p><strong>persistent</strong> (<em>bool</em><em>, </em><em>optional</em>) – Make the Menu persistent (i.e. it will
survive a reload. This will make the Menu cmdset persistent. Use
with caution - if your menu is buggy you may end up in a state
you can’t get out of! Also note that persistent mode requires
that all formatters, menu nodes and callables are possible to
<em>pickle</em>. When the server is reloaded, the latest node shown will be completely
re-run with the same input arguments - so be careful if you are counting
up some persistent counter or similar - the counter may be run twice if
reload happens on the node that does that. Note that if <strong>debug</strong> is True,
this setting is ignored and assumed to be False.</p></li>
<li><p><strong>startnode_input</strong> (<em>str</em><em> or </em><em>(</em><em>str</em><em>, </em><em>dict</em><em>)</em><em>, </em><em>optional</em>) – Send an input text to <strong>startnode</strong> as if
a user input text from a fictional previous node. If including the dict, this will
be passed as <strong>kwargs to that node. When the server reloads,
the latest visited node will be re-run as **node(caller, raw_string, **kwargs)</strong>.</p></li>
<li><p><strong>session</strong> (<aclass="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>) – This is useful when calling EvMenu from an account
in multisession mode > 2. Note that this session only really relevant
for the very first display of the first node - after that, EvMenu itself
will keep the session updated from the command input. So a persistent
menu will <em>not</em> be using this same session anymore after a reload.</p></li>
<li><p><strong>debug</strong> (<em>bool</em><em>, </em><em>optional</em>) – If set, the ‘menudebug’ command will be made available
by default in all nodes of the menu. This will print out the current state of
the menu. Deactivate for production use! When the debug flag is active, the
<strong>persistent</strong> flag is deactivated.</p></li>
<ddclass="field-even"><p><aclass="reference internal"href="#evennia.utils.evmenu.EvMenuError"title="evennia.utils.evmenu.EvMenuError"><strong>EvMenuError</strong></a>– If the start/end node is not found in menu tree.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>While running, the menu is stored on the caller as <strong>caller.ndb._evmenu</strong>. Also
the current Session (from the Command, so this is still valid in multisession
environments) is available through <strong>caller.ndb._evmenu._session</strong>. The <strong>_evmenu</strong>
property is a good one for storing intermediary data on between nodes since it
will be automatically deleted when the menu closes.</p>
<p>In persistent mode, all nodes, formatters and callbacks in the menu must be
possible to be <em>pickled</em>, this excludes e.g. callables that are class methods
or functions defined dynamically or as part of another function. In
non-persistent mode no such restrictions exist.</p>
</dd></dl>
<dlclass="py method">
<dtid="evennia.utils.evmenu.EvMenu.goto">
<codeclass="sig-name descname">goto</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">nodename_or_callable</span></em>, <emclass="sig-param"><spanclass="n">raw_string</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.goto"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.goto"title="Permalink to this definition">¶</a></dt>
<dd><p>Run a node by name, optionally dynamically generating that name first.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>nodename_or_callable</strong> (<em>str</em><em> or </em><em>callable</em>) – Name of node or a callable
to be called as <strong>function(caller, raw_string, **kwargs)</strong> or
<strong>function(caller, **kwargs)</strong>. This callable must return the node-name (str)
pointing to the next node.</p></li>
<li><p><strong>raw_string</strong> (<em>str</em>) – The raw default string entered on the
previous node (only used if the node accepts it as an
argument)</p></li>
<li><p><strong>**kwargs</strong>– Extra arguments to goto callables.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dlclass="py method">
<dtid="evennia.utils.evmenu.EvMenu.close_menu">
<codeclass="sig-name descname">close_menu</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.close_menu"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.close_menu"title="Permalink to this definition">¶</a></dt>
<dd><p>Shutdown menu; occurs when reaching the end node or using the quit command.</p>
<codeclass="sig-name descname">print_debug_info</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">arg</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.print_debug_info"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.print_debug_info"title="Permalink to this definition">¶</a></dt>
<dd><p>Messages the caller with the current menu state, for debug purposes.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>arg</strong> (<em>str</em>) – Arg to debug instruction, either nothing, ‘full’ or the name
of a property to inspect.</p>
</dd>
</dl>
</dd></dl>
<dlclass="py method">
<dtid="evennia.utils.evmenu.EvMenu.msg">
<codeclass="sig-name descname">msg</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">txt</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.msg"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.msg"title="Permalink to this definition">¶</a></dt>
<dd><p>This is a central point for sending return texts to the caller. It
allows for a central point to add custom messaging when creating custom
EvMenu overrides.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>txt</strong> (<em>str</em>) – The text to send.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>By default this will send to the same session provided to EvMenu
(if <strong>session</strong> kwarg was provided to <strong>EvMenu.__init__</strong>). It will
also send it with a <strong>type=menu</strong> for the benefit of OOB/webclient.</p>
</dd></dl>
<dlclass="py method">
<dtid="evennia.utils.evmenu.EvMenu.parse_input">
<codeclass="sig-name descname">parse_input</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">raw_string</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.parse_input"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.parse_input"title="Permalink to this definition">¶</a></dt>
<dd><p>Parses the incoming string from the menu user. This is the entry-point for all input
into the menu.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>raw_string</strong> (<em>str</em>) – The incoming, unmodified string
from the user.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>This method is expected to parse input and use the result
to relay execution to the relevant methods of the menu. It
should also report errors directly to the user.</p>
<codeclass="sig-name descname">display_nodetext</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.display_nodetext"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.display_nodetext"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">display_helptext</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.display_helptext"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.display_helptext"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">display_tooltip</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">cmd</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.display_tooltip"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.display_tooltip"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">nodetext_formatter</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">nodetext</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.nodetext_formatter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.nodetext_formatter"title="Permalink to this definition">¶</a></dt>
<dd><p>Format the node text itself.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>nodetext</strong> (<em>str</em>) – The full node text (the text describing the node).</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>nodetext (str)</em>– The formatted node text.</p>
<codeclass="sig-name descname">helptext_formatter</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">helptext</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.helptext_formatter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.helptext_formatter"title="Permalink to this definition">¶</a></dt>
<dd><p>Format the node’s help text</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>helptext</strong> (<em>str</em>) – The unformatted help text for the node.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>helptext (str)</em>– The formatted help text.</p>
<codeclass="sig-name descname">options_formatter</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">optionlist</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.options_formatter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.options_formatter"title="Permalink to this definition">¶</a></dt>
<dd><p>Formats the option block.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>optionlist</strong> (<em>list</em>) – List of (key, description) tuples for every
option related to this node.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>options (str)</em>– The formatted option display.</p>
<codeclass="sig-name descname">node_formatter</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">nodetext</span></em>, <emclass="sig-param"><spanclass="n">optionstext</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#EvMenu.node_formatter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.EvMenu.node_formatter"title="Permalink to this definition">¶</a></dt>
<dd><p>Formats the entirety of the node.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>nodetext</strong> (<em>str</em>) – The node text as returned by <strong>self.nodetext_formatter</strong>.</p></li>
<li><p><strong>optionstext</strong> (<em>str</em>) – The options display as returned by <strong>self.options_formatter</strong>.</p></li>
<li><p><strong>caller</strong> (<em>Object</em><em>, </em><em>Account</em><em> or </em><em>None</em><em>, </em><em>optional</em>) – The caller of the node.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>node (str)</em>– The formatted node to display.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="py function">
<dtid="evennia.utils.evmenu.list_node">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">list_node</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">option_generator</span></em>, <emclass="sig-param"><spanclass="n">select</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">pagesize</span><spanclass="o">=</span><spanclass="default_value">10</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#list_node"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.list_node"title="Permalink to this definition">¶</a></dt>
<dd><p>Decorator for making an EvMenu node into a multi-page list node. Will add new options,
prepending those options added in the node.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>option_generator</strong> (<em>callable</em><em> or </em><em>list</em>) – A list of strings indicating the options, or a callable
that is called as option_generator(caller) to produce such a list.</p></li>
<li><p><strong>select</strong> (<em>callable</em><em> or </em><em>str</em><em>, </em><em>optional</em>) – Node to redirect a selection to. Its <strong>**kwargs</strong> will
contain the <strong>available_choices</strong> list and <strong>selection</strong> will hold one of the elements in
that list. If a callable, it will be called as
<strong>select(caller, menuchoice, **kwargs)</strong> where menuchoice is the chosen option as a
string and <strong>available_choices</strong> is a kwarg mapping the option keys to the choices
offered by the option_generator. The callable whould return the name of the target node
to goto after this selection (or None to repeat the list-node). Note that if this is not
given, the decorated node must itself provide a way to continue from the node!</p></li>
<li><p><strong>pagesize</strong> (<em>int</em>) – How many options to show per page.</p></li>
<p>All normal <strong>goto</strong> callables returned from the decorated nodes
will, if they accept <strong>**kwargs</strong>, get a new kwarg ‘available_choices’
injected. These are the ordered list of named options (descs) visible
on the current node page.</p>
</dd></dl>
<dlclass="py class">
<dtid="evennia.utils.evmenu.CmdGetInput">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">CmdGetInput</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdGetInput"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = '__nomatch_command'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.key"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="py attribute">
<dtid="evennia.utils.evmenu.CmdGetInput.aliases">
<codeclass="sig-name descname">aliases</code><emclass="property"> = ['__noinput_command']</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.aliases"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="py method">
<dtid="evennia.utils.evmenu.CmdGetInput.func">
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdGetInput.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.func"title="Permalink to this definition">¶</a></dt>
<dd><p>This is called when user enters anything.</p>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.help_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all();'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '__noinput_command', 'category': 'general', 'key': '__nomatch_command', 'no_prefix': ' __noinput_command', 'tags': '', 'text': '\n Enter your data and press return.\n '}</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdGetInput.search_index_entry"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="py class">
<dtid="evennia.utils.evmenu.InputCmdSet">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">InputCmdSet</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">cmdsetobj</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">key</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#InputCmdSet"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = 'input_cmdset'</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">priority</code><emclass="property"> = 1</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.priority"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">mergetype</code><emclass="property"> = 'Replace'</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.mergetype"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="py attribute">
<dtid="evennia.utils.evmenu.InputCmdSet.no_objs">
<codeclass="sig-name descname">no_objs</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.no_objs"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_exits</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.no_exits"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_channels</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.no_channels"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_cmdset_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#InputCmdSet.at_cmdset_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.at_cmdset_creation"title="Permalink to this definition">¶</a></dt>
<dd><p>called once at creation</p>
</dd></dl>
<dlclass="py attribute">
<dtid="evennia.utils.evmenu.InputCmdSet.path">
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.utils.evmenu.InputCmdSet'</em><aclass="headerlink"href="#evennia.utils.evmenu.InputCmdSet.path"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="py function">
<dtid="evennia.utils.evmenu.get_input">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">get_input</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">caller</span></em>, <emclass="sig-param"><spanclass="n">prompt</span></em>, <emclass="sig-param"><spanclass="n">callback</span></em>, <emclass="sig-param"><spanclass="n">session</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#get_input"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.get_input"title="Permalink to this definition">¶</a></dt>
<dd><p>This is a helper function for easily request input from the caller.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>caller</strong> (<em>Account</em><em> or </em><em>Object</em>) – The entity being asked the question. This
should usually be an object controlled by a user.</p></li>
<li><p><strong>prompt</strong> (<em>str</em>) – This text will be shown to the user, in order to let them
know their input is needed.</p></li>
<li><p><strong>callback</strong> (<em>callable</em>) – A function that will be called
when the user enters a reply. It must take three arguments: the
<strong>caller</strong>, the <strong>prompt</strong> text and the <strong>result</strong> of the input given by
the user. If the callback doesn’t return anything or return False,
the input prompt will be cleaned up and exited. If returning True,
the prompt will remain and continue to accept input.</p></li>
<li><p><strong>session</strong> (<aclass="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>) – This allows to specify the
session to send the prompt to. It’s usually only needed if <strong>caller</strong>
is an Account in multisession modes greater than 2. The session is
then updated by the command and is available (for example in
callbacks) through <strong>caller.ndb.getinput._session</strong>.</p></li>
<li><p><strong>*args</strong> (<em>any</em>) – Extra arguments to pass to <strong>callback</strong>. To utilise <strong>*args</strong>
(and <strong>**kwargs</strong>), a value for the <strong>session</strong> argument must also be
provided.</p></li>
<li><p><strong>**kwargs</strong> (<em>any</em>) – Extra kwargs to pass to <strong>callback</strong>.</p></li>
</ul>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><strong>RuntimeError</strong>– If the given callback is not callable.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>The result value sent to the callback is raw and not processed in any
way. This means that you will get the ending line return character from
most types of client inputs. So make sure to strip that before doing a
comparison.</p>
<p>When the prompt is running, a temporary object <strong>caller.ndb._getinput</strong>
is stored; this will be removed when the prompt finishes.</p>
<p>If you need the specific Session of the caller (which may not be easy
to get if caller is an account in higher multisession modes), then it
is available in the callback through <strong>caller.ndb._getinput._session</strong>.
This is why the <strong>session</strong> is required as input.</p>
<p>It’s not recommended to ‘chain’<strong>get_input</strong> into a sequence of
questions. This will result in the caller stacking ever more instances
of InputCmdSets. While they will all be cleared on concluding the
get_input chain, EvMenu should be considered for anything beyond a
single question.</p>
</dd></dl>
<dlclass="py class">
<dtid="evennia.utils.evmenu.CmdYesNoQuestion">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">CmdYesNoQuestion</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdYesNoQuestion"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdYesNoQuestion"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = '__noinput_command'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdYesNoQuestion.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">arg_regex</code><emclass="property"> = re.compile('^$', re.IGNORECASE)</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdYesNoQuestion.arg_regex"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#CmdYesNoQuestion.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.CmdYesNoQuestion.func"title="Permalink to this definition">¶</a></dt>
<dd><p>This is called when user enters anything.</p>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdYesNoQuestion.help_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all();'</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdYesNoQuestion.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': 'n no yes a __nomatch_command y abort', 'category': 'general', 'key': '__noinput_command', 'no_prefix': ' n no yes a __nomatch_command y abort', 'tags': '', 'text': '\n Handle a prompt for yes or no. Press [return] for the default choice.\n\n '}</em><aclass="headerlink"href="#evennia.utils.evmenu.CmdYesNoQuestion.search_index_entry"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">YesNoQuestionCmdSet</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">cmdsetobj</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">key</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#YesNoQuestionCmdSet"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.YesNoQuestionCmdSet"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = 'yes_no_question_cmdset'</em><aclass="headerlink"href="#evennia.utils.evmenu.YesNoQuestionCmdSet.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">priority</code><emclass="property"> = 1</em><aclass="headerlink"href="#evennia.utils.evmenu.YesNoQuestionCmdSet.priority"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">mergetype</code><emclass="property"> = 'Replace'</em><aclass="headerlink"href="#evennia.utils.evmenu.YesNoQuestionCmdSet.mergetype"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_objs</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.utils.evmenu.YesNoQuestionCmdSet.no_objs"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_exits</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.utils.evmenu.YesNoQuestionCmdSet.no_exits"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">no_channels</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.utils.evmenu.YesNoQuestionCmdSet.no_channels"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_cmdset_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#YesNoQuestionCmdSet.at_cmdset_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.YesNoQuestionCmdSet.at_cmdset_creation"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.utils.evmenu.YesNoQuestionCmdSet'</em><aclass="headerlink"href="#evennia.utils.evmenu.YesNoQuestionCmdSet.path"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="py function">
<dtid="evennia.utils.evmenu.ask_yes_no">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">ask_yes_no</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">caller</span></em>, <emclass="sig-param"><spanclass="n">prompt</span><spanclass="o">=</span><spanclass="default_value">'Yes or No {options}?'</span></em>, <emclass="sig-param"><spanclass="n">yes_action</span><spanclass="o">=</span><spanclass="default_value">'Yes'</span></em>, <emclass="sig-param"><spanclass="n">no_action</span><spanclass="o">=</span><spanclass="default_value">'No'</span></em>, <emclass="sig-param"><spanclass="n">default</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">allow_abort</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <emclass="sig-param"><spanclass="n">session</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#ask_yes_no"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.ask_yes_no"title="Permalink to this definition">¶</a></dt>
<dd><p>A helper function for asking a simple yes/no question. This will cause
the system to pause and wait for input from the player.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>caller</strong> (<em>Object</em>) – The entity being asked.</p></li>
<li><p><strong>prompt</strong> (<em>str</em>) – The yes/no question to ask. This takes an optional formatting
marker <strong>{options}</strong> which will be filled with ‘Y/N’, ‘[Y]/N’ or
‘Y/[N]’ depending on the setting of <strong>default</strong>. If <strong>allow_abort</strong> is set,
then the ‘A(bort)’ option will also be available.</p></li>
<li><p><strong>yes_action</strong> (<em>callable</em><em> or </em><em>str</em>) – If a callable, this will be called
with <strong>(caller, *args, **kwargs)</strong> when the Yes-choice is made.
If a string, this string will be echoed back to the caller.</p></li>
<li><p><strong>no_action</strong> (<em>callable</em><em> or </em><em>str</em>) – If a callable, this will be called
with <strong>(caller, *args, **kwargs)</strong> when the No-choice is made.
If a string, this string will be echoed back to the caller.</p></li>
<li><p><strong>default</strong> (<em>str optional</em>) – This is what the user will get if they just press the
return key without giving any input. One of ‘N’, ‘Y’, ‘A’ or <strong>None</strong>
for no default (an explicit choice must be given). If ‘A’ (abort)
is given, <strong>allow_abort</strong> kwarg is ignored and assumed set.</p></li>
<li><p><strong>allow_abort</strong> (<em>bool</em><em>, </em><em>optional</em>) – If set, the ‘A(bort)’ option is available
(a third option meaning neither yes or no but just exits the prompt).</p></li>
<li><p><strong>session</strong> (<aclass="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>) – This allows to specify the
session to send the prompt to. It’s usually only needed if <strong>caller</strong>
is an Account in multisession modes greater than 2. The session is
then updated by the command and is available (for example in
callbacks) through <strong>caller.ndb._yes_no_question.session</strong>.</p></li>
<li><p><strong>*args</strong>– Additional arguments passed on into callables.</p></li>
<li><p><strong>**kwargs</strong>– Additional keyword args passed on into callables.</p></li>
</ul>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><strong>RuntimeError</strong><strong>, </strong><strong>FooError</strong>– If default and <strong>allow_abort</strong> clashes.</p>
</dd>
</dl>
<pclass="rubric">Example</p>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># just returning strings</span>
<spanclass="n">ask_yes_no</span><spanclass="p">(</span><spanclass="n">caller</span><spanclass="p">,</span><spanclass="s2">"Are you happy </span><spanclass="si">{options}</span><spanclass="s2">?"</span><spanclass="p">,</span>
<spanclass="n">ask_yes_no</span><spanclass="p">(</span><spanclass="n">caller</span><spanclass="p">,</span><spanclass="s2">"Are you sad </span><spanclass="si">{options}</span><spanclass="s2">?"</span><spanclass="p">,</span>
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">parse_menu_template</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">caller</span></em>, <emclass="sig-param"><spanclass="n">menu_template</span></em>, <emclass="sig-param"><spanclass="n">goto_callables</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#parse_menu_template"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.parse_menu_template"title="Permalink to this definition">¶</a></dt>
<dd><p>Parse menu-template string. The main function of the EvMenu templating system.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>caller</strong> (<em>Object</em><em> or </em><em>Account</em>) – Entity using the menu.</p></li>
<li><p><strong>menu_template</strong> (<em>str</em>) – Menu described using the templating format.</p></li>
<li><p><strong>goto_callables</strong> (<em>dict</em><em>, </em><em>optional</em>) – Mapping between call-names and callables
on the form <strong>callable(caller, raw_string, **kwargs)</strong>. These are what is
available to use in the <strong>menu_template</strong> string.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>dict</em>– A <strong>{“node”: nodefunc}</strong> menutree suitable to pass into EvMenu.</p>
</dd>
</dl>
</dd></dl>
<dlclass="py function">
<dtid="evennia.utils.evmenu.template2menu">
<codeclass="sig-prename descclassname">evennia.utils.evmenu.</code><codeclass="sig-name descname">template2menu</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">caller</span></em>, <emclass="sig-param"><spanclass="n">menu_template</span></em>, <emclass="sig-param"><spanclass="n">goto_callables</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">startnode</span><spanclass="o">=</span><spanclass="default_value">'start'</span></em>, <emclass="sig-param"><spanclass="n">persistent</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/utils/evmenu.html#template2menu"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.utils.evmenu.template2menu"title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function to generate and start an EvMenu based on a menu template
string. This will internall call <strong>parse_menu_template</strong> and run a default
EvMenu with its results.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>caller</strong> (<em>Object</em><em> or </em><em>Account</em>) – The entity using the menu.</p></li>
<li><p><strong>menu_template</strong> (<em>str</em>) – The menu-template string describing the content
and structure of the menu. It can also be the python-path to, or a module
containing a <strong>MENU_TEMPLATE</strong> global variable with the template.</p></li>
<li><p><strong>goto_callables</strong> (<em>dict</em><em>, </em><em>optional</em>) – Mapping of callable-names to
module-global objects to reference by name in the menu-template.
Must be on the form <strong>callable(caller, raw_string, **kwargs)</strong>.</p></li>
<li><p><strong>startnode</strong> (<em>str</em><em>, </em><em>optional</em>) – The name of the startnode, if not ‘start’.</p></li>
<li><p><strong>persistent</strong> (<em>bool</em><em>, </em><em>optional</em>) – If the generated menu should be persistent.</p></li>
<li><p><strong>**kwargs</strong>– All kwargs will be passed into EvMenu.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>EvMenu</em>– The generated EvMenu.</p>