mirror of
https://github.com/evennia/evennia.git
synced 2026-03-19 06:16:31 +01:00
514 lines
No EOL
39 KiB
HTML
514 lines
No EOL
39 KiB
HTML
|
||
<!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>evennia.contrib.rpg.rpsystem.rplanguage — Evennia 2.x 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="evennia.contrib.rpg.rpsystem.rpsystem" href="evennia.contrib.rpg.rpsystem.rpsystem.html" />
|
||
<link rel="prev" title="evennia.contrib.rpg.rpsystem" href="evennia.contrib.rpg.rpsystem.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="evennia.contrib.rpg.rpsystem.rpsystem.html" title="evennia.contrib.rpg.rpsystem.rpsystem"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.contrib.rpg.rpsystem.html" title="evennia.contrib.rpg.rpsystem"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 2.x</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.contrib.html" >evennia.contrib</a> »</li>
|
||
<li class="nav-item nav-item-5"><a href="evennia.contrib.rpg.html" >evennia.contrib.rpg</a> »</li>
|
||
<li class="nav-item nav-item-6"><a href="evennia.contrib.rpg.rpsystem.html" accesskey="U">evennia.contrib.rpg.rpsystem</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.contrib.rpg.rpsystem.rplanguage</a></li>
|
||
</ul>
|
||
</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="#">evennia.contrib.rpg.rpsystem.rplanguage</a><ul>
|
||
<li><a class="reference internal" href="#usage">Usage</a></li>
|
||
<li><a class="reference internal" href="#custom-languages">Custom languages</a></li>
|
||
<li><a class="reference internal" href="#example">Example</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="evennia.contrib.rpg.rpsystem.html"
|
||
title="previous chapter">evennia.contrib.rpg.rpsystem</a></p>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="evennia.contrib.rpg.rpsystem.rpsystem.html"
|
||
title="next chapter">evennia.contrib.rpg.rpsystem.rpsystem</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/api/evennia.contrib.rpg.rpsystem.rplanguage.md.txt"
|
||
rel="nofollow">Show Page Source</a></li>
|
||
</ul>
|
||
</div><h3>Links</h3>
|
||
<ul>
|
||
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
|
||
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
|
||
<li><a href="https://github.com/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>Doc Versions</h3>
|
||
<ul>
|
||
|
||
<li><a href="evennia.contrib.rpg.rpsystem.rplanguage.html">2.x (main branch)</a></li>
|
||
<ul>
|
||
<li><a href="../1.3.0/index.html">1.3.0 (v1.3.0 branch)</a></li>
|
||
|
||
<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 id="module-evennia.contrib.rpg.rpsystem.rplanguage">
|
||
<span id="evennia-contrib-rpg-rpsystem-rplanguage"></span><h1>evennia.contrib.rpg.rpsystem.rplanguage<a class="headerlink" href="#module-evennia.contrib.rpg.rpsystem.rplanguage" title="Permalink to this headline">¶</a></h1>
|
||
<p>Language and whisper obfuscation system</p>
|
||
<p>Evennia contrib - Griatch 2015</p>
|
||
<p>This module is intented to be used with an emoting system (such as
|
||
contrib/rpsystem.py). It offers the ability to obfuscate spoken words
|
||
in the game in various ways:</p>
|
||
<ul class="simple">
|
||
<li><dl class="simple">
|
||
<dt>Language: The language functionality defines a pseudo-language map</dt><dd><p>to any number of languages. The string will be obfuscated depending
|
||
on a scaling that (most likely) will be input as a weighted average of
|
||
the language skill of the speaker and listener.</p>
|
||
</dd>
|
||
</dl>
|
||
</li>
|
||
<li><dl class="simple">
|
||
<dt>Whisper: The whisper functionality will gradually “fade out” a</dt><dd><p>whisper along as scale 0-1, where the fading is based on gradually
|
||
removing sections of the whisper that is (supposedly) easier to
|
||
overhear (for example “s” sounds tend to be audible even when no other
|
||
meaning can be determined).</p>
|
||
</dd>
|
||
</dl>
|
||
</li>
|
||
</ul>
|
||
<section id="usage">
|
||
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.contrib</span> <span class="kn">import</span> <span class="n">rplanguage</span>
|
||
|
||
<span class="c1"># need to be done once, here we create the "default" lang</span>
|
||
<span class="n">rplanguage</span><span class="o">.</span><span class="n">add_language</span><span class="p">()</span>
|
||
|
||
<span class="n">say</span> <span class="o">=</span> <span class="s2">"This is me talking."</span>
|
||
<span class="n">whisper</span> <span class="o">=</span> <span class="s2">"This is me whispering.</span>
|
||
|
||
<span class="nb">print</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_language</span><span class="p">(</span><span class="n">say</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
|
||
<span class="o"><<<</span> <span class="s2">"This is me talking."</span>
|
||
<span class="nb">print</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_language</span><span class="p">(</span><span class="n">say</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
|
||
<span class="o"><<<</span> <span class="s2">"This is me byngyry."</span>
|
||
<span class="nb">print</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_language</span><span class="p">(</span><span class="n">say</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
|
||
<span class="o"><<<</span> <span class="s2">"Daly ly sy byngyry."</span>
|
||
|
||
<span class="n">result</span> <span class="o">=</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_whisper</span><span class="p">(</span><span class="n">whisper</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
|
||
<span class="o"><<<</span> <span class="s2">"This is me whispering"</span>
|
||
<span class="n">result</span> <span class="o">=</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_whisper</span><span class="p">(</span><span class="n">whisper</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.2</span><span class="p">)</span>
|
||
<span class="o"><<<</span> <span class="s2">"This is m- whisp-ring"</span>
|
||
<span class="n">result</span> <span class="o">=</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_whisper</span><span class="p">(</span><span class="n">whisper</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
|
||
<span class="o"><<<</span> <span class="s2">"---s -s -- ---s------"</span>
|
||
<span class="n">result</span> <span class="o">=</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_whisper</span><span class="p">(</span><span class="n">whisper</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">0.7</span><span class="p">)</span>
|
||
<span class="o"><<<</span> <span class="s2">"---- -- -- ----------"</span>
|
||
<span class="n">result</span> <span class="o">=</span> <span class="n">rplanguage</span><span class="o">.</span><span class="n">obfuscate_whisper</span><span class="p">(</span><span class="n">whisper</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
|
||
<span class="o"><<<</span> <span class="s2">"..."</span>
|
||
</pre></div>
|
||
</div>
|
||
</section>
|
||
<section id="custom-languages">
|
||
<h2>Custom languages<a class="headerlink" href="#custom-languages" title="Permalink to this headline">¶</a></h2>
|
||
<p>To set up new languages, you need to run <strong>add_language()</strong>
|
||
helper function in this module. The arguments of this function (see below)
|
||
are used to store the new language in the database (in the LanguageHandler,
|
||
which is a type of Script).</p>
|
||
<p>If you want to remember the language definitions, you could put them all
|
||
in a module along with the <strong>add_language</strong> call as a quick way to
|
||
rebuild the language on a db reset:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># a stand-alone module somewhere under mygame. Just import this</span>
|
||
<span class="c1"># once to automatically add the language!</span>
|
||
|
||
<span class="kn">from</span> <span class="nn">evennia.contrib.rpg.rpsystem</span> <span class="kn">import</span> <span class="n">rplanguage</span>
|
||
<span class="n">grammar</span> <span class="o">=</span> <span class="p">(</span><span class="o">...</span><span class="p">)</span>
|
||
<span class="n">vowels</span> <span class="o">=</span> <span class="s2">"eaouy"</span>
|
||
<span class="c1"># etc</span>
|
||
|
||
<span class="n">rplanguage</span><span class="o">.</span><span class="n">add_language</span><span class="p">(</span><span class="n">grammar</span><span class="o">=</span><span class="n">grammar</span><span class="p">,</span> <span class="n">vowels</span><span class="o">=</span><span class="n">vowels</span><span class="p">,</span> <span class="o">...</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The variables of <strong>add_language</strong> allows you to customize the “feel” of
|
||
the semi-random language you are creating. Especially
|
||
the <strong>word_length_variance</strong> helps vary the length of translated
|
||
words compared to the original. You can also add your own
|
||
dictionary and “fix” random words for a list of input words.</p>
|
||
</section>
|
||
<section id="example">
|
||
<h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2>
|
||
<p>Below is an example module creating “elvish”, using “rounder” vowels and sounds:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># vowel/consonant grammar possibilities</span>
|
||
<span class="n">grammar</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"v vv vvc vcc vvcc cvvc vccv vvccv vcvccv vcvcvcc vvccvvcc "</span>
|
||
<span class="s2">"vcvvccvvc cvcvvcvvcc vcvcvvccvcvv"</span><span class="p">)</span>
|
||
|
||
<span class="c1"># all not in this group is considered a consonant</span>
|
||
<span class="n">vowels</span> <span class="o">=</span> <span class="s2">"eaoiuy"</span>
|
||
|
||
<span class="c1"># you need a representative of all of the minimal grammars here, so if a</span>
|
||
<span class="c1"># grammar v exists, there must be atleast one phoneme available with only</span>
|
||
<span class="c1"># one vowel in it</span>
|
||
<span class="n">phonemes</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"oi oh ee ae aa eh ah ao aw ay er ey ow ia ih iy "</span>
|
||
<span class="s2">"oy ua uh uw y p b t d f v t dh s z sh zh ch jh k "</span>
|
||
<span class="s2">"ng g m n l r w"</span><span class="p">)</span>
|
||
|
||
<span class="c1"># how much the translation varies in length compared to the original. 0 is</span>
|
||
<span class="c1"># smallest, higher values give ever bigger randomness (including removing</span>
|
||
<span class="c1"># short words entirely)</span>
|
||
<span class="n">word_length_variance</span> <span class="o">=</span> <span class="mi">1</span>
|
||
|
||
<span class="c1"># if a proper noun (word starting with capitalized letter) should be</span>
|
||
<span class="c1"># translated or not. If not (default) it means e.g. names will remain</span>
|
||
<span class="c1"># unchanged across languages.</span>
|
||
<span class="n">noun_translate</span> <span class="o">=</span> <span class="kc">False</span>
|
||
|
||
<span class="c1"># all proper nouns (words starting with a capital letter not at the beginning</span>
|
||
<span class="c1"># of a sentence) can have either a postfix or -prefix added at all times</span>
|
||
<span class="n">noun_postfix</span> <span class="o">=</span> <span class="s2">"'la"</span>
|
||
|
||
<span class="c1"># words in dict will always be translated this way. The 'auto_translations'</span>
|
||
<span class="c1"># is instead a list or filename to file with words to use to help build a</span>
|
||
<span class="c1"># bigger dictionary by creating random translations of each word in the</span>
|
||
<span class="c1"># list *once* and saving the result for subsequent use.</span>
|
||
<span class="n">manual_translations</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"the"</span><span class="p">:</span><span class="s2">"y'e"</span><span class="p">,</span> <span class="s2">"we"</span><span class="p">:</span><span class="s2">"uyi"</span><span class="p">,</span> <span class="s2">"she"</span><span class="p">:</span><span class="s2">"semi"</span><span class="p">,</span> <span class="s2">"he"</span><span class="p">:</span><span class="s2">"emi"</span><span class="p">,</span>
|
||
<span class="s2">"you"</span><span class="p">:</span> <span class="s2">"do"</span><span class="p">,</span> <span class="s1">'me'</span><span class="p">:</span><span class="s1">'mi'</span><span class="p">,</span><span class="s1">'i'</span><span class="p">:</span><span class="s1">'me'</span><span class="p">,</span> <span class="s1">'be'</span><span class="p">:</span><span class="s2">"hy'e"</span><span class="p">,</span> <span class="s1">'and'</span><span class="p">:</span><span class="s1">'y'</span><span class="p">}</span>
|
||
|
||
<span class="n">rplanguage</span><span class="o">.</span><span class="n">add_language</span><span class="p">(</span><span class="n">key</span><span class="o">=</span><span class="s2">"elvish"</span><span class="p">,</span> <span class="n">phonemes</span><span class="o">=</span><span class="n">phonemes</span><span class="p">,</span> <span class="n">grammar</span><span class="o">=</span><span class="n">grammar</span><span class="p">,</span>
|
||
<span class="n">word_length_variance</span><span class="o">=</span><span class="n">word_length_variance</span><span class="p">,</span>
|
||
<span class="n">noun_translate</span><span class="o">=</span><span class="n">noun_translate</span><span class="p">,</span>
|
||
<span class="n">noun_postfix</span><span class="o">=</span><span class="n">noun_postfix</span><span class="p">,</span> <span class="n">vowels</span><span class="o">=</span><span class="n">vowels</span><span class="p">,</span>
|
||
<span class="n">manual_translations</span><span class="o">=</span><span class="n">manual_translations</span><span class="p">,</span>
|
||
<span class="n">auto_translations</span><span class="o">=</span><span class="s2">"my_word_file.txt"</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>This will produce a decicively more “rounded” and “soft” language
|
||
than the default one. The few manual_translations also make sure
|
||
to make it at least look superficially “reasonable”.</p>
|
||
<p>The <strong>auto_translations</strong> keyword is useful, this accepts either a
|
||
list or a path to a file of words (one per line) to automatically
|
||
create fixed translations for according to the grammatical rules.
|
||
This allows to quickly build a large corpus of translated words
|
||
that never change (if this is desired).</p>
|
||
<dl class="py exception">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.LanguageError">
|
||
<em class="property">exception </em><code class="sig-prename descclassname">evennia.contrib.rpg.rpsystem.rplanguage.</code><code class="sig-name descname">LanguageError</code><a class="reference internal" href="../_modules/evennia/contrib/rpg/rpsystem/rplanguage.html#LanguageError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageError" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">RuntimeError</span></code></p>
|
||
</dd></dl>
|
||
|
||
<dl class="py exception">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.LanguageExistsError">
|
||
<em class="property">exception </em><code class="sig-prename descclassname">evennia.contrib.rpg.rpsystem.rplanguage.</code><code class="sig-name descname">LanguageExistsError</code><a class="reference internal" href="../_modules/evennia/contrib/rpg/rpsystem/rplanguage.html#LanguageExistsError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageExistsError" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <a class="reference internal" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageError" title="evennia.contrib.rpg.rpsystem.rplanguage.LanguageError"><code class="xref py py-class docutils literal notranslate"><span class="pre">evennia.contrib.rpg.rpsystem.rplanguage.LanguageError</span></code></a></p>
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.contrib.rpg.rpsystem.rplanguage.</code><code class="sig-name descname">LanguageHandler</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/rpg/rpsystem/rplanguage.html#LanguageHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <a class="reference internal" href="evennia.scripts.scripts.html#evennia.scripts.scripts.DefaultScript" title="evennia.scripts.scripts.DefaultScript"><code class="xref py py-class docutils literal notranslate"><span class="pre">evennia.scripts.scripts.DefaultScript</span></code></a></p>
|
||
<p>This is a storage class that should usually not be created on its
|
||
own. It’s automatically created by a call to <strong>obfuscate_language</strong>
|
||
or <strong>add_language</strong> below.</p>
|
||
<p>Languages are implemented as a “logical” pseudo- consistent language
|
||
algorith here. The idea is that a language is built up from
|
||
phonemes. These are joined together according to a “grammar” of
|
||
possible phoneme- combinations and allowed characters. It may
|
||
sound simplistic, but this allows to easily make
|
||
“similar-sounding” languages. One can also custom-define a
|
||
dictionary of some common words to give further consistency.
|
||
Optionally, the system also allows an input list of common words
|
||
to be loaded and given random translations. These will be stored
|
||
to disk and will thus not change. This gives a decent “stability”
|
||
of the language but if the goal is to obfuscate, this may allow
|
||
players to eventually learn to understand the gist of a sentence
|
||
even if their characters can not. Any number of languages can be
|
||
created this way.</p>
|
||
<p>This nonsense language will partially replace the actual spoken
|
||
language when so desired (usually because the speaker/listener
|
||
don’t know the language well enough).</p>
|
||
<dl class="py method">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.at_script_creation">
|
||
<code class="sig-name descname">at_script_creation</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/rpg/rpsystem/rplanguage.html#LanguageHandler.at_script_creation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.at_script_creation" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Called when script is first started</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.add">
|
||
<code class="sig-name descname">add</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span><span class="o">=</span><span class="default_value">'default'</span></em>, <em class="sig-param"><span class="n">phonemes</span><span class="o">=</span><span class="default_value">'ea oh ae aa eh ah ao aw ai er ey ow ia ih iy oy ua uh uw a e i u y p b t d f v t dh s z sh zh ch jh k ng g m n l r w'</span></em>, <em class="sig-param"><span class="n">grammar</span><span class="o">=</span><span class="default_value">'v cv vc cvv vcc vcv cvcc vccv cvccv cvcvcc cvccvcv vccvccvc cvcvccvv cvcvcvcvv'</span></em>, <em class="sig-param"><span class="n">word_length_variance</span><span class="o">=</span><span class="default_value">0</span></em>, <em class="sig-param"><span class="n">noun_translate</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">noun_prefix</span><span class="o">=</span><span class="default_value">''</span></em>, <em class="sig-param"><span class="n">noun_postfix</span><span class="o">=</span><span class="default_value">''</span></em>, <em class="sig-param"><span class="n">vowels</span><span class="o">=</span><span class="default_value">'eaoiuy'</span></em>, <em class="sig-param"><span class="n">manual_translations</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">auto_translations</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">force</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/rpg/rpsystem/rplanguage.html#LanguageHandler.add"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.add" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Add a new language. Note that you generally only need to do
|
||
this once per language and that adding an existing language
|
||
will re-initialize all the random components to new permanent
|
||
values.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>optional</em>) – The name of the language. This
|
||
will be used as an identifier for the language so it
|
||
should be short and unique.</p></li>
|
||
<li><p><strong>phonemes</strong> (<em>str</em><em>, </em><em>optional</em>) – Space-separated string of all allowed
|
||
phonemes in this language. If either of the base phonemes
|
||
(c, v, cc, vv) are present in the grammar, the phoneme list must
|
||
at least include one example of each.</p></li>
|
||
<li><p><strong>grammar</strong> (<em>str</em>) – All allowed consonant (c) and vowel (v) combinations
|
||
allowed to build up words. Grammars are broken into the base phonemes
|
||
(c, v, cc, vv) prioritizing the longer bases. So cvv would be a
|
||
the c + vv (would allow for a word like ‘die’ whereas
|
||
cvcvccc would be c+v+c+v+cc+c (a word like ‘galosch’).</p></li>
|
||
<li><p><strong>word_length_variance</strong> (<em>real</em>) – The variation of length of words.
|
||
0 means a minimal variance, higher variance may mean words
|
||
have wildly varying length; this strongly affects how the
|
||
language “looks”.</p></li>
|
||
<li><p><strong>noun_translate</strong> (<em>bool</em><em>, </em><em>optional</em>) – If a proper noun should be translated or
|
||
not. By default they will not, allowing for e.g. the names of characters
|
||
to be understandable. A ‘noun’ is identified as a capitalized word
|
||
<em>not at the start of a sentence</em>. This simple metric means that names
|
||
starting a sentence always will be translated (- but hey, maybe
|
||
the fantasy language just never uses a noun at the beginning of
|
||
sentences, who knows?)</p></li>
|
||
<li><p><strong>noun_prefix</strong> (<em>str</em><em>, </em><em>optional</em>) – A prefix to go before every noun
|
||
in this language (if any).</p></li>
|
||
<li><p><strong>noun_postfix</strong> (<em>str</em><em>, </em><em>optuonal</em>) – A postfix to go after every noun
|
||
in this language (if any, usually best to avoid combining
|
||
with <strong>noun_prefix</strong> or language becomes very wordy).</p></li>
|
||
<li><p><strong>vowels</strong> (<em>str</em><em>, </em><em>optional</em>) – Every vowel allowed in this language.</p></li>
|
||
<li><p><strong>manual_translations</strong> (<em>dict</em><em>, </em><em>optional</em>) – This allows for custom-setting
|
||
certain words in the language to mean the same thing. It is
|
||
on the form <strong>{real_word: fictional_word}</strong>, for example
|
||
<strong>{“the”, “y’e”}</strong> .</p></li>
|
||
<li><p><strong>auto_translations</strong> (<em>str</em><em> or </em><em>list</em><em>, </em><em>optional</em>) – These are lists
|
||
words that should be auto-translated with a random, but
|
||
fixed, translation. If a path to a file, this file should
|
||
contain a list of words to produce translations for, one
|
||
word per line. If a list, the list’s elements should be
|
||
the words to translate. The <strong>manual_translations</strong> will
|
||
always override overlapping translations created
|
||
automatically.</p></li>
|
||
<li><p><strong>force</strong> (<em>bool</em><em>, </em><em>optional</em>) – Unless true, will not allow the addition
|
||
of a language that is already created.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Raises</dt>
|
||
<dd class="field-even"><p><a class="reference internal" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageExistsError" title="evennia.contrib.rpg.rpsystem.rplanguage.LanguageExistsError"><strong>LanguageExistsError</strong></a> – Raised if trying to adding a language
|
||
with a key that already exists, without <strong>force</strong> being set.</p>
|
||
</dd>
|
||
</dl>
|
||
<p class="rubric">Notes</p>
|
||
<p>The <strong>word_file</strong> is for example a word-frequency list for
|
||
the N most common words in the host language. The
|
||
translations will be random, but will be stored
|
||
persistently to always be the same. This allows for
|
||
building a quick, decently-sounding fictive language that
|
||
tend to produce the same “translation” (mostly) with the
|
||
same input sentence.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.translate">
|
||
<code class="sig-name descname">translate</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">text</span></em>, <em class="sig-param"><span class="n">level</span><span class="o">=</span><span class="default_value">0.0</span></em>, <em class="sig-param"><span class="n">language</span><span class="o">=</span><span class="default_value">'default'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/rpg/rpsystem/rplanguage.html#LanguageHandler.translate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.translate" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Translate the text according to the given level.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>text</strong> (<em>str</em>) – The text to translate</p></li>
|
||
<li><p><strong>level</strong> (<em>real</em>) – Value between 0.0 and 1.0, where
|
||
0.0 means no obfuscation (text returned unchanged) and
|
||
1.0 means full conversion of every word. The closer to
|
||
1, the shorter words will be translated.</p></li>
|
||
<li><p><strong>language</strong> (<em>str</em>) – The language key identifier.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><em>text (str)</em> – A translated string.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py exception">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.DoesNotExist">
|
||
<em class="property">exception </em><code class="sig-name descname">DoesNotExist</code><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.DoesNotExist" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <a class="reference internal" href="evennia.scripts.scripts.html#evennia.scripts.scripts.DefaultScript.DoesNotExist" title="evennia.scripts.scripts.DefaultScript.DoesNotExist"><code class="xref py py-class docutils literal notranslate"><span class="pre">evennia.scripts.scripts.DefaultScript.DoesNotExist</span></code></a></p>
|
||
</dd></dl>
|
||
|
||
<dl class="py exception">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.MultipleObjectsReturned">
|
||
<em class="property">exception </em><code class="sig-name descname">MultipleObjectsReturned</code><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.MultipleObjectsReturned" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <a class="reference internal" href="evennia.scripts.scripts.html#evennia.scripts.scripts.DefaultScript.MultipleObjectsReturned" title="evennia.scripts.scripts.DefaultScript.MultipleObjectsReturned"><code class="xref py py-class docutils literal notranslate"><span class="pre">evennia.scripts.scripts.DefaultScript.MultipleObjectsReturned</span></code></a></p>
|
||
</dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.path">
|
||
<code class="sig-name descname">path</code><em class="property"> = 'evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler'</em><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.path" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.typename">
|
||
<code class="sig-name descname">typename</code><em class="property"> = 'LanguageHandler'</em><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.LanguageHandler.typename" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.obfuscate_language">
|
||
<code class="sig-prename descclassname">evennia.contrib.rpg.rpsystem.rplanguage.</code><code class="sig-name descname">obfuscate_language</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">text</span></em>, <em class="sig-param"><span class="n">level</span><span class="o">=</span><span class="default_value">0.0</span></em>, <em class="sig-param"><span class="n">language</span><span class="o">=</span><span class="default_value">'default'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/rpg/rpsystem/rplanguage.html#obfuscate_language"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.obfuscate_language" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Main access method for the language parser.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>text</strong> (<em>str</em>) – Text to obfuscate.</p></li>
|
||
<li><p><strong>level</strong> (<em>real</em><em>, </em><em>optional</em>) – A value from 0.0-1.0 determining
|
||
the level of obfuscation where 0 means no obfuscation
|
||
(string returned unchanged) and 1.0 means the entire
|
||
string is obfuscated.</p></li>
|
||
<li><p><strong>language</strong> (<em>str</em><em>, </em><em>optional</em>) – The identifier of a language
|
||
the system understands.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><em>translated (str)</em> – The translated text.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.add_language">
|
||
<code class="sig-prename descclassname">evennia.contrib.rpg.rpsystem.rplanguage.</code><code class="sig-name descname">add_language</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/rpg/rpsystem/rplanguage.html#add_language"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.add_language" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Access function to creating a new language. See the docstring of
|
||
<strong>LanguageHandler.add</strong> for list of keyword arguments.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.available_languages">
|
||
<code class="sig-prename descclassname">evennia.contrib.rpg.rpsystem.rplanguage.</code><code class="sig-name descname">available_languages</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/rpg/rpsystem/rplanguage.html#available_languages"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.available_languages" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Returns all available language keys.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p><em>languages (list)</em> – List of key strings of all available
|
||
languages.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt id="evennia.contrib.rpg.rpsystem.rplanguage.obfuscate_whisper">
|
||
<code class="sig-prename descclassname">evennia.contrib.rpg.rpsystem.rplanguage.</code><code class="sig-name descname">obfuscate_whisper</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">whisper</span></em>, <em class="sig-param"><span class="n">level</span><span class="o">=</span><span class="default_value">0.0</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/rpg/rpsystem/rplanguage.html#obfuscate_whisper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.rpg.rpsystem.rplanguage.obfuscate_whisper" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Obfuscate whisper depending on a pre-calculated level
|
||
(that may depend on distance, listening skill etc)</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>whisper</strong> (<em>str</em>) – The whisper string to obscure. The
|
||
entire string will be considered in the obscuration.</p></li>
|
||
<li><p><strong>level</strong> (<em>real</em><em>, </em><em>optional</em>) – This is a value 0-1, where 0
|
||
means not obscured (whisper returned unchanged) and 1
|
||
means fully obscured.</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</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="evennia.contrib.rpg.rpsystem.rpsystem.html" title="evennia.contrib.rpg.rpsystem.rpsystem"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.contrib.rpg.rpsystem.html" title="evennia.contrib.rpg.rpsystem"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 2.x</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.contrib.html" >evennia.contrib</a> »</li>
|
||
<li class="nav-item nav-item-5"><a href="evennia.contrib.rpg.html" >evennia.contrib.rpg</a> »</li>
|
||
<li class="nav-item nav-item-6"><a href="evennia.contrib.rpg.rpsystem.html" >evennia.contrib.rpg.rpsystem</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.contrib.rpg.rpsystem.rplanguage</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
|
||
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2023, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
|
||
</div>
|
||
</body>
|
||
</html> |