<p><em>This page is adopted from an article originally posted for the MUSH community <aclass="reference external"href="https://musoapbox.net/topic/1150/evennia-for-mushers">here on
<p><aclass="reference external"href="https://en.wikipedia.org/wiki/MUSH">MUSH</a>es are text multiplayer games traditionally used for
heavily roleplay-focused game styles. They are often (but not always) utilizing game masters and
human oversight over code automation. MUSHes are traditionally built on the TinyMUSH-family of game
servers, like PennMUSH, TinyMUSH, TinyMUX and RhostMUSH. Also their siblings
<aclass="reference external"href="https://en.wikipedia.org/wiki/TinyMUCK">MUCK</a> and <aclass="reference external"href="https://en.wikipedia.org/wiki/MOO">MOO</a> are
often mentioned together with MUSH since they all inherit from the same
<aclass="reference external"href="https://en.wikipedia.org/wiki/MUD_trees#TinyMUD_family_tree">TinyMUD</a> base. A major feature is the
ability to modify and program the game world from inside the game by using a custom scripting
language. We will refer to this online scripting as <em>softcode</em> here.</p>
<p>Evennia works quite differently from a MUSH both in its overall design and under the hood. The same
things are achievable, just in a different way. Here are some fundamental differences to keep in
<li><p>An Evennia <em>Developer</em> works in Python from <em>outside</em> the game, in what MUSH would consider
“hardcode”. Developers implement larger-scale code changes and can fundamentally change how the game
works. They then load their changes into the running Evennia server. Such changes will usually not
drop any connected players.</p></li>
<li><p>An Evennia <em>Player</em> operates from <em>inside</em> the game. Some staff-level players are likely to double
as developers. Depending on access level, players can modify and expand the game’s world by digging
new rooms, creating new objects, alias commands, customize their experience and so on. Trusted staff
may get access to Python via the <codeclass="docutils literal notranslate"><spanclass="pre">@py</span></code> command, but this would be a security risk for normal Players
to use. So the <em>Player</em> usually operates by making use of the tools prepared for them by the
<em>Developer</em> - tools that can be as rigid or flexible as the developer desires.</p></li>
<h2>Collaborating on a game - Python vs Softcode<aclass="headerlink"href="#collaborating-on-a-game-python-vs-softcode"title="Permalink to this headline">¶</a></h2>
using text tags and <aclass="reference internal"href="../Components/FuncParser.html"><spanclass="doc std std-doc">inline functions</span></a> to prettify and customize the
<h2><codeclass="docutils literal notranslate"><spanclass="pre">@parent</span></code> vs <codeclass="docutils literal notranslate"><spanclass="pre">@typeclass</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">@spawn</span></code><aclass="headerlink"href="#parent-vs-typeclass-and-spawn"title="Permalink to this headline">¶</a></h2>
<p>Inheritance works differently in Python than in softcode. Evennia has no concept of a “master
object” that other objects inherit from. There is in fact no reason at all to introduce “virtual
objects” in the game world - code and data are kept separate from one another.</p>
<p>In Python (which is an <aclass="reference external"href="https://en.wikipedia.org/wiki/Object-oriented_programming">object oriented</a>
language) one instead creates <em>classes</em> - these are like blueprints from which you spawn any number
of <em>object instances</em>. Evennia also adds the extra feature that every instance is persistent in the
database (this means no SQL is ever needed). To take one example, a unique character in Evennia is
an instances of the class <codeclass="docutils literal notranslate"><spanclass="pre">Character</span></code>.</p>
<p>One parallel to MUSH’s <codeclass="docutils literal notranslate"><spanclass="pre">@parent</span></code> command may be Evennia’s <codeclass="docutils literal notranslate"><spanclass="pre">@typeclass</span></code> command, which changes which
class an already existing object is an instance of. This way you can literally turn a <codeclass="docutils literal notranslate"><spanclass="pre">Character</span></code>
into a <codeclass="docutils literal notranslate"><spanclass="pre">Flowerpot</span></code> on the spot.</p>
<p>if you are new to object oriented design it’s important to note that all object instances of a class
does <em>not</em> have to be identical. If they did, all Characters would be named the same. Evennia allows
to customize individual objects in many different ways. One way is through <em>Attributes</em>, which are
database-bound properties that can be linked to any object. For example, you could have an <codeclass="docutils literal notranslate"><spanclass="pre">Orc</span></code>
class that defines all the stuff an Orc should be able to do (probably in turn inheriting from some
<codeclass="docutils literal notranslate"><spanclass="pre">Monster</span></code> class shared by all monsters). Setting different Attributes on different instances
(different strength, equipment, looks etc) would make each Orc unique despite all sharing the same
class.</p>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">@spawn</span></code> command allows one to conveniently choose between different “sets” of Attributes to
put on each new Orc (like the “warrior” set or “shaman” set) . Such sets can even inherit one
another which is again somewhat remniscent at least of the <em>effect</em> of <codeclass="docutils literal notranslate"><spanclass="pre">@parent</span></code> and the object-
based inheritance of MUSH.</p>
<p>There are other differences for sure, but that should give some feel for things. Enough with the
<h2>A first step making things more familiar<aclass="headerlink"href="#a-first-step-making-things-more-familiar"title="Permalink to this headline">¶</a></h2>
<p>We will here give two examples of customizing Evennia to be more familiar to a MUSH <em>Player</em>.</p>
<p>By default Evennia’s <codeclass="docutils literal notranslate"><spanclass="pre">desc</span></code> command updates your description and that’s it. There is a more feature-
rich optional “multi-descer” in <codeclass="docutils literal notranslate"><spanclass="pre">evennia/contrib/multidesc.py</span></code> though. This alternative allows for
managing and combining a multitude of keyed descriptions.</p>
<p>To activate the multi-descer, <codeclass="docutils literal notranslate"><spanclass="pre">cd</span></code> to your game folder and into the <codeclass="docutils literal notranslate"><spanclass="pre">commands</span></code> sub-folder. There
you’ll find the file <codeclass="docutils literal notranslate"><spanclass="pre">default_cmdsets.py</span></code>. In Python lingo all <codeclass="docutils literal notranslate"><spanclass="pre">*.py</span></code> files are called <em>modules</em>.
Open the module in a text editor. We won’t go into Evennia in-game <em>Commands</em> and <em>Command sets</em>
further here, but suffice to say Evennia allows you to change which commands (or versions of
commands) are available to the player from moment to moment depending on circumstance.</p>
<spanclass="c1"># any commands you add below will overload the default ones.</span>
<spanclass="c1">#</span>
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">add</span><spanclass="p">(</span><spanclass="n">multidescer</span><spanclass="o">.</span><spanclass="n">CmdMultiDesc</span><spanclass="p">())</span><spanclass="c1"># <- added now </span>
<p>So what happens above? We <aclass="reference external"href="https://www.linuxtopia.org/online_books/programming_books/python_programming/python_ch28s03.html">import the
<codeclass="docutils literal notranslate"><spanclass="pre">evennia/contrib/multidescer.py</span></code> at the top. Once imported we can access stuff inside that module
using full stop (<codeclass="docutils literal notranslate"><spanclass="pre">.</span></code>). The multidescer is defined as a class <codeclass="docutils literal notranslate"><spanclass="pre">CmdMultiDesc</span></code> (we could find this out
by opening said module in a text editor). At the bottom we create a new instance of this class and
add it to the <codeclass="docutils literal notranslate"><spanclass="pre">CharacterCmdSet</span></code> class. For the sake of this tutorial we only need to know that
<codeclass="docutils literal notranslate"><spanclass="pre">CharacterCmdSet</span></code> contains all commands that should be be available to the <codeclass="docutils literal notranslate"><spanclass="pre">Character</span></code> by default.</p>
<p>This whole thing will be triggered when the command set is first created, which happens on server
start. So we need to reload Evennia with <codeclass="docutils literal notranslate"><spanclass="pre">@reload</span></code> - no one will be disconnected by doing this. If
all went well you should now be able to use <codeclass="docutils literal notranslate"><spanclass="pre">desc</span></code> (or <codeclass="docutils literal notranslate"><spanclass="pre">+desc</span></code>) and find that you have more
<p>If there are errors, a <em>traceback</em> will show in the server log - several lines of text showing
where the error occurred. Find where the error is by locating the line number related to the
<codeclass="docutils literal notranslate"><spanclass="pre">default_cmdsets.py</span></code> file (it’s the only one you’ve changed so far). Most likely you mis-spelled
something or missed the indentation. Fix it and either <codeclass="docutils literal notranslate"><spanclass="pre">@reload</span></code> again or run <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span><spanclass="pre">start</span></code> as
<p>As seen above the multidescer uses syntax like this (where <codeclass="docutils literal notranslate"><spanclass="pre">|/</span></code> are Evennia’s tags for line breaks)
<p>This use of <codeclass="docutils literal notranslate"><spanclass="pre">+</span></code> was prescribed by the <em>Developer</em> that coded this <codeclass="docutils literal notranslate"><spanclass="pre">+desc</span></code> command. What if the
<em>Player</em> doesn’t like this syntax though? Do players need to pester the dev to change it? Not
necessarily. While Evennia does not allow the player to build their own multi-descer on the command
line, it does allow for <em>re-mapping</em> the command syntax to one they prefer. This is done using the
<p>The string on the left will be matched against your input and if matching, it will be replaced with
the string on the right. The <codeclass="docutils literal notranslate"><spanclass="pre">$</span></code>-type tags will store space-separated arguments and put them into
the replacement. The nick allows <aclass="reference external"href="http://www.linfo.org/wildcard.html">shell-like wildcards</a>, so you
can use <codeclass="docutils literal notranslate"><spanclass="pre">*</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">?</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">[...]</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">[!...]</span></code> etc to match parts of the input.</p>
<p>With the <codeclass="docutils literal notranslate"><spanclass="pre">nick</span></code> functionality players can mitigate a lot of syntax dislikes even without the
developer changing the underlying Python code.</p>
to look into the Evennia <aclass="reference internal"href="Starting/Part3/Tutorial-for-basic-MUSH-like-game.html"><spanclass="doc std std-doc">Tutorial for a first MUSH-like game</span></a>.
Tutorial). You may also find it useful to shop through the <codeclass="docutils literal notranslate"><spanclass="pre">evennia/contrib/</span></code> folder. The
<aclass="reference internal"href="Starting/Part1/Tutorial-World.html"><spanclass="doc std std-doc">Tutorial world</span></a> is a small single-player quest you can try (it’s not very MUSH-
like but it does show many Evennia concepts in action). Beyond that there are <aclass="reference internal"href="Howto-Overview.html"><spanclass="doc std std-doc">many more tutorials</span></a>
<p>… And of course, if you need further help you can always drop into the <aclass="reference external"href="https://webchat.freenode.net/?channels=evennia&uio=MT1mYWxzZSY5PXRydWUmMTE9MTk1JjEyPXRydWUbb">Evennia