<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>
<divclass="section"id="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 sent without any line breaks.</p>
<p>You can combine the sending of normal text with the sending (updating of the prompt):</p>
<divclass="highlight-python notranslate"><tableclass="highlighttable"><tr><tdclass="linenos"><divclass="linenodiv"><pre>1</pre></div></td><tdclass="code"><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>
</td></tr></table></div>
<p>You can update the prompt on demand, this is normally done using <aclass="reference internal"href="OOB.html"><spanclass="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="s2">"You diagnose </span><spanclass="si">%s</span><spanclass="s2"> as having "</span> \
<spanclass="s2">"</span><spanclass="si">%i</span><spanclass="s2"> health, </span><spanclass="si">%i</span><spanclass="s2"> mana and </span><spanclass="si">%i</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>
<h3>Modifying default commands<aclass="headerlink"href="#modifying-default-commands"title="Permalink to this headline">¶</a></h3>
<p>If you want to add something small like this to Evennia’s default commands without modifying them directly the easiest way is to just wrap those with a multiple inheritance to your own base class:</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>
<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>