renpy/doc/developer_tools.html

396 lines
25 KiB
HTML
Raw Normal View History

2023-01-18 22:13:55 +00:00
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Developer Tools &#8212; Ren&#39;Py Documentation</title>
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="_static/js/jquery-fix.js"></script>
<script type="text/javascript" src="_static/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="_static/bootstrap-sphinx.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Interactive Director" href="director.html" />
<link rel="prev" title="Launcher" href="launcher.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
</head><body>
<div id="navbar" class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">
Ren&#39;Py Documentation</a>
<span class="navbar-text navbar-version pull-left"><b>7.5.3</b></span>
</div>
<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">
<li><a href="https://www.renpy.org">Home Page</a></li>
<li><a href="https://www.renpy.org/doc/html/">Online Documentation</a></li>
<li class="dropdown globaltoc-container">
<a role="button"
id="dLabelGlobalToc"
data-toggle="dropdown"
data-target="#"
href="index.html">Site <b class="caret"></b></a>
<ul class="dropdown-menu globaltoc"
role="menu"
aria-labelledby="dLabelGlobalToc"><ul>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="gui.html">GUI Customization Guide</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="language_basics.html">Language Basics</a></li>
<li class="toctree-l1"><a class="reference internal" href="label.html">Labels &amp; Control Flow</a></li>
<li class="toctree-l1"><a class="reference internal" href="dialogue.html">Dialogue and Narration</a></li>
<li class="toctree-l1"><a class="reference internal" href="displaying_images.html">Displaying Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="menus.html">In-Game Menus</a></li>
<li class="toctree-l1"><a class="reference internal" href="python.html">Python Statements</a></li>
<li class="toctree-l1"><a class="reference internal" href="conditional.html">Conditional Statements</a></li>
<li class="toctree-l1"><a class="reference internal" href="audio.html">Audio</a></li>
<li class="toctree-l1"><a class="reference internal" href="movie.html">Movie</a></li>
<li class="toctree-l1"><a class="reference internal" href="voice.html">Voice</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="text.html">Text</a></li>
<li class="toctree-l1"><a class="reference internal" href="translation.html">Translation</a></li>
<li class="toctree-l1"><a class="reference internal" href="displayables.html">Displayables</a></li>
<li class="toctree-l1"><a class="reference internal" href="transforms.html">Transforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="transitions.html">Transitions</a></li>
<li class="toctree-l1"><a class="reference internal" href="atl.html">Animation and Transformation Language</a></li>
<li class="toctree-l1"><a class="reference internal" href="matrixcolor.html">Matrixcolor</a></li>
<li class="toctree-l1"><a class="reference internal" href="layeredimage.html">Layered Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="3dstage.html">3D Stage</a></li>
<li class="toctree-l1"><a class="reference internal" href="live2d.html">Live2D Cubism</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="style.html">Styles</a></li>
<li class="toctree-l1"><a class="reference internal" href="style_properties.html">Style Properties</a></li>
<li class="toctree-l1"><a class="reference internal" href="screens.html">Screens and Screen Language</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_actions.html">Screen Actions, Values, and Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_special.html">Special Screen Names</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_optimization.html">Screen Language Optimization</a></li>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="preferences.html">Preference Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="store_variables.html">Store Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="mouse.html">Custom Mouse Cursors</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="launcher.html">Launcher</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Developer Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="director.html">Interactive Director</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="nvl_mode.html">NVL-Mode Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="input.html">Text Input</a></li>
<li class="toctree-l1"><a class="reference internal" href="side_image.html">Side Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="rooms.html">Image Gallery, Music Room, and Replay Actions</a></li>
<li class="toctree-l1"><a class="reference internal" href="drag_drop.html">Drag and Drop</a></li>
<li class="toctree-l1"><a class="reference internal" href="sprites.html">Sprites</a></li>
<li class="toctree-l1"><a class="reference internal" href="keymap.html">Customizing the Keymap</a></li>
<li class="toctree-l1"><a class="reference internal" href="achievement.html">Achievements</a></li>
<li class="toctree-l1"><a class="reference internal" href="history.html">Dialogue History</a></li>
<li class="toctree-l1"><a class="reference internal" href="multiple.html">Multiple Character Dialogue</a></li>
<li class="toctree-l1"><a class="reference internal" href="splashscreen_presplash.html">Splashscreen and Presplash</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="statement_equivalents.html">Statement Equivalents</a></li>
<li class="toctree-l1"><a class="reference internal" href="save_load_rollback.html">Saving, Loading, and Rollback</a></li>
<li class="toctree-l1"><a class="reference internal" href="persistent.html">Persistent Data</a></li>
<li class="toctree-l1"><a class="reference internal" href="trans_trans_python.html">Transforms and Transitions in Python</a></li>
<li class="toctree-l1"><a class="reference internal" href="gui_advanced.html">Advanced GUI</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_python.html">Screens and Python</a></li>
<li class="toctree-l1"><a class="reference internal" href="modes.html">Modes</a></li>
<li class="toctree-l1"><a class="reference internal" href="cdd.html">Creator-Defined Displayables</a></li>
<li class="toctree-l1"><a class="reference internal" href="cds.html">Creator-Defined Statements</a></li>
<li class="toctree-l1"><a class="reference internal" href="custom_text_tags.html">Custom Text Tags</a></li>
<li class="toctree-l1"><a class="reference internal" href="character_callbacks.html">Character Callbacks</a></li>
<li class="toctree-l1"><a class="reference internal" href="file_python.html">File Access</a></li>
<li class="toctree-l1"><a class="reference internal" href="color_class.html">Color Class</a></li>
<li class="toctree-l1"><a class="reference internal" href="matrix.html">Matrix</a></li>
<li class="toctree-l1"><a class="reference internal" href="model.html">Model-Based Rendering</a></li>
<li class="toctree-l1"><a class="reference internal" href="other.html">Other Functions and Variables</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="build.html">Building Distributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="updater.html">Web Updater</a></li>
<li class="toctree-l1"><a class="reference internal" href="android.html">Android</a></li>
<li class="toctree-l1"><a class="reference internal" href="chromeos.html">Chrome OS/Chromebook</a></li>
<li class="toctree-l1"><a class="reference internal" href="ios.html">iOS</a></li>
<li class="toctree-l1"><a class="reference internal" href="iap.html">In-App Purchasing</a></li>
<li class="toctree-l1"><a class="reference internal" href="gesture.html">Gestures</a></li>
<li class="toctree-l1"><a class="reference internal" href="raspi.html">Raspberry Pi</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="security.html">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="problems.html">Dealing with Problems</a></li>
<li class="toctree-l1"><a class="reference internal" href="environment_variables.html">Environment Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="self_voicing.html">Self-Voicing</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="editor.html">Text Editor Integration</a></li>
<li class="toctree-l1"><a class="reference internal" href="skins.html">Skins</a></li>
<li class="toctree-l1"><a class="reference internal" href="translating_renpy.html">Translating Ren'Py</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog (Ren'Py 7.x-)</a></li>
<li class="toctree-l1"><a class="reference internal" href="changelog6.html">Changelog (Ren'Py 6.11 - 6.99)</a></li>
<li class="toctree-l1"><a class="reference internal" href="incompatible.html">Incompatible Changes</a></li>
<li class="toctree-l1"><a class="reference internal" href="distributor.html">Distributor Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
<li class="toctree-l1"><a class="reference internal" href="credits.html">Credits</a></li>
<li class="toctree-l1"><a class="reference internal" href="sponsors.html">Ren'Py Development Sponsors</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="thequestion.html">Script of The Question</a></li>
<li class="toctree-l1"><a class="reference internal" href="thequestion_nvl.html">NVL-mode script for The Question</a></li>
</ul>
</ul>
</li>
</ul>
<form class="navbar-form navbar-right" action="search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3">
<div id="sidebar" class="bs-sidenav" role="complementary"><ul>
<li><a class="reference internal" href="#">Developer Tools</a><ul>
<li><a class="reference internal" href="#lint">Lint</a></li>
<li><a class="reference internal" href="#shift-o-console">Shift+O Console</a></li>
<li><a class="reference internal" href="#shift-e-editor-support">Shift+E Editor Support</a></li>
<li><a class="reference internal" href="#shift-d-developer-menu">Shift+D Developer Menu</a></li>
<li><a class="reference internal" href="#shift-r-reloading">Shift+R Reloading</a></li>
<li><a class="reference internal" href="#shift-i-style-inspecting">Shift+I Style Inspecting</a></li>
<li><a class="reference internal" href="#fast-skipping">&gt; Fast Skipping</a></li>
<li><a class="reference internal" href="#warping-to-a-line">Warping to a Line</a></li>
<li><a class="reference internal" href="#debug-functions">Debug Functions</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="col-md-9 content">
<div class="section" id="developer-tools">
<h1>Developer Tools<a class="headerlink" href="#developer-tools" title="Permalink to this headline"> link</a></h1>
<p>Ren'Py includes a number of features to make a developer's life easier. Many of
them need the variable <a class="reference internal" href="config.html#var-config.developer"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.developer</span></code></a> to be set to True to operate.</p>
<div class="section" id="lint">
<span id="id1"></span><h2>Lint<a class="headerlink" href="#lint" title="Permalink to this headline"> link</a></h2>
<p>The Lint tool (available from the launcher) checks the game for potential errors
or misoptimizations, and advises the developing team about how to best improve it.
Since some of these errors will only affect users on other platforms, its
recommended to understand and fix all errors, even if the problem can't be
triggered locally.</p>
<p>Lint also includes useful infos and stats about the game.</p>
<p>Note that using Lint is not a substitute for thorough testing.</p>
</div>
<div class="section" id="shift-o-console">
<h2>Shift+O Console<a class="headerlink" href="#shift-o-console" title="Permalink to this headline"> link</a></h2>
<p>The debug console makes it possible to interactively run Ren'Py script and
Python statements, and immediately see the results. The console is available in
developer mode or when <code class="xref std std-var docutils literal notranslate"><span class="pre">config.console</span></code> is True, and can be accessed by
pressing Shift+O.</p>
<p>The console can be used to:</p>
<ul class="simple">
<li>Jump to a label.</li>
<li>Interactively try out Ren'Py script statements.</li>
<li>Evaluate a Python expression or statement to see the result.</li>
<li>Trace Python expressions as the game progresses.</li>
</ul>
<p>commands:</p>
<ul class="simple">
<li>clear: clear the console history</li>
<li>escape: Enables escaping of unicode symbols in unicode strings.</li>
<li>exit: exit the console</li>
<li>help: show this help</li>
<li>jump &lt;label&gt;: jumps to label</li>
<li>load &lt;slot&gt;: loads the game from slot</li>
<li>long: Print the full representation of objects on the console.</li>
<li>reload: reloads the game, refreshing the scripts</li>
<li>save &lt;slot&gt;: saves the game in slot</li>
<li>short: Shorten the representation of objects on the console (default).</li>
<li>stack: print the return stack</li>
<li>unescape: Disables escaping of unicode symbols in unicode strings and print it as is (default).</li>
<li>unwatch &lt;expression&gt;: stop watching an expression</li>
<li>unwatchall: stop watching all expressions</li>
<li>watch &lt;expression&gt;: watch a python expression</li>
<li>watch short: makes the representation of traced expressions short (default)</li>
<li>watch long: makes the representation of traced expressions as is</li>
<li>&lt;renpy script statement&gt;: run the statement</li>
<li>&lt;python expression or statement&gt;: run the expression or statement</li>
</ul>
</div>
<div class="section" id="shift-e-editor-support">
<h2>Shift+E Editor Support<a class="headerlink" href="#shift-e-editor-support" title="Permalink to this headline"> link</a></h2>
<p>The <code class="xref std std-var docutils literal notranslate"><span class="pre">config.editor</span></code> variable allows a developer to specify an editor
command that is run when the launch_editor keypress (by default, Shift+E)
occurs.</p>
<p>Please see <a class="reference internal" href="editor.html"><span class="doc">Text Editor Integration</span></a>.</p>
</div>
<div class="section" id="shift-d-developer-menu">
<h2>Shift+D Developer Menu<a class="headerlink" href="#shift-d-developer-menu" title="Permalink to this headline"> link</a></h2>
<p>When <a class="reference internal" href="config.html#var-config.developer"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.developer</span></code></a> is true, hitting Shift+D will display a developer
menu that provides easy access to some of the features given below.</p>
</div>
<div class="section" id="shift-r-reloading">
<h2>Shift+R Reloading<a class="headerlink" href="#shift-r-reloading" title="Permalink to this headline"> link</a></h2>
<p>When <a class="reference internal" href="config.html#var-config.developer"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.developer</span></code></a> is True, hitting Shift+R will save the current
game, reload the game script, and reload the game. This will often place you at
the last unchanged statement encountered before Shift+R was pressed.</p>
<p>This allows the developer to make script changes with an external editor, and
not have to exit and restart Ren'Py to see the effect of the changes.</p>
<p>Note that game state, which includes variable values and scene lists, is
preserved across the reload. This means that if one of those statements is
changed, it is necessary to rollback and re-execute the statement to see its
new effect.</p>
</div>
<div class="section" id="shift-i-style-inspecting">
<h2>Shift+I Style Inspecting<a class="headerlink" href="#shift-i-style-inspecting" title="Permalink to this headline"> link</a></h2>
<p>When <a class="reference internal" href="config.html#var-config.developer"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.developer</span></code></a> is true, pressing Shift+I will cause style
inspection to occur. This will display a list of displayables underneath the
mouse. For each displayable, it will display the type, the style used, and the
size it is being rendered at.</p>
<p>Clicking on the style name will display where the style properties used by the
displayable are taken from.</p>
</div>
<div class="section" id="fast-skipping">
<h2>&gt; Fast Skipping<a class="headerlink" href="#fast-skipping" title="Permalink to this headline"> link</a></h2>
<p>When <a class="reference internal" href="config.html#var-config.developer"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.developer</span></code></a> or <a class="reference internal" href="config.html#var-config.fast_skipping"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.fast_skipping</span></code></a> is True, pressing
the <cite>fast_skip</cite> key (by default, &quot;&gt;&quot;) causes the the game to immediately skip to
the next important interaction. For this purpose, an important interaction is
one that is not caused by a say statement, transition, or pause command.
Usually, this means skipping to the next menu, but it will also stop when
user-defined forms of interaction occur.</p>
</div>
<div class="section" id="warping-to-a-line">
<span id="id2"></span><h2>Warping to a Line<a class="headerlink" href="#warping-to-a-line" title="Permalink to this headline"> link</a></h2>
<p>Ren'Py supports warping to a line in the script, without the developer to play
through the entire game to get there. While this warping technique has a number
of warnings associated with it, it still may be useful in providing a live
preview.</p>
<p>To invoke warping, run Ren'Py with the <code class="docutils literal notranslate"><span class="pre">--warp</span></code> command-line argument followed
by a filename:line combination, to specify where you would like to warp to. For
example:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="n">renpy</span><span class="o">.</span><span class="n">exe</span> <span class="n">my_project</span> <span class="o">--</span><span class="n">warp</span> <span class="n">script</span><span class="o">.</span><span class="k">rpy</span><span class="p">:</span><span class="mi">458</span>
</pre></div>
</div>
<p>(Where <cite>my_project</cite> is the full path to the base directory of your project.)</p>
<p>When warping is invoked, Ren'Py does a number of things. It first finds all of
the scene statements in the program. It then tries to find a path from the
scene statements to every reachable statement in the game. It then picks the
reachable statement closest to, but before or at, the given line. It works
backwards from that statement to a scene statement, recording the path it took.
Ren'Py then executes the scene statement and any show or hide statements found
along that path. Finally, it transfers control to the found statement.</p>
<p>There are a number of fairly major caveats to the warp feature. The first is
that it only examines a single path, which means that while the path may be
representative of some route of execution, it's possible that there may be a
bug along some other route. In general, the path doesn't consider game logic,
so it's also possible to have a path that isn't actually reachable. (This is
only really a problem on control-heavy games, especially those that use a lot of
Python.</p>
<p>The biggest problem, though, is that Python is not executed before the
statement that is warped to. This means that all variables will be
uninitialized, which can lead to crashes when they are used. To overcome this,
one can define a label <code class="docutils literal notranslate"><span class="pre">after_warp</span></code>, which is called after a warp but before
the warped-to statement executes. This label can set up variables in the
program, and then return to the preview.</p>
<p>The warp feature requires <a class="reference internal" href="config.html#var-config.developer"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.developer</span></code></a> to be True to operate.</p>
</div>
<div class="section" id="debug-functions">
<h2>Debug Functions<a class="headerlink" href="#debug-functions" title="Permalink to this headline"> link</a></h2>
<dl class="function">
<dt id="renpy.get_filename_line">
<code class="descclassname">renpy.</code><code class="descname">get_filename_line</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#renpy.get_filename_line" title="Permalink to this definition"> link</a></dt>
<dd><p>Returns a pair giving the filename and line number of the current
statement.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.log">
<code class="descclassname">renpy.</code><code class="descname">log</code><span class="sig-paren">(</span><em>msg</em><span class="sig-paren">)</span><a class="headerlink" href="#renpy.log" title="Permalink to this definition"> link</a></dt>
<dd><p>If <a class="reference internal" href="config.html#var-config.log"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.log</span></code></a> is not set, this does nothing. Otherwise, it opens
the logfile (if not already open), formats the message to <a class="reference internal" href="config.html#var-config.log_width"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.log_width</span></code></a>
columns, and prints it to the logfile.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.unwatch">
<code class="descclassname">renpy.</code><code class="descname">unwatch</code><span class="sig-paren">(</span><em>expr</em><span class="sig-paren">)</span><a class="headerlink" href="#renpy.unwatch" title="Permalink to this definition"> link</a></dt>
<dd><p>Stops watching the given Python expression.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.watch">
<code class="descclassname">renpy.</code><code class="descname">watch</code><span class="sig-paren">(</span><em>expr</em><span class="sig-paren">)</span><a class="headerlink" href="#renpy.watch" title="Permalink to this definition"> link</a></dt>
<dd><p>This watches the given Python expression, by displaying it in the
upper-right corner of the screen.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-right">
<a href="#">Back to top</a>
</p>
<p>
&copy; Copyright 2012-2022, Tom Rothamel.<br/>
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.6.<br/>
</p>
</div>
</footer>
</body>
</html>