<p>This extends the normal <codeclass="docutils literal notranslate"><spanclass="pre">Room</span></code> typeclass to allow its description to change with
time-of-day and/or season as well as any other state (like flooded or dark).
Embedding <codeclass="docutils literal notranslate"><spanclass="pre">$state(burning,</span><spanclass="pre">This</span><spanclass="pre">place</span><spanclass="pre">is</span><spanclass="pre">on</span><spanclass="pre">fire!)</span></code> in the description will
allow for changing the description based on room state. The room also supports
<codeclass="docutils literal notranslate"><spanclass="pre">details</span></code> for the player to look at in the room (without having to create a new
in-game object for each), as well as support for random echoes. The room
comes with a set of alternate commands for <codeclass="docutils literal notranslate"><spanclass="pre">look</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">@desc</span></code>, as well as new
<p>Then reload to make the new commands available. Note that they only work
on rooms with the typeclass <codeclass="docutils literal notranslate"><spanclass="pre">ExtendedRoom</span></code>. Create new rooms with the right
typeclass or use the <codeclass="docutils literal notranslate"><spanclass="pre">typeclass</span></code> command to swap existing rooms. Note that since
this contrib overrides the <codeclass="docutils literal notranslate"><spanclass="pre">look</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">@desc</span></code> commands, you will need to add the
<codeclass="docutils literal notranslate"><spanclass="pre">extended_room.ExtendedRoomCmdSet</span></code> to the default character cmdset <em>after</em>
<codeclass="docutils literal notranslate"><spanclass="pre">super().at_cmdset_creation()</span></code>, or they will be overridden by the default look.</p>
<p>To make all new rooms ExtendedRooms without having to specify it, make your
<codeclass="docutils literal notranslate"><spanclass="pre">Room</span></code> typeclass inherit from the <codeclass="docutils literal notranslate"><spanclass="pre">ExtendedRoom</span></code> and then reload:</p>
<divclass="highlight-python notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># in mygame/typeclasses/rooms.py</span>
<h2>Features<aclass="headerlink"href="#features"title="Permalink to this headline">¶</a></h2>
<sectionid="state-dependent-description-slots">
<h3>State-dependent description slots<aclass="headerlink"href="#state-dependent-description-slots"title="Permalink to this headline">¶</a></h3>
<p>By default, the normal <codeclass="docutils literal notranslate"><spanclass="pre">room.db.desc</span></code> description is used. You can however
add new state-ful descriptions with <codeclass="docutils literal notranslate"><spanclass="pre">room.add_desc(description,</span><spanclass="pre">room_state=roomstate)</span></code> or with the in-game command</p>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span>@desc/dark This room is pitch black.`.
</pre></div>
</div>
<p>These will be stored in Attributes <codeclass="docutils literal notranslate"><spanclass="pre">desc_<roomstate></span></code>. To set the default,
fallback description, just use <codeclass="docutils literal notranslate"><spanclass="pre">@desc</span><spanclass="pre"><description></span></code>.
To activate a state on the room, use <codeclass="docutils literal notranslate"><spanclass="pre">room.add/remove_state(*roomstate)</span></code> or the in-game
<p>There is one in-built, time-based state <codeclass="docutils literal notranslate"><spanclass="pre">season</span></code>. By default these are ‘spring’,
‘summer’, ‘autumn’ and ‘winter’. The <codeclass="docutils literal notranslate"><spanclass="pre">room.get_season()</span></code> method returns the
current season based on the in-game time. By default they change with a 12-month
in-game time schedule. You can control them with</p>
<spanclass="n">ExtendedRoom</span><spanclass="o">.</span><spanclass="n">seasons_per</span><spanclass="n">year</span><spanclass="c1"># a dict of {"season": (start, end), ...} where</span>
<spanclass="c1"># start/end are given in fractions of the whole year</span>
</pre></div>
</div>
<p>To set a seasonal description, just set it as normal, with <codeclass="docutils literal notranslate"><spanclass="pre">room.add_desc</span></code> or
<p>If you set the season manually like this, it won’t change automatically again
until you unset it.</p>
<p>You can get the stateful description from the room with <codeclass="docutils literal notranslate"><spanclass="pre">room.get_stateful_desc()</span></code>.</p>
<h3>Changing parts of description based on state<aclass="headerlink"href="#changing-parts-of-description-based-on-state"title="Permalink to this headline">¶</a></h3>
<p>All descriptions can have embedded <codeclass="docutils literal notranslate"><spanclass="pre">$state(roomstate,</span><spanclass="pre">description)</span></code>
<aclass="reference internal"href="../Components/FuncParser.html"><spanclass="doc std std-doc">FuncParser tags</span></a> embedded in them. Here is an example:</p>
<divclass="highlight-py notranslate"><divclass="highlight"><pre><span></span><spanclass="n">room</span><spanclass="o">.</span><spanclass="n">add_desc</span><spanclass="p">(</span><spanclass="s2">"This a nice beach. "</span>
<spanclass="s2">"$state(empty, It is completely empty)"</span>
<spanclass="s2">"$state(full, It is full of people)."</span><spanclass="p">,</span><spanclass="n">room_state</span><spanclass="o">=</span><spanclass="s2">"summer"</span><spanclass="p">)</span>
</pre></div>
</div>
<p>This is a summer-description with special embedded strings. If you set the room
<p>You use these inside descriptions as normal:</p>
<divclass="highlight-none notranslate"><divclass="highlight"><pre><span></span>"A glade. $(morning, The morning sun shines down through the branches)."
</pre></div>
</div>
</section>
<sectionid="details">
<h3>Details<aclass="headerlink"href="#details"title="Permalink to this headline">¶</a></h3>
<p><em>Details</em> are “virtual” targets to look at in a room, without having to create a
new database instance for every thing. It’s good to add more information to a
location. The details are stored as strings in a dictionary.</p>
<divclass="highlight-none notranslate"><divclass="highlight"><pre><span></span>detail window = There is a window leading out.
detail rock = The rock has a text written on it: 'Do not dare lift me'.
</pre></div>
</div>
<p>When you are in the room you can then do <codeclass="docutils literal notranslate"><spanclass="pre">look</span><spanclass="pre">window</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">look</span><spanclass="pre">rock</span></code> and get
the matching detail-description. This requires the new custom <codeclass="docutils literal notranslate"><spanclass="pre">look</span></code> command.</p>
</section>
<sectionid="random-echoes">
<h3>Random echoes<aclass="headerlink"href="#random-echoes"title="Permalink to this headline">¶</a></h3>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">ExtendedRoom</span></code> supports random echoes. Just set them as an Attribute list
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="n">room</span><spanclass="o">.</span><spanclass="n">room_message_rate</span><spanclass="o">=</span><spanclass="mi">120</span><spanclass="c1"># in seconds. 0 to disable</span>
<spanclass="n">room</span><spanclass="o">.</span><spanclass="n">db</span><spanclass="o">.</span><spanclass="n">room_messages</span><spanclass="o">=</span><spanclass="p">[</span><spanclass="s2">"A car passes by."</span><spanclass="p">,</span><spanclass="s2">"You hear the sound of car horns."</span><spanclass="p">]</span>
<spanclass="n">room</span><spanclass="o">.</span><spanclass="n">start_repeat_broadcast_messages</span><spanclass="p">()</span><spanclass="c1"># also a server reload works</span>
</pre></div>
</div>
<p>These will start randomly echoing to the room every 120s.</p>
</section>
<sectionid="extra-commands">
<h3>Extra commands<aclass="headerlink"href="#extra-commands"title="Permalink to this headline">¶</a></h3>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">CmdExtendedRoomDetail</span></code> (<codeclass="docutils literal notranslate"><spanclass="pre">detail</span></code>) - list and manipulate room details</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">CmdExtendedRoomGameTime</span></code> (<codeclass="docutils literal notranslate"><spanclass="pre">time</span></code>) - Shows the current time and season in the room.</p></li>
</ul>
<hrclass="docutils"/>
<p><small>This document page is generated from <codeclass="docutils literal notranslate"><spanclass="pre">evennia/contrib/grid/extended_room/README.md</span></code>. Changes to this
file will be overwritten, so edit that file rather than this one.</small></p>