mirror of
https://github.com/evennia/evennia.git
synced 2026-03-21 23:36:30 +01:00
Updated HTML docs.
This commit is contained in:
parent
cf88322ffe
commit
e078081850
55 changed files with 237 additions and 2301 deletions
|
|
@ -17,8 +17,8 @@
|
|||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Continuous Integration (CI)" href="Continuous-Integration.html" />
|
||||
<link rel="prev" title="Quirks" href="Quirks.html" />
|
||||
<link rel="next" title="Contribs" href="../Contribs/Contribs-Overview.html" />
|
||||
<link rel="prev" title="Setting up PyCharm with Evennia" href="Setting-up-PyCharm.html" />
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
|
|
@ -30,10 +30,10 @@
|
|||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Continuous-Integration.html" title="Continuous Integration (CI)"
|
||||
<a href="../Contribs/Contribs-Overview.html" title="Contribs"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Quirks.html" title="Quirks"
|
||||
<a href="Setting-up-PyCharm.html" title="Setting up PyCharm with Evennia"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" accesskey="U">Coding and development help</a> »</li>
|
||||
|
|
@ -125,11 +125,11 @@
|
|||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="Quirks.html"
|
||||
title="previous chapter">Quirks</a></p>
|
||||
<p class="topless"><a href="Setting-up-PyCharm.html"
|
||||
title="previous chapter">Setting up PyCharm with Evennia</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="Continuous-Integration.html"
|
||||
title="next chapter">Continuous Integration (CI)</a></p>
|
||||
<p class="topless"><a href="../Contribs/Contribs-Overview.html"
|
||||
title="next chapter">Contribs</a></p>
|
||||
<div role="note" aria-label="source link">
|
||||
<!--h3>This Page</h3-->
|
||||
<ul class="this-page-menu">
|
||||
|
|
@ -1080,10 +1080,10 @@ and have no changelogs.</p>
|
|||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Continuous-Integration.html" title="Continuous Integration (CI)"
|
||||
<a href="../Contribs/Contribs-Overview.html" title="Contribs"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Quirks.html" title="Quirks"
|
||||
<a href="Setting-up-PyCharm.html" title="Setting up PyCharm with Evennia"
|
||||
>previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" >Coding and development help</a> »</li>
|
||||
|
|
|
|||
|
|
@ -1,402 +0,0 @@
|
|||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||||
|
||||
<title>Coding FAQ — Evennia 1.0-dev documentation</title>
|
||||
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/language_data.js"></script>
|
||||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Quirks" href="Quirks.html" />
|
||||
<link rel="prev" title="Evennia Code Style" href="Evennia-Code-Style.html" />
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Quirks.html" title="Quirks"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Evennia-Code-Style.html" title="Evennia Code Style"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" accesskey="U">Coding and development help</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Coding FAQ</a></li>
|
||||
</ul>
|
||||
<div class="develop">develop branch</div>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
|
||||
<div class="documentwrapper">
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../index.html">
|
||||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
<h3><a href="../index.html">Table of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">Coding FAQ</a><ul>
|
||||
<li><a class="reference internal" href="#removing-default-commands">Removing default commands</a></li>
|
||||
<li><a class="reference internal" href="#preventing-character-from-moving-based-on-a-condition">Preventing character from moving based on a condition</a></li>
|
||||
<li><a class="reference internal" href="#reference-initiating-object-in-an-evmenu-command">Reference initiating object in an EvMenu command.</a></li>
|
||||
<li><a class="reference internal" href="#selectively-turn-off-commands-in-a-room">Selectively turn off commands in a room</a></li>
|
||||
<li><a class="reference internal" href="#select-command-based-on-a-condition">Select Command based on a condition</a></li>
|
||||
<li><a class="reference internal" href="#automatically-updating-code-when-reloading">Automatically updating code when reloading</a></li>
|
||||
<li><a class="reference internal" href="#changing-all-exit-messages">Changing all exit messages</a></li>
|
||||
<li><a class="reference internal" href="#add-parsing-with-the-to-delimiter">Add parsing with the “to” delimiter</a></li>
|
||||
<li><a class="reference internal" href="#non-latin-characters-in-evtable">Non-latin characters in EvTable</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="Evennia-Code-Style.html"
|
||||
title="previous chapter">Evennia Code Style</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="Quirks.html"
|
||||
title="next chapter">Quirks</a></p>
|
||||
<div role="note" aria-label="source link">
|
||||
<!--h3>This Page</h3-->
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../_sources/Coding/Coding-FAQ.md.txt"
|
||||
rel="nofollow">Show Page Source</a></li>
|
||||
</ul>
|
||||
</div><h3>Links</h3>
|
||||
<ul>
|
||||
<li><a href="https://www.evennia.com">Home page</a> </li>
|
||||
<li><a href="https://github.com/evennia/evennia">Evennia Github</a> </li>
|
||||
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
||||
<li>
|
||||
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
||||
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
||||
<a href="https://evennia.blogspot.com/">Blog</a>
|
||||
</li>
|
||||
</ul>
|
||||
<h3>Versions</h3>
|
||||
<ul>
|
||||
<li><a href="Coding-FAQ.html">1.0-dev (develop branch)</a></li>
|
||||
<ul>
|
||||
<li><a href="../0.9.5/index.html">0.9.5 (v0.9.5 branch)</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section class="tex2jax_ignore mathjax_ignore" id="coding-faq">
|
||||
<h1>Coding FAQ<a class="headerlink" href="#coding-faq" title="Permalink to this headline">¶</a></h1>
|
||||
<p><em>This FAQ page is for users to share their solutions to coding problems. Keep it brief and link to
|
||||
the docs if you can rather than too lengthy explanations. Don’t forget to check if an answer already
|
||||
exists before answering - maybe you can clarify that answer rather than to make a new Q&A section.</em></p>
|
||||
<section id="removing-default-commands">
|
||||
<h2>Removing default commands<a class="headerlink" href="#removing-default-commands" title="Permalink to this headline">¶</a></h2>
|
||||
<p><strong>Q:</strong> How does one <em>remove</em> (not replace) e.g. the default <code class="docutils literal notranslate"><span class="pre">get</span></code> <a class="reference internal" href="../Components/Commands.html"><span class="doc std std-doc">Command</span></a> from the Character <a class="reference internal" href="../Components/Command-Sets.html"><span class="doc std std-doc">Command Set</span></a>?</p>
|
||||
<p><strong>A:</strong> Go to <code class="docutils literal notranslate"><span class="pre">mygame/commands/default_cmdsets.py</span></code>. Find the <code class="docutils literal notranslate"><span class="pre">CharacterCmdSet</span></code> class. It has one
|
||||
method named <code class="docutils literal notranslate"><span class="pre">at_cmdset_creation</span></code>. At the end of that method, add the following line:
|
||||
<code class="docutils literal notranslate"><span class="pre">self.remove(default_cmds.CmdGet())</span></code>. See the <a class="reference internal" href="../Howtos/Beginner-Tutorial/Part1/Beginner-Tutorial-Adding-Commands.html"><span class="doc std std-doc">Adding Commands Tutorial</span></a>
|
||||
for more info.</p>
|
||||
</section>
|
||||
<section id="preventing-character-from-moving-based-on-a-condition">
|
||||
<h2>Preventing character from moving based on a condition<a class="headerlink" href="#preventing-character-from-moving-based-on-a-condition" title="Permalink to this headline">¶</a></h2>
|
||||
<p><strong>Q:</strong> How does one keep a character from using any exit, if they meet a certain condition? (I.E. in
|
||||
combat, immobilized, etc.)</p>
|
||||
<p><strong>A:</strong> The <code class="docutils literal notranslate"><span class="pre">at_pre_move</span></code> hook is called by Evennia just before performing any move. If it returns
|
||||
<code class="docutils literal notranslate"><span class="pre">False</span></code>, the move is aborted. Let’s say we want to check for an <a class="reference internal" href="../Components/Attributes.html"><span class="doc std std-doc">Attribute</span></a> <code class="docutils literal notranslate"><span class="pre">cantmove</span></code>.
|
||||
Add the following code to the <code class="docutils literal notranslate"><span class="pre">Character</span></code> class:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">at_pre_move</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">destination</span><span class="p">):</span>
|
||||
<span class="s2">"Called just before trying to move"</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">cantmove</span><span class="p">:</span> <span class="c1"># replace with condition you want to test</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">"Something is preventing you from moving!"</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="kc">False</span>
|
||||
<span class="k">return</span> <span class="kc">True</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="reference-initiating-object-in-an-evmenu-command">
|
||||
<h2>Reference initiating object in an EvMenu command.<a class="headerlink" href="#reference-initiating-object-in-an-evmenu-command" title="Permalink to this headline">¶</a></h2>
|
||||
<p><strong>Q:</strong> An object has a Command on it starts up an EvMenu instance. How do I capture a reference to
|
||||
that object for use in the menu?</p>
|
||||
<p><strong>A:</strong> When an <a class="reference internal" href="../Components/EvMenu.html"><span class="doc std std-doc">EvMenu</span></a> is started, the menu object is stored as <code class="docutils literal notranslate"><span class="pre">caller.ndb._evmenu</span></code>.
|
||||
This is a good place to store menu-specific things since it will clean itself up when the menu
|
||||
closes. When initiating the menu, any additional keywords you give will be available for you as
|
||||
properties on this menu object:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyObjectCommand</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
|
||||
<span class="c1"># A Command stored on an object (the object is always accessible from</span>
|
||||
<span class="c1"># the Command as self.obj)</span>
|
||||
<span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="c1"># add the object as the stored_obj menu property</span>
|
||||
<span class="n">EvMenu</span><span class="p">(</span><span class="n">caller</span><span class="p">,</span> <span class="o">...</span><span class="p">,</span> <span class="n">stored_obj</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">obj</span><span class="p">)</span>
|
||||
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Inside the menu you can now access the object through <code class="docutils literal notranslate"><span class="pre">caller.ndb._evmenu.stored_obj</span></code>.</p>
|
||||
</section>
|
||||
<section id="selectively-turn-off-commands-in-a-room">
|
||||
<h2>Selectively turn off commands in a room<a class="headerlink" href="#selectively-turn-off-commands-in-a-room" title="Permalink to this headline">¶</a></h2>
|
||||
<p><strong>Q:</strong> I want certain commands to turn off in a given room. They should still work normally for
|
||||
staff.</p>
|
||||
<p><strong>A:</strong> This is done using a custom cmdset on a room <a class="reference internal" href="../Components/Locks.html"><span class="doc std std-doc">locked with the ‘call’ lock type</span></a>. Only
|
||||
if this lock is passed will the commands on the room be made available to an object inside it. Here
|
||||
is an example of a room where certain commands are disabled for non-staff:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/typeclasses/rooms.py</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">default_commands</span><span class="p">,</span> <span class="n">CmdSet</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">CmdBlocking</span><span class="p">(</span><span class="n">default_commands</span><span class="o">.</span><span class="n">MuxCommand</span><span class="p">):</span>
|
||||
<span class="c1"># block commands give, get, inventory and drop</span>
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="s2">"give"</span>
|
||||
<span class="n">aliases</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"get"</span><span class="p">,</span> <span class="s2">"inventory"</span><span class="p">,</span> <span class="s2">"drop"</span><span class="p">]</span>
|
||||
<span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">caller</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">"You cannot do that in this room."</span><span class="p">)</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">BlockingCmdSet</span><span class="p">(</span><span class="n">CmdSet</span><span class="p">):</span>
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="s2">"blocking_cmdset"</span>
|
||||
<span class="c1"># default commands have prio 0</span>
|
||||
<span class="n">priority</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="k">def</span> <span class="nf">at_cmdset_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">CmdBlocking</span><span class="p">())</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">BlockingRoom</span><span class="p">(</span><span class="n">Room</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">at_object_creation</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">cmdset</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">BlockingCmdSet</span><span class="p">,</span> <span class="n">persistent</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="c1"># only share commands with players in the room that</span>
|
||||
<span class="c1"># are NOT Builders or higher</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">locks</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"call:not perm(Builders)"</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>After <code class="docutils literal notranslate"><span class="pre">reload</span></code>, make some <code class="docutils literal notranslate"><span class="pre">BlockingRooms</span></code> (or switch a room to it with <code class="docutils literal notranslate"><span class="pre">@typeclass</span></code>). Entering one
|
||||
will now replace the given commands for anyone that does not have the <code class="docutils literal notranslate"><span class="pre">Builders</span></code> or higher
|
||||
permission. Note that the ‘call’ lock is special in that even the superuser will be affected by it
|
||||
(otherwise superusers would always see other player’s cmdsets and a game would be unplayable for superusers).</p>
|
||||
</section>
|
||||
<section id="select-command-based-on-a-condition">
|
||||
<h2>Select Command based on a condition<a class="headerlink" href="#select-command-based-on-a-condition" title="Permalink to this headline">¶</a></h2>
|
||||
<p><strong>Q:</strong> I want a command to be available only based on a condition. For example I want the “werewolf”
|
||||
command to only be available on a full moon, from midnight to three in-game time.</p>
|
||||
<p><strong>A:</strong> This is easiest accomplished by putting the “werewolf” command on the Character as normal, but to <a class="reference internal" href="../Components/Locks.html"><span class="doc std std-doc">lock</span></a> it with the “cmd” type lock. Only if the “cmd” lock type is passed will the
|
||||
command be available.</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/commands/command.py</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">Command</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">CmdWerewolf</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="s2">"werewolf"</span>
|
||||
<span class="c1"># lock full moon, between 00:00 (midnight) and 03:00.</span>
|
||||
<span class="n">locks</span> <span class="o">=</span> <span class="s2">"cmd:is_full_moon(0, 3)"</span>
|
||||
<span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="c1"># ...</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Add this to the <a class="reference internal" href="../Howtos/Beginner-Tutorial/Part1/Beginner-Tutorial-Adding-Commands.html"><span class="doc std std-doc">default cmdset as usual</span></a>. The <code class="docutils literal notranslate"><span class="pre">is_full_moon</span></code> <a class="reference internal" href="../Components/Locks.html#lock-functions"><span class="std std-doc">lock function</span></a> does not yet exist. We must create that:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># in mygame/server/conf/lockfuncs.py</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">is_full_moon</span><span class="p">(</span><span class="n">accessing_obj</span><span class="p">,</span> <span class="n">accessed_obj</span><span class="p">,</span>
|
||||
<span class="n">starthour</span><span class="p">,</span> <span class="n">endhour</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="c1"># calculate if the moon is full here and</span>
|
||||
<span class="c1"># if current game time is between starthour and endhour</span>
|
||||
<span class="c1"># return True or False</span>
|
||||
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>After a <code class="docutils literal notranslate"><span class="pre">reload</span></code>, the <code class="docutils literal notranslate"><span class="pre">werewolf</span></code> command will be available only at the right time, that is when the
|
||||
<code class="docutils literal notranslate"><span class="pre">is_full_moon</span></code> lock function returns True.</p>
|
||||
</section>
|
||||
<section id="automatically-updating-code-when-reloading">
|
||||
<h2>Automatically updating code when reloading<a class="headerlink" href="#automatically-updating-code-when-reloading" title="Permalink to this headline">¶</a></h2>
|
||||
<p><strong>Q:</strong> I have a development server running Evennia. Can I have the server update its code-base when
|
||||
I reload?</p>
|
||||
<p><strong>A:</strong> Having a development server that pulls updated code whenever you reload it can be really
|
||||
useful if you have limited shell access to your server, or want to have it done automatically. If
|
||||
you have your project in a configured Git environment, it’s a matter of automatically calling <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">pull</span></code> when you reload. And that’s pretty straightforward:</p>
|
||||
<p>In <code class="docutils literal notranslate"><span class="pre">/server/conf/at_server_startstop.py</span></code>:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">subprocess</span>
|
||||
|
||||
<span class="c1"># ... other hooks ...</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">at_server_reload_stop</span><span class="p">():</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> This is called only time the server stops before a reload.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"Pulling from the game repository..."</span><span class="p">)</span>
|
||||
<span class="n">process</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">call</span><span class="p">([</span><span class="s2">"git"</span><span class="p">,</span> <span class="s2">"pull"</span><span class="p">],</span> <span class="n">shell</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>That’s all. We call <code class="docutils literal notranslate"><span class="pre">subprocess</span></code> to execute a shell command (that code works on Windows and Linux, assuming the current directory is your game directory, which is probably the case when you run Evennia). <code class="docutils literal notranslate"><span class="pre">call</span></code> waits for the process to complete, because otherwise, Evennia would reload on partially-modified code, which would be problematic.</p>
|
||||
<p>Now, when you enter <code class="docutils literal notranslate"><span class="pre">reload</span></code> on your development server, the game repository is updated from the configured remote repository (Github, for instance). Your development cycle could resemble something like:</p>
|
||||
<ol class="simple">
|
||||
<li><p>Coding on the local machine.</p></li>
|
||||
<li><p>Testing modifications.</p></li>
|
||||
<li><p>Committing once, twice or more (being sure the code is still working, unittests are pretty useful here).</p></li>
|
||||
<li><p>When the time comes, login to the development server and run <code class="docutils literal notranslate"><span class="pre">@reload</span></code>.</p></li>
|
||||
</ol>
|
||||
<p>The reloading might take one or two additional seconds, since Evennia will pull from your remote Git repository. But it will reload on it and you will have your modifications ready, without needing
|
||||
connecting to your server using SSH or something similar.</p>
|
||||
</section>
|
||||
<section id="changing-all-exit-messages">
|
||||
<h2>Changing all exit messages<a class="headerlink" href="#changing-all-exit-messages" title="Permalink to this headline">¶</a></h2>
|
||||
<p><strong>Q:</strong> How can I change the default exit messages to something like “XXX leaves east” or “XXX
|
||||
arrives from the west”?</p>
|
||||
<p><strong>A:</strong> the default exit messages are stored in two hooks, namely <code class="docutils literal notranslate"><span class="pre">announce_move_from</span></code> and <code class="docutils literal notranslate"><span class="pre">announce_move_to</span></code>, on the <code class="docutils literal notranslate"><span class="pre">Character</span></code> typeclass (if what you want to change is the message other characters will see when a character exits).</p>
|
||||
<p>These two hooks provide some useful features to easily update the message to be displayed. They take both the default message and mapping as argument. You can easily call the parent hook with these information:</p>
|
||||
<ul class="simple">
|
||||
<li><p>The message represents the string of characters sent to characters in the room when a character leaves.</p></li>
|
||||
<li><p>The mapping is a dictionary containing additional mappings (you will probably not need it for simple customization).</p></li>
|
||||
</ul>
|
||||
<p>It is advisable to look in the <a class="reference internal" href="../api/evennia.objects.objects.html#evennia.objects.objects.DefaultCharacter" title="evennia.objects.objects.DefaultCharacter"><span class="xref myst py py-class">code of both hooks</span></a>, and read the hooks’ documentation. The explanations on how to quickly update the message are shown below:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># In typeclasses/characters.py</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd">Characters</span>
|
||||
|
||||
<span class="sd">"""</span>
|
||||
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">DefaultCharacter</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">Character</span><span class="p">(</span><span class="n">DefaultCharacter</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> The default character class.</span>
|
||||
|
||||
<span class="sd"> ...</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">announce_move_from</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">destination</span><span class="p">,</span> <span class="n">msg</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">mapping</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Called if the move is to be announced. This is</span>
|
||||
<span class="sd"> called while we are still standing in the old</span>
|
||||
<span class="sd"> location.</span>
|
||||
|
||||
<span class="sd"> Args:</span>
|
||||
<span class="sd"> destination (Object): The place we are going to.</span>
|
||||
<span class="sd"> msg (str, optional): a replacement message.</span>
|
||||
<span class="sd"> mapping (dict, optional): additional mapping objects.</span>
|
||||
|
||||
<span class="sd"> You can override this method and call its parent with a</span>
|
||||
<span class="sd"> message to simply change the default message. In the string,</span>
|
||||
<span class="sd"> you can use the following as mappings (between braces):</span>
|
||||
<span class="sd"> object: the object which is moving.</span>
|
||||
<span class="sd"> exit: the exit from which the object is moving (if found).</span>
|
||||
<span class="sd"> origin: the location of the object before the move.</span>
|
||||
<span class="sd"> destination: the location of the object after moving.</span>
|
||||
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">announce_move_from</span><span class="p">(</span><span class="n">destination</span><span class="p">,</span> <span class="n">msg</span><span class="o">=</span><span class="s2">"</span><span class="si">{object}</span><span class="s2"> leaves </span><span class="si">{exit}</span><span class="s2">."</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">announce_move_to</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">source_location</span><span class="p">,</span> <span class="n">msg</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">mapping</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Called after the move if the move was not quiet. At this point</span>
|
||||
<span class="sd"> we are standing in the new location.</span>
|
||||
|
||||
<span class="sd"> Args:</span>
|
||||
<span class="sd"> source_location (Object): The place we came from</span>
|
||||
<span class="sd"> msg (str, optional): the replacement message if location.</span>
|
||||
<span class="sd"> mapping (dict, optional): additional mapping objects.</span>
|
||||
|
||||
<span class="sd"> You can override this method and call its parent with a</span>
|
||||
<span class="sd"> message to simply change the default message. In the string,</span>
|
||||
<span class="sd"> you can use the following as mappings (between braces):</span>
|
||||
<span class="sd"> object: the object which is moving.</span>
|
||||
<span class="sd"> exit: the exit from which the object is moving (if found).</span>
|
||||
<span class="sd"> origin: the location of the object before the move.</span>
|
||||
<span class="sd"> destination: the location of the object after moving.</span>
|
||||
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">announce_move_to</span><span class="p">(</span><span class="n">source_location</span><span class="p">,</span> <span class="n">msg</span><span class="o">=</span><span class="s2">"</span><span class="si">{object}</span><span class="s2"> arrives from the </span><span class="si">{exit}</span><span class="s2">."</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>We override both hooks, but call the parent hook to display a different message. If you read the provided docstrings, you will better understand why and how we use mappings (information between braces). You can provide additional mappings as well, if you want to set a verb to move, for instance, or other, extra information.</p>
|
||||
</section>
|
||||
<section id="add-parsing-with-the-to-delimiter">
|
||||
<h2>Add parsing with the “to” delimiter<a class="headerlink" href="#add-parsing-with-the-to-delimiter" title="Permalink to this headline">¶</a></h2>
|
||||
<p><strong>Q:</strong> How do I change commands to undestand say <code class="docutils literal notranslate"><span class="pre">give</span> <span class="pre">obj</span> <span class="pre">to</span> <span class="pre">target</span></code> as well as the default <code class="docutils literal notranslate"><span class="pre">give</span> <span class="pre">obj</span> <span class="pre">=</span> <span class="pre">target</span></code>?</p>
|
||||
<p><strong>A:</strong> You can make change the default <code class="docutils literal notranslate"><span class="pre">MuxCommand</span></code> parent with your own class making a small change in its <code class="docutils literal notranslate"><span class="pre">parse</span></code> method:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="c1"># in mygame/commands/command.py</span>
|
||||
<span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">default_cmds</span>
|
||||
<span class="k">class</span> <span class="nc">MuxCommand</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">MuxCommand</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">parse</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Implement an additional parsing of 'to'"""</span>
|
||||
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">parse</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="s2">" to "</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lhs</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rhs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" to "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Next you change the parent of the default commands in settings:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="n">COMMAND_DEFAULT_CLASS</span> <span class="o">=</span> <span class="s2">"commands.command.MuxCommand"</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Do a <code class="docutils literal notranslate"><span class="pre">reload</span></code> and all default commands will now use your new tweaked parent class. A copy of the
|
||||
MuxCommand class is also found commented-out in the <code class="docutils literal notranslate"><span class="pre">mygame/commands/command.py</span></code> file.</p>
|
||||
</section>
|
||||
<section id="non-latin-characters-in-evtable">
|
||||
<h2>Non-latin characters in EvTable<a class="headerlink" href="#non-latin-characters-in-evtable" title="Permalink to this headline">¶</a></h2>
|
||||
<p><strong>Q:</strong> When using e.g. Chinese characters in EvTable, some lines appear to be too wide, for example</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">+------+------+</span>
|
||||
<span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||||
<span class="o">|</span> <span class="n">测试</span> <span class="o">|</span> <span class="n">测试</span> <span class="o">|</span>
|
||||
<span class="o">|</span> <span class="o">|</span> <span class="o">|</span>
|
||||
<span class="o">+~~~~~~+~~~~~~+</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p><strong>A:</strong> The reason for this is because certain non-latin characters are <em>visually</em> much wider than their len() suggests. There is little Evennia can (reliably) do about this. If you are using such characters, you need to make sure to use a suitable mono-spaced font where are width are equal. You can set this in your web client and need to recommend it for telnet-client users. See <a class="reference external" href="https://github.com/evennia/evennia/issues/1522">this discussion</a> where some suitable fonts are suggested.</p>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Quirks.html" title="Quirks"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Evennia-Code-Style.html" title="Evennia Code Style"
|
||||
>previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" >Coding and development help</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Coding FAQ</a></li>
|
||||
</ul>
|
||||
<div class="develop">develop branch</div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, The Evennia developer community.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Coding using Version Control" href="Version-Control.html" />
|
||||
<link rel="next" title="Evennia Code Style" href="Evennia-Code-Style.html" />
|
||||
<link rel="prev" title="Web Features" href="../Concepts/Web-Features.html" />
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Version-Control.html" title="Coding using Version Control"
|
||||
<a href="Evennia-Code-Style.html" title="Evennia Code Style"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="../Concepts/Web-Features.html" title="Web Features"
|
||||
|
|
@ -63,7 +63,6 @@
|
|||
<ul>
|
||||
<li><a class="reference internal" href="#">Coding and development help</a><ul>
|
||||
<li><a class="reference internal" href="#evennia-changelog">Evennia Changelog</a></li>
|
||||
<li><a class="reference internal" href="#third-party-integrations">Third-party integrations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
@ -72,8 +71,8 @@
|
|||
<p class="topless"><a href="../Concepts/Web-Features.html"
|
||||
title="previous chapter">Web Features</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="Version-Control.html"
|
||||
title="next chapter">Coding using Version Control</a></p>
|
||||
<p class="topless"><a href="Evennia-Code-Style.html"
|
||||
title="next chapter">Evennia Code Style</a></p>
|
||||
<div role="note" aria-label="source link">
|
||||
<!--h3>This Page</h3-->
|
||||
<ul class="this-page-menu">
|
||||
|
|
@ -107,10 +106,17 @@
|
|||
<section class="tex2jax_ignore mathjax_ignore" id="coding-and-development-help">
|
||||
<h1>Coding and development help<a class="headerlink" href="#coding-and-development-help" title="Permalink to this headline">¶</a></h1>
|
||||
<p>This documentation aims to help you set up a sane development environment to
|
||||
make your game, also if you never coded before. If you are an experienced coder, much of this will be familiar to you, but some things may still be useful.</p>
|
||||
make your game, also if you never coded before.</p>
|
||||
<p>See also the <a class="reference internal" href="../Howtos/Beginner-Tutorial/Beginner-Tutorial-Overview.html"><span class="doc std std-doc">Beginner Tutorial</span></a>.</p>
|
||||
<div class="toctree-wrapper compound">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="Evennia-Code-Style.html">Evennia Code Style</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Evennia-Code-Style.html#main-code-style-specification">Main code style specification</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Evennia-Code-Style.html#code-docstrings">Code Docstrings</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Evennia-Code-Style.html#default-command-docstrings">Default Command Docstrings</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Evennia-Code-Style.html#tools-for-auto-linting">Tools for auto-linting</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="Version-Control.html">Coding using Version Control</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Version-Control.html#setting-up-git">Setting up Git</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Version-Control.html#common-git-commands">Common Git commands</a></li>
|
||||
|
|
@ -140,33 +146,13 @@ make your game, also if you never coded before. If you are an experienced coder,
|
|||
<li class="toctree-l2"><a class="reference internal" href="Profiling.html#the-dummyrunner">The Dummyrunner</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="Evennia-Code-Style.html">Evennia Code Style</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Evennia-Code-Style.html#main-code-style-specification">Main code style specification</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Evennia-Code-Style.html#code-docstrings">Code Docstrings</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Evennia-Code-Style.html#default-command-docstrings">Default Command Docstrings</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Evennia-Code-Style.html#tools-for-auto-linting">Tools for auto-linting</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="Continuous-Integration.html">Continuous Integration (CI)</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Continuous-Integration.html#continuous-integration-guides">Continuous-Integration guides</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="Coding-FAQ.html">Coding FAQ</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Coding-FAQ.html#removing-default-commands">Removing default commands</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Coding-FAQ.html#preventing-character-from-moving-based-on-a-condition">Preventing character from moving based on a condition</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Coding-FAQ.html#reference-initiating-object-in-an-evmenu-command">Reference initiating object in an EvMenu command.</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Coding-FAQ.html#selectively-turn-off-commands-in-a-room">Selectively turn off commands in a room</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Coding-FAQ.html#select-command-based-on-a-condition">Select Command based on a condition</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Coding-FAQ.html#automatically-updating-code-when-reloading">Automatically updating code when reloading</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Coding-FAQ.html#changing-all-exit-messages">Changing all exit messages</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Coding-FAQ.html#add-parsing-with-the-to-delimiter">Add parsing with the “to” delimiter</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Coding-FAQ.html#non-latin-characters-in-evtable">Non-latin characters in EvTable</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="Quirks.html">Quirks</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Quirks.html#forgetting-to-use-reload-to-see-changes-to-your-typeclasses">Forgetting to use <code class="docutils literal notranslate"><span class="pre">reload</span></code> to see changes to your typeclasses</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Quirks.html#web-admin-to-create-new-account">Web admin to create new Account</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Quirks.html#mutable-attributes-and-their-connection-to-the-database">Mutable attributes and their connection to the database</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Quirks.html#commands-are-matched-by-name-or-alias">Commands are matched by name <em>or</em> alias</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Quirks.html#objects-turning-to-defaultobject">Objects turning to <code class="docutils literal notranslate"><span class="pre">DefaultObject</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Quirks.html#overriding-of-magic-methods">Overriding of magic methods</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Quirks.html#things-to-remember-about-the-flat-api">Things to remember about the flat API</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="Setting-up-PyCharm.html">Setting up PyCharm with Evennia</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Setting-up-PyCharm.html#debug-evennia-from-inside-pycharm">Debug Evennia from inside PyCharm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="Setting-up-PyCharm.html#run-evennia-from-inside-pycharm">Run Evennia from inside PyCharm</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
@ -208,15 +194,6 @@ make your game, also if you never coded before. If you are an experienced coder,
|
|||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<section id="third-party-integrations">
|
||||
<h2>Third-party integrations<a class="headerlink" href="#third-party-integrations" title="Permalink to this headline">¶</a></h2>
|
||||
<div class="toctree-wrapper compound">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="Continuous-Integration.html">Continuous Integration (CI)</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="Setting-up-PyCharm.html">Setting up PyCharm with Evennia</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
|
|
@ -235,7 +212,7 @@ make your game, also if you never coded before. If you are an experienced coder,
|
|||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Version-Control.html" title="Coding using Version Control"
|
||||
<a href="Evennia-Code-Style.html" title="Evennia Code Style"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="../Concepts/Web-Features.html" title="Web Features"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Continuous integration with Travis" href="Continuous-Integration-Travis.html" />
|
||||
<link rel="prev" title="Changelog" href="Changelog.html" />
|
||||
<link rel="prev" title="Profiling" href="Profiling.html" />
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
<a href="Continuous-Integration-Travis.html" title="Continuous integration with Travis"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Changelog.html" title="Changelog"
|
||||
<a href="Profiling.html" title="Profiling"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" accesskey="U">Coding and development help</a> »</li>
|
||||
|
|
@ -63,14 +63,14 @@
|
|||
<h3><a href="../index.html">Table of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">Continuous Integration (CI)</a><ul>
|
||||
<li><a class="reference internal" href="#list-of-ci-evennia-tutorials">List of CI Evennia tutorials</a></li>
|
||||
<li><a class="reference internal" href="#continuous-integration-guides">Continuous-Integration guides</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="Changelog.html"
|
||||
title="previous chapter">Changelog</a></p>
|
||||
<p class="topless"><a href="Profiling.html"
|
||||
title="previous chapter">Profiling</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="Continuous-Integration-Travis.html"
|
||||
title="next chapter">Continuous integration with Travis</a></p>
|
||||
|
|
@ -106,7 +106,6 @@
|
|||
|
||||
<section class="tex2jax_ignore mathjax_ignore" id="continuous-integration-ci">
|
||||
<h1>Continuous Integration (CI)<a class="headerlink" href="#continuous-integration-ci" title="Permalink to this headline">¶</a></h1>
|
||||
<p>One of the advantages of Evennia over traditional MU* development systems is that Evennia can integrate into enterprise-level integration environments and source control.</p>
|
||||
<p><a class="reference external" href="https://www.thoughtworks.com/continuous-integration">Continuous Integration (CI)</a> is a development practice that requires developers to integrate code into a shared repository. Each check-in is then verified by an automated build, allowing teams to detect problems early. This can be set up to safely deploy data to a production server only after tests have passed, for example.</p>
|
||||
<p>For Evennia, continuous integration allows an automated build process to:</p>
|
||||
<ul class="simple">
|
||||
|
|
@ -117,8 +116,8 @@
|
|||
<li><p>Publish those files to the server directory</p></li>
|
||||
<li><p>Reload the game.</p></li>
|
||||
</ul>
|
||||
<section id="list-of-ci-evennia-tutorials">
|
||||
<h2>List of CI Evennia tutorials<a class="headerlink" href="#list-of-ci-evennia-tutorials" title="Permalink to this headline">¶</a></h2>
|
||||
<section id="continuous-integration-guides">
|
||||
<h2>Continuous-Integration guides<a class="headerlink" href="#continuous-integration-guides" title="Permalink to this headline">¶</a></h2>
|
||||
<p>There are a lot of tools and services providing CI functionality. Here are a few that people have used with Evennia:</p>
|
||||
<div class="toctree-wrapper compound">
|
||||
<ul>
|
||||
|
|
@ -126,6 +125,9 @@
|
|||
<li class="toctree-l1"><a class="reference internal" href="Continuous-Integration-TeamCity.html">Continuous Integration - TeamCity (linux)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<ul class="simple">
|
||||
<li><p>Evennia is itself making heavy use of <span class="xref myst">github actions</span></p></li>
|
||||
</ul>
|
||||
<p><a class="reference external" href="https://www.atlassian.com/continuous-delivery/continuous-integration/tools">This is an overview of other tools</a> (external link).</p>
|
||||
</section>
|
||||
</section>
|
||||
|
|
@ -149,7 +151,7 @@
|
|||
<a href="Continuous-Integration-Travis.html" title="Continuous integration with Travis"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Changelog.html" title="Changelog"
|
||||
<a href="Profiling.html" title="Profiling"
|
||||
>previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" >Coding and development help</a> »</li>
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Coding FAQ" href="Coding-FAQ.html" />
|
||||
<link rel="prev" title="Profiling" href="Profiling.html" />
|
||||
<link rel="next" title="Coding using Version Control" href="Version-Control.html" />
|
||||
<link rel="prev" title="Coding and development help" href="Coding-Overview.html" />
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
|
|
@ -30,10 +30,10 @@
|
|||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Coding-FAQ.html" title="Coding FAQ"
|
||||
<a href="Version-Control.html" title="Coding using Version Control"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Profiling.html" title="Profiling"
|
||||
<a href="Coding-Overview.html" title="Coding and development help"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" accesskey="U">Coding and development help</a> »</li>
|
||||
|
|
@ -81,11 +81,11 @@
|
|||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="Profiling.html"
|
||||
title="previous chapter">Profiling</a></p>
|
||||
<p class="topless"><a href="Coding-Overview.html"
|
||||
title="previous chapter">Coding and development help</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="Coding-FAQ.html"
|
||||
title="next chapter">Coding FAQ</a></p>
|
||||
<p class="topless"><a href="Version-Control.html"
|
||||
title="next chapter">Coding using Version Control</a></p>
|
||||
<div role="note" aria-label="source link">
|
||||
<!--h3>This Page</h3-->
|
||||
<ul class="this-page-menu">
|
||||
|
|
@ -384,10 +384,10 @@ Google-style docstrings, follow <a class="reference external" href="https://www.
|
|||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Coding-FAQ.html" title="Coding FAQ"
|
||||
<a href="Version-Control.html" title="Coding using Version Control"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Profiling.html" title="Profiling"
|
||||
<a href="Coding-Overview.html" title="Coding and development help"
|
||||
>previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" >Coding and development help</a> »</li>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Evennia Code Style" href="Evennia-Code-Style.html" />
|
||||
<link rel="next" title="Continuous Integration (CI)" href="Continuous-Integration.html" />
|
||||
<link rel="prev" title="Unit Testing" href="Unit-Testing.html" />
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Evennia-Code-Style.html" title="Evennia Code Style"
|
||||
<a href="Continuous-Integration.html" title="Continuous Integration (CI)"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Unit-Testing.html" title="Unit Testing"
|
||||
|
|
@ -80,8 +80,8 @@
|
|||
<p class="topless"><a href="Unit-Testing.html"
|
||||
title="previous chapter">Unit Testing</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="Evennia-Code-Style.html"
|
||||
title="next chapter">Evennia Code Style</a></p>
|
||||
<p class="topless"><a href="Continuous-Integration.html"
|
||||
title="next chapter">Continuous Integration (CI)</a></p>
|
||||
<div role="note" aria-label="source link">
|
||||
<!--h3>This Page</h3-->
|
||||
<ul class="this-page-menu">
|
||||
|
|
@ -315,7 +315,7 @@ For this, actual real-game testing is required.</p></li>
|
|||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Evennia-Code-Style.html" title="Evennia Code Style"
|
||||
<a href="Continuous-Integration.html" title="Continuous Integration (CI)"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Unit-Testing.html" title="Unit Testing"
|
||||
|
|
|
|||
|
|
@ -1,274 +0,0 @@
|
|||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||||
|
||||
<title>Quirks — Evennia 1.0-dev documentation</title>
|
||||
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/language_data.js"></script>
|
||||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Changelog" href="Changelog.html" />
|
||||
<link rel="prev" title="Coding FAQ" href="Coding-FAQ.html" />
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Changelog.html" title="Changelog"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Coding-FAQ.html" title="Coding FAQ"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" accesskey="U">Coding and development help</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Quirks</a></li>
|
||||
</ul>
|
||||
<div class="develop">develop branch</div>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
|
||||
<div class="documentwrapper">
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../index.html">
|
||||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
<h3><a href="../index.html">Table of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">Quirks</a><ul>
|
||||
<li><a class="reference internal" href="#forgetting-to-use-reload-to-see-changes-to-your-typeclasses">Forgetting to use <code class="docutils literal notranslate"><span class="pre">reload</span></code> to see changes to your typeclasses</a></li>
|
||||
<li><a class="reference internal" href="#web-admin-to-create-new-account">Web admin to create new Account</a></li>
|
||||
<li><a class="reference internal" href="#mutable-attributes-and-their-connection-to-the-database">Mutable attributes and their connection to the database</a></li>
|
||||
<li><a class="reference internal" href="#commands-are-matched-by-name-or-alias">Commands are matched by name <em>or</em> alias</a></li>
|
||||
<li><a class="reference internal" href="#objects-turning-to-defaultobject">Objects turning to <code class="docutils literal notranslate"><span class="pre">DefaultObject</span></code></a></li>
|
||||
<li><a class="reference internal" href="#overriding-of-magic-methods">Overriding of magic methods</a></li>
|
||||
<li><a class="reference internal" href="#things-to-remember-about-the-flat-api">Things to remember about the flat API</a><ul>
|
||||
<li><a class="reference internal" href="#to-remember-when-importing-from-evennia">To remember when importing from <code class="docutils literal notranslate"><span class="pre">evennia</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="Coding-FAQ.html"
|
||||
title="previous chapter">Coding FAQ</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="Changelog.html"
|
||||
title="next chapter">Changelog</a></p>
|
||||
<div role="note" aria-label="source link">
|
||||
<!--h3>This Page</h3-->
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../_sources/Coding/Quirks.md.txt"
|
||||
rel="nofollow">Show Page Source</a></li>
|
||||
</ul>
|
||||
</div><h3>Links</h3>
|
||||
<ul>
|
||||
<li><a href="https://www.evennia.com">Home page</a> </li>
|
||||
<li><a href="https://github.com/evennia/evennia">Evennia Github</a> </li>
|
||||
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
||||
<li>
|
||||
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
||||
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
||||
<a href="https://evennia.blogspot.com/">Blog</a>
|
||||
</li>
|
||||
</ul>
|
||||
<h3>Versions</h3>
|
||||
<ul>
|
||||
<li><a href="Quirks.html">1.0-dev (develop branch)</a></li>
|
||||
<ul>
|
||||
<li><a href="../0.9.5/index.html">0.9.5 (v0.9.5 branch)</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section class="tex2jax_ignore mathjax_ignore" id="quirks">
|
||||
<h1>Quirks<a class="headerlink" href="#quirks" title="Permalink to this headline">¶</a></h1>
|
||||
<p>This is a list of various quirks or common stumbling blocks that people often ask about or report
|
||||
when using (or trying to use) Evennia. They are not bugs.</p>
|
||||
<section id="forgetting-to-use-reload-to-see-changes-to-your-typeclasses">
|
||||
<h2>Forgetting to use <code class="docutils literal notranslate"><span class="pre">reload</span></code> to see changes to your typeclasses<a class="headerlink" href="#forgetting-to-use-reload-to-see-changes-to-your-typeclasses" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Firstly: Reloading the server is a safe and usually quick operation which will <em>not</em> disconnect any
|
||||
accounts.</p>
|
||||
<p>New users tend to forget this step. When editing source code (such as when tweaking typeclasses and
|
||||
commands or adding new commands to command sets) you need to either use the in-game <code class="docutils literal notranslate"><span class="pre">@reload</span></code>
|
||||
command or, from the command line do <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">evennia.py</span> <span class="pre">reload</span></code> before you see your changes.</p>
|
||||
</section>
|
||||
<section id="web-admin-to-create-new-account">
|
||||
<h2>Web admin to create new Account<a class="headerlink" href="#web-admin-to-create-new-account" title="Permalink to this headline">¶</a></h2>
|
||||
<p>If you use the default login system and are trying to use the Web admin to create a new Player
|
||||
account, you need to consider which <code class="docutils literal notranslate"><span class="pre">MULTIACCOUNT_MODE</span></code> you are in. If you are in
|
||||
<code class="docutils literal notranslate"><span class="pre">MULTIACCOUNT_MODE</span></code> <code class="docutils literal notranslate"><span class="pre">0</span></code> or <code class="docutils literal notranslate"><span class="pre">1</span></code>, the login system expects each Account to also have a Character
|
||||
object named the same as the Account - there is no character creation screen by default. If using
|
||||
the normal mud login screen, a Character with the same name is automatically created and connected
|
||||
to your Account. From the web interface you must do this manually.</p>
|
||||
<p>So, when creating the Account, make sure to also create the Character <em>from the same form</em> as you
|
||||
create the Account from. This should set everything up for you. Otherwise you need to manually set
|
||||
the “account” property on the Character and the “character” property on the Account to point to each
|
||||
other. You must also set the lockstring of the Character to allow the Account to “puppet” this
|
||||
particular character.</p>
|
||||
</section>
|
||||
<section id="mutable-attributes-and-their-connection-to-the-database">
|
||||
<h2>Mutable attributes and their connection to the database<a class="headerlink" href="#mutable-attributes-and-their-connection-to-the-database" title="Permalink to this headline">¶</a></h2>
|
||||
<p>When storing a mutable object (usually a list or a dictionary) in an Attribute</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="nb">object</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">mylist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">]</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>you should know that the connection to the database is retained also if you later extract that
|
||||
Attribute into another variable (what is stored and retrieved is actually a <code class="docutils literal notranslate"><span class="pre">PackedList</span></code> or a
|
||||
<code class="docutils literal notranslate"><span class="pre">PackedDict</span></code> that works just like their namesakes except they save themselves to the database when
|
||||
changed). So if you do</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="n">alist</span> <span class="o">=</span> <span class="nb">object</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">mylist</span>
|
||||
<span class="n">alist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>this updates the database behind the scenes, so both <code class="docutils literal notranslate"><span class="pre">alist</span></code> and <code class="docutils literal notranslate"><span class="pre">object.db.mylist</span></code> are now
|
||||
<code class="docutils literal notranslate"><span class="pre">[1,2,3,4]</span></code></p>
|
||||
<p>If you don’t want this, Evennia provides a way to stably disconnect the mutable from the database by
|
||||
use of <code class="docutils literal notranslate"><span class="pre">evennia.utils.dbserialize.deserialize</span></code>:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="kn">from</span> <span class="nn">evennia.utils.dbserialize</span> <span class="kn">import</span> <span class="n">deserialize</span>
|
||||
|
||||
<span class="n">blist</span> <span class="o">=</span> <span class="n">deserialize</span><span class="p">(</span><span class="nb">object</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">mylist</span><span class="p">)</span>
|
||||
<span class="n">blist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The property <code class="docutils literal notranslate"><span class="pre">blist</span></code> is now <code class="docutils literal notranslate"><span class="pre">[1,2,3,4]</span></code> whereas <code class="docutils literal notranslate"><span class="pre">object.db.mylist</span></code> remains unchanged. If you want to
|
||||
update the database you’d need to explicitly re-assign the updated data to the <code class="docutils literal notranslate"><span class="pre">mylist</span></code> Attribute.</p>
|
||||
</section>
|
||||
<section id="commands-are-matched-by-name-or-alias">
|
||||
<h2>Commands are matched by name <em>or</em> alias<a class="headerlink" href="#commands-are-matched-by-name-or-alias" title="Permalink to this headline">¶</a></h2>
|
||||
<p>When merging <a class="reference internal" href="../Components/Commands.html"><span class="doc std std-doc">command sets</span></a> it’s important to remember that command objects are identified
|
||||
<em>both</em> by key <em>or</em> alias. So if you have a command with a key <code class="docutils literal notranslate"><span class="pre">look</span></code> and an alias <code class="docutils literal notranslate"><span class="pre">ls</span></code>, introducing
|
||||
another command with a key <code class="docutils literal notranslate"><span class="pre">ls</span></code> will be assumed by the system to be <em>identical</em> to the first one.
|
||||
This usually means merging cmdsets will overload one of them depending on priority. Whereas this is
|
||||
logical once you know how command objects are handled, it may be confusing if you are just looking
|
||||
at the command strings thinking they are parsed as-is.</p>
|
||||
</section>
|
||||
<section id="objects-turning-to-defaultobject">
|
||||
<h2>Objects turning to <code class="docutils literal notranslate"><span class="pre">DefaultObject</span></code><a class="headerlink" href="#objects-turning-to-defaultobject" title="Permalink to this headline">¶</a></h2>
|
||||
<p>A common confusing error for new developers is finding that one or more objects in-game are suddenly
|
||||
of the type <code class="docutils literal notranslate"><span class="pre">DefaultObject</span></code> rather than the typeclass you wanted it to be. This happens when you
|
||||
introduce a critical Syntax error to the module holding your custom class. Since such a module is
|
||||
not valid Python, Evennia can’t load it at all to get to the typeclasses within. To keep on running,
|
||||
Evennia will solve this by printing the full traceback to the terminal/console and temporarily fall
|
||||
back to the safe <code class="docutils literal notranslate"><span class="pre">DefaultObject</span></code> until you fix the problem and reload. Most errors of this kind will
|
||||
be caught by any good text editors. Keep an eye on the terminal/console during a reload to catch
|
||||
such errors - you may have to scroll up if your window is small.</p>
|
||||
</section>
|
||||
<section id="overriding-of-magic-methods">
|
||||
<h2>Overriding of magic methods<a class="headerlink" href="#overriding-of-magic-methods" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Python implements a system of <a class="reference external" href="https://docs.python.org/3/reference/datamodel.html#emulating-container-types">magic
|
||||
methods</a>, usually
|
||||
prefixed and suffixed by double-underscores (<code class="docutils literal notranslate"><span class="pre">__example__</span></code>) that allow object instances to have
|
||||
certain operations performed on them without needing to do things like turn them into strings or
|
||||
numbers first– for example, is <code class="docutils literal notranslate"><span class="pre">obj1</span></code> greater than or equal to <code class="docutils literal notranslate"><span class="pre">obj2</span></code>?</p>
|
||||
<p>Neither object is a number, but given <code class="docutils literal notranslate"><span class="pre">obj1.size</span> <span class="pre">==</span> <span class="pre">"small"</span></code> and <code class="docutils literal notranslate"><span class="pre">obj2.size</span> <span class="pre">==</span> <span class="pre">"large"</span></code>, how might
|
||||
one compare these two arbitrary English adjective strings to figure out which is greater than the
|
||||
other? By defining the <code class="docutils literal notranslate"><span class="pre">__ge__</span></code> (greater than or equal to) magic method on the object class in which
|
||||
you figure out which word has greater significance, perhaps through use of a mapping table
|
||||
(<code class="docutils literal notranslate"><span class="pre">{'small':0,</span> <span class="pre">'large':10}</span></code>) or other lookup and comparing the numeric values of each.</p>
|
||||
<p>Evennia extensively makes use of magic methods on typeclasses to do things like initialize objects,
|
||||
check object existence or iterate over objects in an inventory or container. If you override or
|
||||
interfere with the return values from the methods Evennia expects to be both present and working, it
|
||||
can result in very inconsistent and hard-to-diagnose errors.</p>
|
||||
<p>The moral of the story– it can be dangerous to tinker with magic methods on typeclassed objects.
|
||||
Try to avoid doing so.</p>
|
||||
</section>
|
||||
<section id="things-to-remember-about-the-flat-api">
|
||||
<h2>Things to remember about the flat API<a class="headerlink" href="#things-to-remember-about-the-flat-api" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The flat API is a series of ‘shortcuts’ on the <code class="docutils literal notranslate"><span class="pre">evennia</span></code> main library root (defined in
|
||||
<code class="docutils literal notranslate"><span class="pre">evennia/__init__.py</span></code>). Its componentas are documented <a class="reference internal" href="../Evennia-API.html"><span class="doc std std-doc">as part of the auto-documentation</span></a>.</p>
|
||||
<section id="to-remember-when-importing-from-evennia">
|
||||
<h3>To remember when importing from <code class="docutils literal notranslate"><span class="pre">evennia</span></code><a class="headerlink" href="#to-remember-when-importing-from-evennia" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Properties on the root of the <code class="docutils literal notranslate"><span class="pre">evennia</span></code> package are <em>not</em> modules in their own right. They are just
|
||||
shortcut properties stored in the <code class="docutils literal notranslate"><span class="pre">evennia/__init__.py</span></code> module. That means that you cannot use dot-
|
||||
notation to <code class="docutils literal notranslate"><span class="pre">import</span></code> nested module-names over <code class="docutils literal notranslate"><span class="pre">evennia</span></code>. The rule of thumb is that you cannot use
|
||||
<code class="docutils literal notranslate"><span class="pre">import</span></code> for more than one level down. Hence you can do</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="kn">import</span> <span class="nn">evennia</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">evennia</span><span class="o">.</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">CmdLook</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>or import one level down</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">default_cmds</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">default_cmds</span><span class="o">.</span><span class="n">CmdLook</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>but you <em>cannot</em> import two levels down</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="kn">from</span> <span class="nn">evennia.default_cmds</span> <span class="kn">import</span> <span class="n">CmdLook</span> <span class="c1"># error!</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>This will give you an <code class="docutils literal notranslate"><span class="pre">ImportError</span></code> telling you that the module <code class="docutils literal notranslate"><span class="pre">default_cmds</span></code> cannot be found -
|
||||
this is becasue <code class="docutils literal notranslate"><span class="pre">default_cmds</span></code> is just a <em>variable</em> stored in <code class="docutils literal notranslate"><span class="pre">evennia.__init__.py</span></code>; this cannot be
|
||||
imported from. If you really want full control over which level of package you import you can always
|
||||
bypass the root package and import directly from from the real location. For example
|
||||
<code class="docutils literal notranslate"><span class="pre">evennia.DefaultObject</span></code> is a shortcut to <code class="docutils literal notranslate"><span class="pre">evennia.objects.objects.DefaultObject</span></code>. Using this full
|
||||
path will have the import mechanism work normally. See <code class="docutils literal notranslate"><span class="pre">evennia/__init__.py</span></code> to see where the
|
||||
package imports from.</p>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Changelog.html" title="Changelog"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Coding-FAQ.html" title="Coding FAQ"
|
||||
>previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" >Coding and development help</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Quirks</a></li>
|
||||
</ul>
|
||||
<div class="develop">develop branch</div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, The Evennia developer community.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Contribs" href="../Contribs/Contribs-Overview.html" />
|
||||
<link rel="next" title="Changelog" href="Changelog.html" />
|
||||
<link rel="prev" title="Continuous Integration - TeamCity (linux)" href="Continuous-Integration-TeamCity.html" />
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="../Contribs/Contribs-Overview.html" title="Contribs"
|
||||
<a href="Changelog.html" title="Changelog"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Continuous-Integration-TeamCity.html" title="Continuous Integration - TeamCity (linux)"
|
||||
|
|
@ -63,20 +63,21 @@
|
|||
<h3><a href="../index.html">Table of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">Setting up PyCharm with Evennia</a><ul>
|
||||
<li><a class="reference internal" href="#setting-up-the-project-interpreter">Setting up the project interpreter</a></li>
|
||||
<li><a class="reference internal" href="#attaching-pycharm-debugger-to-evennia">Attaching PyCharm debugger to Evennia</a></li>
|
||||
<li><a class="reference internal" href="#setting-up-an-evennia-run-configuration">Setting up an Evennia run configuration</a></li>
|
||||
<li><a class="reference internal" href="#debug-evennia-from-inside-pycharm">Debug Evennia from inside PyCharm</a></li>
|
||||
<li><a class="reference internal" href="#run-evennia-from-inside-pycharm">Run Evennia from inside PyCharm</a><ul>
|
||||
<li><a class="reference internal" href="#alternative-config-utilizing-logfiles-as-source-of-data">Alternative config - utilizing logfiles as source of data</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="Continuous-Integration-TeamCity.html"
|
||||
title="previous chapter">Continuous Integration - TeamCity (linux)</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="../Contribs/Contribs-Overview.html"
|
||||
title="next chapter">Contribs</a></p>
|
||||
<p class="topless"><a href="Changelog.html"
|
||||
title="next chapter">Changelog</a></p>
|
||||
<div role="note" aria-label="source link">
|
||||
<!--h3>This Page</h3-->
|
||||
<ul class="this-page-menu">
|
||||
|
|
@ -121,19 +122,15 @@ need to add them to your project too:</p>
|
|||
<li><p>Select the folder (i.e. the <code class="docutils literal notranslate"><span class="pre">evennia</span></code> root)</p></li>
|
||||
<li><p>Select “Open in current window” and “Add to currently opened projects”</p></li>
|
||||
</ol>
|
||||
<section id="setting-up-the-project-interpreter">
|
||||
<h2>Setting up the project interpreter<a class="headerlink" href="#setting-up-the-project-interpreter" title="Permalink to this headline">¶</a></h2>
|
||||
<p>It’s a good idea to do this before attempting anything further. The rest of this page assumes your
|
||||
project is already configured in PyCharm.</p>
|
||||
<p>It’s a good idea to set up the interpreter this before attempting anything further. The rest of this page assumes your project is already configured in PyCharm.</p>
|
||||
<ol class="simple">
|
||||
<li><p>Go to <code class="docutils literal notranslate"><span class="pre">File</span> <span class="pre">></span> <span class="pre">Settings...</span> <span class="pre">></span> <span class="pre">Project:</span> <span class="pre">\<mygame\></span> <span class="pre">></span> <span class="pre">Project</span> <span class="pre">Interpreter</span></code></p></li>
|
||||
<li><p>Click the Gear symbol <code class="docutils literal notranslate"><span class="pre">></span> <span class="pre">Add</span> <span class="pre">local</span></code></p></li>
|
||||
<li><p>Navigate to your <code class="docutils literal notranslate"><span class="pre">evenv/scripts</span> <span class="pre">directory</span></code>, and select Python.exe</p></li>
|
||||
</ol>
|
||||
<p>Enjoy seeing all your imports checked properly, setting breakpoints, and live variable watching!</p>
|
||||
</section>
|
||||
<section id="attaching-pycharm-debugger-to-evennia">
|
||||
<h2>Attaching PyCharm debugger to Evennia<a class="headerlink" href="#attaching-pycharm-debugger-to-evennia" title="Permalink to this headline">¶</a></h2>
|
||||
<section id="debug-evennia-from-inside-pycharm">
|
||||
<h2>Debug Evennia from inside PyCharm<a class="headerlink" href="#debug-evennia-from-inside-pycharm" title="Permalink to this headline">¶</a></h2>
|
||||
<ol class="simple">
|
||||
<li><p>Launch Evennia in your preferred way (usually from a console/terminal)</p></li>
|
||||
<li><p>Open your project in PyCharm</p></li>
|
||||
|
|
@ -150,8 +147,8 @@ or runner for some reason (or just learn how they work!), see Run Configuration
|
|||
</div></blockquote>
|
||||
<p><img alt="Example process filter configuration" src="https://i.imgur.com/vkSheR8.png" /></p>
|
||||
</section>
|
||||
<section id="setting-up-an-evennia-run-configuration">
|
||||
<h2>Setting up an Evennia run configuration<a class="headerlink" href="#setting-up-an-evennia-run-configuration" title="Permalink to this headline">¶</a></h2>
|
||||
<section id="run-evennia-from-inside-pycharm">
|
||||
<h2>Run Evennia from inside PyCharm<a class="headerlink" href="#run-evennia-from-inside-pycharm" title="Permalink to this headline">¶</a></h2>
|
||||
<p>This configuration allows you to launch Evennia from inside PyCharm. Besides convenience, it also allows suspending and debugging the evennia_launcher or evennia_runner at points earlier than you could by running them externally and attaching. In fact by the time the server and/or portal are running the launcher will have exited already.</p>
|
||||
<ol class="simple">
|
||||
<li><p>Go to <code class="docutils literal notranslate"><span class="pre">Run</span> <span class="pre">></span> <span class="pre">Edit</span> <span class="pre">Configutations...</span></code></p></li>
|
||||
|
|
@ -164,9 +161,8 @@ or runner for some reason (or just learn how they work!), see Run Configuration
|
|||
</ol>
|
||||
<p>Now set up a “stop” configuration by following the same steps as above, but set your Script parameters to: stop (and name the configuration appropriately).</p>
|
||||
<p>A dropdown box holding your new configurations should appear next to your PyCharm run button. Select MyMUD start and press the debug icon to begin debugging. Depending on how far you let the program run, you may need to run your “MyMUD stop” config to actually stop the server, before you’ll be able start it again.</p>
|
||||
</section>
|
||||
<section id="alternative-config-utilizing-logfiles-as-source-of-data">
|
||||
<h2>Alternative config - utilizing logfiles as source of data<a class="headerlink" href="#alternative-config-utilizing-logfiles-as-source-of-data" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Alternative config - utilizing logfiles as source of data<a class="headerlink" href="#alternative-config-utilizing-logfiles-as-source-of-data" title="Permalink to this headline">¶</a></h3>
|
||||
<p>This configuration takes a bit different approach as instead of focusing on getting the data back through logfiles. Reason for that is this way you can easily separate data streams, for example you rarely want to follow both server and portal at the same time, and this will allow it. This will also make sure to stop the evennia before starting it, essentially working as reload command (it will also include instructions how to disable that part of functionality). We will start by defining a configuration that will stop evennia. This assumes that <code class="docutils literal notranslate"><span class="pre">upfire</span></code> is your pycharm project name, and also the game name, hence the <code class="docutils literal notranslate"><span class="pre">upfire/upfire</span></code> path.</p>
|
||||
<ol class="simple">
|
||||
<li><p>Go to <code class="docutils literal notranslate"><span class="pre">Run</span> <span class="pre">></span> <span class="pre">Edit</span> <span class="pre">Configutations...</span></code>\</p></li>
|
||||
|
|
@ -196,6 +192,7 @@ following in the bottom panel:
|
|||
and you can click through the tabs to check appropriate logs, or even the console output as it is
|
||||
still running in interactive mode.</p>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
|
|
@ -214,7 +211,7 @@ still running in interactive mode.</p>
|
|||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="../Contribs/Contribs-Overview.html" title="Contribs"
|
||||
<a href="Changelog.html" title="Changelog"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Continuous-Integration-TeamCity.html" title="Continuous Integration - TeamCity (linux)"
|
||||
|
|
|
|||
|
|
@ -331,12 +331,9 @@ add the model to Evennia’s central <code class="docutils literal notranslate">
|
|||
optional models regardless of if the user wants them. But at the same time a contribution is a part
|
||||
of the Evennia distribution and its unit tests should be run with all other Evennia tests using
|
||||
<code class="docutils literal notranslate"><span class="pre">evennia</span> <span class="pre">test</span> <span class="pre">evennia</span></code>.</p>
|
||||
<p>The way to do this is to only temporarily add your models to the <code class="docutils literal notranslate"><span class="pre">INSTALLED_APPS</span></code> directory when the
|
||||
test runs. here is an example of how to do it.</p>
|
||||
<p>The way to do this is to only temporarily add your models to the <code class="docutils literal notranslate"><span class="pre">INSTALLED_APPS</span></code> directory when the test runs. here is an example of how to do it.</p>
|
||||
<blockquote>
|
||||
<div><p>Note that this solution, derived from this [stackexchange
|
||||
answer](<a class="reference external" href="http://stackoverflow.com/questions/502916/django-how-to-create-a-model-dynamically-just-for-">http://stackoverflow.com/questions/502916/django-how-to-create-a-model-dynamically-just-for-</a>
|
||||
testing#503435) is currently untested! Please report your findings.</p>
|
||||
<div><p>Note that this solution, derived from this <a class="reference external" href="http://stackoverflow.com/questions/502916/django-how-to-create-a-model-dynamically-just-for-testing#503435">stackexchange answer</a> is currently untested! Please report your findings.</p>
|
||||
</div></blockquote>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># a file contrib/mycontrib/tests.py</span>
|
||||
|
||||
|
|
@ -387,8 +384,7 @@ testing#503435) is currently untested! Please report your findings.</p>
|
|||
</section>
|
||||
<section id="a-note-on-making-the-test-runner-faster">
|
||||
<h2>A note on making the test runner faster<a class="headerlink" href="#a-note-on-making-the-test-runner-faster" title="Permalink to this headline">¶</a></h2>
|
||||
<p>If you have custom models with a large number of migrations, creating the test database can take a
|
||||
very long time. If you don’t require migrations to run for your tests, you can disable them with the
|
||||
<p>If you have custom models with a large number of migrations, creating the test database can take a very long time. If you don’t require migrations to run for your tests, you can disable them with the
|
||||
django-test-without-migrations package. To install it, simply:</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pip install django-test-without-migrations
|
||||
</pre></div>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<link rel="next" title="Debugging" href="Debugging.html" />
|
||||
<link rel="prev" title="Coding and development help" href="Coding-Overview.html" />
|
||||
<link rel="prev" title="Evennia Code Style" href="Evennia-Code-Style.html" />
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
<a href="Debugging.html" title="Debugging"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Coding-Overview.html" title="Coding and development help"
|
||||
<a href="Evennia-Code-Style.html" title="Evennia Code Style"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" accesskey="U">Coding and development help</a> »</li>
|
||||
|
|
@ -91,8 +91,8 @@
|
|||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="Coding-Overview.html"
|
||||
title="previous chapter">Coding and development help</a></p>
|
||||
<p class="topless"><a href="Evennia-Code-Style.html"
|
||||
title="previous chapter">Evennia Code Style</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="Debugging.html"
|
||||
title="next chapter">Debugging</a></p>
|
||||
|
|
@ -482,7 +482,7 @@ password <my_github_password>
|
|||
<a href="Debugging.html" title="Debugging"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="Coding-Overview.html" title="Coding and development help"
|
||||
<a href="Evennia-Code-Style.html" title="Evennia Code Style"
|
||||
>previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 1.0-dev</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="Coding-Overview.html" >Coding and development help</a> »</li>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue