<h1>Messages varying per receiver<aclass="headerlink"href="#messages-varying-per-receiver"title="Permalink to this headline">¶</a></h1>
<p>Sending messages to everyong in a location is handled by the <aclass="reference internal"href="../api/evennia.objects.objects.html#evennia.objects.objects.DefaultObject.msg_contents"title="evennia.objects.objects.DefaultObject.msg_contents"><spanclass="xref myst py py-meth">msg_contents</span></a> method on
all <aclass="reference internal"href="../Components/Objects.html"><spanclass="doc std std-doc">Objects</span></a>. It’s most commonly called on rooms.</p>
<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="n">room</span><spanclass="o">.</span><spanclass="n">msg_contents</span><spanclass="p">(</span><spanclass="s2">"Anna walks into the room."</span><spanclass="p">)</span>
</pre></div>
</div>
<p>You can also embed references in the string:</p>
<spanclass="n">room</span><spanclass="o">.</span><spanclass="n">msg_contents</span><spanclass="p">(</span><spanclass="s2">"</span><spanclass="si">{anna}</span><spanclass="s2"> walks into the room."</span><spanclass="p">,</span>
<p>Use <codeclass="docutils literal notranslate"><spanclass="pre">exclude=object_or_list_of_object</span></code> to skip sending the message one or more targets.</p>
<p>The advantage of this is that <codeclass="docutils literal notranslate"><spanclass="pre">anna_object.get_display_name(looker)</span></code> will be called for every onlooker; this allows the <codeclass="docutils literal notranslate"><spanclass="pre">{anna}</span></code> stanza to be different depending on who sees the strings. How this is to work depends on the <em>stance</em> of your game.</p>
handle the stance is important for a text game. There are two main stances that are usually considered, <em>Actor stance</em> and <em>Director stance</em>.</p>
<p>It’s not unheard of to mix the two stances - with commands from the game being told in Actor stance while Director stance is used for complex emoting and roleplaying. One should usually try to be consistent however.</p>
in roleplaying MUDs where longer roleplaying emotes are used. It is also a pretty simple stance to
implement technically since everyone sees the same text, regardless of viewpoint.</p>
<p>Here’s an example of a flavorful text to show the room:</p>
<divclass="highlight-none notranslate"><divclass="highlight"><pre><span></span>Tom picks up the gun, whistling to himself.
</pre></div>
</div>
<p>Everyone will see this string, both Tom and others. Here’s how to send it to everyone in
the room.</p>
<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="n">text</span><spanclass="o">=</span><spanclass="s2">"Tom picks up the gun, whistling to himself."</span>
<p>One may want to expand on it by making the name <codeclass="docutils literal notranslate"><spanclass="pre">Tom</span></code> be seen differently by different people,
but the English grammar of the sentence does not change. Not only is this pretty easy to do
technically, it’s also easy to write for the player.</p>
</section>
<sectionid="actor-stance">
<h2>Actor Stance<aclass="headerlink"href="#actor-stance"title="Permalink to this headline">¶</a></h2>
<p>This means that the game addresses “you” when it does things. In actor stance, whenever you perform an action, you should get a different message than those <em>observing</em> you doing that action.</p>
<p>Not only do you need to map “Tom” to “You” above, there are also grammatical differences - “Tom walks” vs “You walk” and “himself” vs “yourself”. This is a lot more complex to handle. For a developer making simple “You/Tom pick/picks up the stone” messages, you could in principle hand-craft the strings from every view point, but there’s a better way.</p>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">msg_contents</span></code> method helps by parsing the ingoing string with a <aclass="reference internal"href="../Components/FuncParser.html"><spanclass="doc std std-doc">FuncParser functions</span></a> with some very specific <codeclass="docutils literal notranslate"><spanclass="pre">$inline-functions</span></code>. The inline funcs basically provides you with a mini-language for building <em>one</em> string that will change appropriately depending on who sees it.</p>
<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="n">text</span><spanclass="o">=</span><spanclass="s2">"$You() $conj(pick) up the gun, whistling to $pron(yourself)."</span>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">$You()/$you()</span></code> - this is a reference to ‘you’ in the text. It will be replaced with “You/you” for
the one sending the text and with the return from <codeclass="docutils literal notranslate"><spanclass="pre">caller.get_display_name(looker)</span></code> for everyone else.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">$conj(verb)</span></code> - this will conjugate the given verb depending on who sees the string (like <codeclass="docutils literal notranslate"><spanclass="pre">pick</span></code>
to <codeclass="docutils literal notranslate"><spanclass="pre">picks</span></code>). Enter the root form of the verb.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">$pron(pronoun[,options])</span></code> - A pronoun is a word you want to use instead of a proper noun, like
<em>him</em>, <em>herself</em>, <em>its</em>, <em>me</em>, <em>I</em>, <em>their</em> and so on. The <codeclass="docutils literal notranslate"><spanclass="pre">options</span></code> is a space- or comma-separated
<h3>More on $pron()<aclass="headerlink"href="#more-on-pron"title="Permalink to this headline">¶</a></h3>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">$pron()</span></code> inline func maps between 1st/2nd person (I/you) to 3rd person (he/she etc). In short,
<p>Some mappings are easy. For example, if you write <codeclass="docutils literal notranslate"><spanclass="pre">$pron(yourselves)</span></code> then the 3rd-person form is always <codeclass="docutils literal notranslate"><spanclass="pre">themselves</span></code>. But because English grammar is the way it is, not all mappings are 1:1. For example, if you write <codeclass="docutils literal notranslate"><spanclass="pre">$pron(you)</span></code>, Evennia will not know which 3rd-persion equivalent this should map to - you need to provide more info to help out. This can either be provided as a second space-separated option to <codeclass="docutils literal notranslate"><spanclass="pre">$pron</span></code> or the system will try to figure it out on its own.</p>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">pronoun_type</span></code> - this is one of the columns in the table and can be set as a <codeclass="docutils literal notranslate"><spanclass="pre">$pron</span></code> option.</p>
<p>(There is no need to specify reflexive pronouns since they
are all uniquely mapped 1:1). Speciying the pronoun-type is mainly needed when using <codeclass="docutils literal notranslate"><spanclass="pre">you</span></code>,
since the same ‘you’ is used to represent all sorts of things in English grammar.
If not specified and the mapping is not clear, a ‘subject pronoun’ (he/she/it/they) is assumed.</p>
</li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">gender</span></code> - set in <codeclass="docutils literal notranslate"><spanclass="pre">$pron</span></code> option as</p>
<ulclass="simple">
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">male</span></code>, or <codeclass="docutils literal notranslate"><spanclass="pre">m</span></code></p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">female'</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">f</span></code></p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">neutral</span></code>, or <codeclass="docutils literal notranslate"><spanclass="pre">n</span></code></p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">plural</span></code>, or <codeclass="docutils literal notranslate"><spanclass="pre">p</span></code> (yes plural is considered a ‘gender’ for this purpose).</p></li>
</ul>
<p>If not set as an option the system will
look for a callable or property <codeclass="docutils literal notranslate"><spanclass="pre">.gender</span></code> on the current <codeclass="docutils literal notranslate"><spanclass="pre">from_obj</span></code>. A callable will be called
with no arguments and is expected to return a string ‘male/female/neutral/plural’. If none
is found, a neutral gender is assumed.</p>
</li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">viewpoint</span></code>- set in <codeclass="docutils literal notranslate"><spanclass="pre">$pron</span></code> option as</p>
<p>Note the three last examples - instead of specifying the 2nd person form you can also specify the 3rd-person and do a ‘reverse’ lookup - you will still see the proper 1st/2nd text. So writing <codeclass="docutils literal notranslate"><spanclass="pre">$pron(her)</span></code> instead of <codeclass="docutils literal notranslate"><spanclass="pre">$pron(you,</span><spanclass="pre">op</span><spanclass="pre">f)</span></code> gives the same result.</p>
<p>The <aclass="reference internal"href="../api/evennia.utils.funcparser.html#evennia.utils.funcparser.funcparser_callable_pronoun"title="evennia.utils.funcparser.funcparser_callable_pronoun"><spanclass="xref myst py py-func">$pron inlinefunc api is found here</span></a></p>
<p>There is one more inlinefunc understood by <codeclass="docutils literal notranslate"><spanclass="pre">msg_contents</span></code>. This can be used natively to spruce up
your strings (for both director- and actor stance):</p>
<ulclass="simple">
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">$Obj(name)/$obj(name)</span></code> references another entity, which must be supplied
in the <codeclass="docutils literal notranslate"><spanclass="pre">mapping</span></code> keyword argument to <codeclass="docutils literal notranslate"><spanclass="pre">msg_contents</span></code>. The object’s <codeclass="docutils literal notranslate"><spanclass="pre">.get_display_name(looker)</span></code> will be
called and inserted instead. This is essentially the same as using the <codeclass="docutils literal notranslate"><spanclass="pre">{anna}</span></code> marker we used
in the first example at the top of this page, but using <codeclass="docutils literal notranslate"><spanclass="pre">$Obj/$obj</span></code> allows you to easily
control capitalization.</p></li>
</ul>
<p>This is used like so:</p>
<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># director stance</span>
<spanclass="n">text</span><spanclass="o">=</span><spanclass="s2">"Tom picks up the $obj(gun), whistling to himself"</span>
<spanclass="c1"># actor stance</span>
<spanclass="n">text</span><spanclass="o">=</span><spanclass="s2">"$You() $conj(pick) up the $obj(gun), whistling to $pron(yourself)"</span>
<p>Depending on your game, Tom may now see himself picking up <codeclass="docutils literal notranslate"><spanclass="pre">A</span><spanclass="pre">rusty</span><spanclass="pre">old</span><spanclass="pre">gun</span></code>, whereas an onlooker with a high gun smith skill may instead see him picking up <codeclass="docutils literal notranslate"><spanclass="pre">A</span><spanclass="pre">rare-make</span><spanclass="pre">Smith</span><spanclass="pre">&</span><spanclass="pre">Wesson</span><spanclass="pre">model</span><spanclass="pre">686</span><spanclass="pre">in</span><spanclass="pre">poor</span><spanclass="pre">condition"</span><spanclass="pre">...</span></code></p>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">$funcparser</span></code> inline functions are very powerful for the game developer, but they may
be a bit too much to write for the regular player.</p>
<p>The <aclass="reference internal"href="../api/evennia.contrib.rpg.rpsystem.html#evennia-contrib-rpg-rpsystem"><spanclass="std std-ref">rpsystem contrib</span></a> implements a full dynamic emote/pose and recognition system with short-descriptions and disguises. It uses director stance with a custom markup language, like <codeclass="docutils literal notranslate"><spanclass="pre">/me</span></code><codeclass="docutils literal notranslate"><spanclass="pre">/gun</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">/tall</span><spanclass="pre">man</span></code> to refer to players and objects in the location. It can be worth checking out for inspiration.</p>