<h1>Command Prompt<aclass="headerlink"href="#command-prompt"title="Permalink to this headline">¶</a></h1>
<p>A <em>prompt</em> is quite common in MUDs. The prompt display useful details about your character that you
are likely to want to keep tabs on at all times, such as health, magical power etc. It might also
show things like in-game time, weather and so on. Many modern MUD clients (including Evennia’s own
webclient) allows for identifying the prompt and have it appear in a correct location (usually just
above the input line). Usually it will remain like that until it is explicitly updated.</p>
<sectionid="sending-a-prompt">
<h2>Sending a prompt<aclass="headerlink"href="#sending-a-prompt"title="Permalink to this headline">¶</a></h2>
<p>A prompt is sent using the <codeclass="docutils literal notranslate"><spanclass="pre">prompt</span></code> keyword to the <codeclass="docutils literal notranslate"><spanclass="pre">msg()</span></code> method on objects. The prompt will be
<p>You can combine the sending of normal text with the sending (updating of the prompt):</p>
<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">msg</span><spanclass="p">(</span><spanclass="s2">"This is a text"</span><spanclass="p">,</span><spanclass="n">prompt</span><spanclass="o">=</span><spanclass="s2">"This is a prompt"</span><spanclass="p">)</span>
</pre></div>
</div>
<p>You can update the prompt on demand, this is normally done using <aclass="reference internal"href="../Concepts/OOB.html"><spanclass="doc std std-doc">OOB</span></a>-tracking of the relevant
Attributes (like the character’s health). You could also make sure that attacking commands update
the prompt when they cause a change in health, for example.</p>
<p>Here is a simple example of the prompt sent/updated from a command class:</p>
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">caller</span><spanclass="o">.</span><spanclass="n">msg</span><spanclass="p">(</span><spanclass="s2">"Not a valid target!"</span><spanclass="p">)</span>
<spanclass="k">return</span>
<spanclass="n">text</span><spanclass="o">=</span><spanclass="sa">f</span><spanclass="s2">"You diagnose </span><spanclass="si">{</span><spanclass="n">target</span><spanclass="si">}</span><spanclass="s2"> as having </span><spanclass="si">{</span><spanclass="n">hp</span><spanclass="si">}</span><spanclass="s2"> health, </span><spanclass="si">{</span><spanclass="n">mp</span><spanclass="si">}</span><spanclass="s2"> mana and </span><spanclass="si">{</span><spanclass="n">sp</span><spanclass="si">}</span><spanclass="s2"> stamina."</span>
<h2>A prompt sent with every command<aclass="headerlink"href="#a-prompt-sent-with-every-command"title="Permalink to this headline">¶</a></h2>
<p>The prompt sent as described above uses a standard telnet instruction (the Evennia web client gets a
special flag). Most MUD telnet clients will understand and allow users to catch this and keep the
prompt in place until it updates. So <em>in principle</em> you’d not need to update the prompt every
command.</p>
<p>However, with a varying user base it can be unclear which clients are used and which skill level the
users have. So sending a prompt with every command is a safe catch-all. You don’t need to manually
go in and edit every command you have though. Instead you edit the base command class for your
custom commands (like <codeclass="docutils literal notranslate"><spanclass="pre">MuxCommand</span></code> in your <codeclass="docutils literal notranslate"><spanclass="pre">mygame/commands/command.py</span></code> folder) and overload the
<codeclass="docutils literal notranslate"><spanclass="pre">at_post_cmd()</span></code> hook. This hook is always called <em>after</em> the main <codeclass="docutils literal notranslate"><spanclass="pre">func()</span></code> method of the Command.</p>
<p>The result of this is that the hooks from your custom <codeclass="docutils literal notranslate"><spanclass="pre">MuxCommand</span></code> will be mixed into the default
<codeclass="docutils literal notranslate"><spanclass="pre">CmdLook</span></code> through multiple inheritance. Next you just add this to your default command set:</p>
<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># in mygame/commands/default_cmdsets.py</span>
<p>This will automatically replace the default <codeclass="docutils literal notranslate"><spanclass="pre">look</span></code> command in your game with your own version.</p>