/usr/share/doc/renpy/html/label.html is in renpy-doc 6.17.6-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Labels & Control Flow — Ren'Py Documentation</title>
<link rel="stylesheet" href="_static/screen.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" media="print" />
<!--[if lt IE 8]>
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" media="screen, projection"/>
<![endif]-->
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '6.18.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</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>
<link rel="top" title="Ren'Py Documentation" href="index.html" />
<link rel="next" title="Dialogue and Narration" href="dialogue.html" />
<link rel="prev" title="Language Basics" href="language_basics.html" />
</head>
<body>
<div class="related">
<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="dialogue.html" title="Dialogue and Narration"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="language_basics.html" title="Language Basics"
accesskey="P">previous</a> |</li>
<li> <img src="_static/logo.png" width=19 height=21 align=center>
<li> <a href="http://www.renpy.org/">Ren'Py Home</a> |
<li><a href="index.html">Ren'Py Documentation</a></li>
</ul>
</div>
<div class="container">
<div class="span4">
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Labels & Control Flow</a><ul>
<li><a class="reference internal" href="#label-statement">Label Statement</a></li>
<li><a class="reference internal" href="#jump-statement">Jump Statement</a></li>
<li><a class="reference internal" href="#call-statement">Call Statement</a></li>
<li><a class="reference internal" href="#return-statement">Return Statement</a></li>
<li><a class="reference internal" href="#special-labels">Special Labels</a></li>
<li><a class="reference internal" href="#labels-control-flow-functions">Labels & Control Flow Functions</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="language_basics.html"
title="previous chapter">Language Basics</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="dialogue.html"
title="next chapter">Dialogue and Narration</a></p>
<h4>Search</h4>
<div id="cse-search-form" style="width: 100%;"></div>
<div class="copydata">
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
<br>
</div>
</div>
</div>
</div>
<div class="document span20 last">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="labels-control-flow">
<h1>Labels & Control Flow<a class="headerlink" href="#labels-control-flow" title="Permalink to this headline">¶</a></h1>
<div class="section" id="label-statement">
<h2>Label Statement<a class="headerlink" href="#label-statement" title="Permalink to this headline">¶</a></h2>
<p>Label statements allow the given name to be assigned to a program point. They
exist solely to be called or jumped to, whether by script code or the Ren'Py
config.</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">label</span> <span class="n">sample1</span><span class="p">:</span>
<span class="s">"Here is 'sample1' label."</span>
<span class="k">label</span> <span class="n">sample2</span><span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="s">"default"</span><span class="p">):</span>
<span class="s">"Here is 'sample2' label."</span>
<span class="s">"a = [a]"</span>
</pre></div>
</div>
<p>A label statement may have a block associated with it. In that case, control
enters the block whenever the label statement is reached, and proceeds with the
statement after the label statement whenever the end of the block is reached.</p>
<p>The label statement may take an optional list of parameters. These parameters
are processed as described in PEP 3102, with two exceptions:</p>
<ul class="simple">
<li>The values of default parameters are evaluated at call time.</li>
<li>The variables are dynamically, rather than lexically, scoped.</li>
</ul>
</div>
<div class="section" id="jump-statement">
<span id="id1"></span><h2>Jump Statement<a class="headerlink" href="#jump-statement" title="Permalink to this headline">¶</a></h2>
<p>The jump statement is used to transfer control to the given label.</p>
<p>If the <tt class="docutils literal"><span class="pre">expression</span></tt> keyword is present, the expression following it is
evaluated, and the string so computed is used as the label name of the
statement to jump to. If the <tt class="docutils literal"><span class="pre">expression</span></tt> keyword is not present, the label
name of the statement to jump to must be explicitly given.</p>
<p>Unlike call, jump does not push the next statement onto a stack. As a
result, there's no way to return to where you've jumped from.</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">label</span> <span class="n">loop_start</span><span class="p">:</span>
<span class="n">e</span> <span class="s">"Oh no! It looks like we're trapped in an infinite loop."</span>
<span class="k">jump</span> <span class="n">loop_start</span>
</pre></div>
</div>
</div>
<div class="section" id="call-statement">
<span id="id2"></span><h2>Call Statement<a class="headerlink" href="#call-statement" title="Permalink to this headline">¶</a></h2>
<p>The call statement is used to transfer control to the given label. It
also pushes the next statement onto the call stack, allowing the return statement
to return control to the statement following the call.</p>
<p>If the <tt class="docutils literal"><span class="pre">expression</span></tt> keyword is present, the expression following it is evaluated, and the
string so computed is used as the name of the label to call. If the
<tt class="docutils literal"><span class="pre">expression</span></tt> keyword is not present, the name of the statement to call must be
explicitly given.</p>
<p>If the optional from clause is present, it has the effect of including a label
statement with the given name as the statement immediately following the call
statement. An explicit label helps to ensure that saved games with return
stacks can return to the proper place when loaded on a changed script.</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="n">e</span> <span class="s">"First, we will call a subroutine."</span>
<span class="k">call</span> <span class="n">subroutine</span>
<span class="k">call</span> <span class="n">subroutine</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="k">call</span> <span class="k">expression</span> <span class="s">"subroutine"</span> <span class="k">pass</span> <span class="p">(</span><span class="n">count</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="c"># ...</span>
<span class="k">label</span> <span class="n">subroutine</span><span class="p">(</span><span class="n">count</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
<span class="n">e</span> <span class="s">"I camed here [count] time(s)."</span>
<span class="n">e</span> <span class="s">"Next, we will return from the subroutine."</span>
<span class="k">return</span>
</pre></div>
</div>
<p>The call statement may take arguments, which are processed as described in PEP
3102.</p>
<p>When using a call expression with an arguments list, the <tt class="docutils literal"><span class="pre">pass</span></tt> keyword must
be inserted between the expression and the arguments list. Otherwise, the
arguments list will be parsed as part of the expression, not as part of the
call.</p>
</div>
<div class="section" id="return-statement">
<span id="id3"></span><h2>Return Statement<a class="headerlink" href="#return-statement" title="Permalink to this headline">¶</a></h2>
<p>The return statement pops the top statement off of the call stack, and transfers
control to it. If the call stack is empty, the return statement restarts
Ren'Py, returning control to the main menu.</p>
<p>If the optional expression is given to return, it is evaluated, and it's result
is stored in the _return variable. This variable is dynamically scoped to each
context.</p>
</div>
<div class="section" id="special-labels">
<h2>Special Labels<a class="headerlink" href="#special-labels" title="Permalink to this headline">¶</a></h2>
<p>The following labels are used by Ren'Py:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">start</span></tt></dt>
<dd>By default, Ren'Py jumps to this label when the game starts.</dd>
<dt><tt class="docutils literal"><span class="pre">quit</span></tt></dt>
<dd>If it exists, this label is called in a new context when the user
quits the game.</dd>
<dt><tt class="docutils literal"><span class="pre">after_load</span></tt></dt>
<dd>If it exists, this label is called when a game is loaded. It can be
use to fix data when the game is updated.</dd>
<dt><tt class="docutils literal"><span class="pre">splashscreen</span></tt></dt>
<dd>If it exists, this label is called when the game is first run, before
showing the main menu.</dd>
<dt><tt class="docutils literal"><span class="pre">before_main_menu</span></tt></dt>
<dd>If it exists, this label is called before the main menu. It is used in
rare cases to set up the main menu, for example by starting a movie
playing in the background.</dd>
<dt><tt class="docutils literal"><span class="pre">main_menu</span></tt></dt>
<dd><p class="first">If it exists, this label is called instead of the main menu. If it returns,
Ren'Py will start the game at the <tt class="docutils literal"><span class="pre">start</span></tt> label. For example, the
following code will immediately start the game without displaying the
main menu.</p>
<div class="last highlight-renpy"><div class="highlight"><pre><span class="k">label</span> <span class="n">main_menu</span><span class="p">:</span>
<span class="k">return</span>
</pre></div>
</div>
</dd>
<dt><tt class="docutils literal"><span class="pre">after_warp</span></tt></dt>
<dd>If it is existed, this label is called after a warp but before the warped-to
statement executes. please see <a class="reference internal" href="developer_tools.html#warping-to-a-line"><em>Warping to a line</em></a></dd>
</dl>
</div>
<div class="section" id="labels-control-flow-functions">
<h2>Labels & Control Flow Functions<a class="headerlink" href="#labels-control-flow-functions" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="renpy.call_in_new_context">
<tt class="descclassname">renpy.</tt><tt class="descname">call_in_new_context</tt><big>(</big><em>label</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#renpy.call_in_new_context" title="Permalink to this definition">¶</a></dt>
<dd><p>This code creates a new context, and starts executing code from
that label in the new context. Rollback is disabled in the
new context. (Actually, it will just bring you back to the
real context.)</p>
<p>Use this to begin a second interaction with the user while
inside an interaction.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.get_all_labels">
<tt class="descclassname">renpy.</tt><tt class="descname">get_all_labels</tt><big>(</big><big>)</big><a class="headerlink" href="#renpy.get_all_labels" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the set of all labels defined in the program, including labels
defined for internal use in the libraries.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.has_label">
<tt class="descclassname">renpy.</tt><tt class="descname">has_label</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#renpy.has_label" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns true if name is a valid label in the program, or false
otherwise.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.invoke_in_new_context">
<tt class="descclassname">renpy.</tt><tt class="descname">invoke_in_new_context</tt><big>(</big><em>callable</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#renpy.invoke_in_new_context" title="Permalink to this definition">¶</a></dt>
<dd><p>This pushes the current context, and invokes the given python
function in a new context. When that function returns or raises an
exception, it removes the new context, and restores the current
context.</p>
<p>Additional arguments and keyword arguments are passed to the
callable.</p>
<p>Please note that the context so created cannot execute renpy
code. So exceptions that change the flow of renpy code (like
the one created by renpy.jump) cause this context to terminate,
and are handled by the next higher context.</p>
<p>If you want to execute renpy code from the function, you can call
it with renpy.call_in_new_context.</p>
<p>Use this to begin a second interaction with the user while
inside an interaction.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.jump_out_of_context">
<tt class="descclassname">renpy.</tt><tt class="descname">jump_out_of_context</tt><big>(</big><em>label</em><big>)</big><a class="headerlink" href="#renpy.jump_out_of_context" title="Permalink to this definition">¶</a></dt>
<dd><p>Causes control to leave the current context, and then to be
transferred in the parent context to the given label.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.seen_label">
<tt class="descclassname">renpy.</tt><tt class="descname">seen_label</tt><big>(</big><em>label</em><big>)</big><a class="headerlink" href="#renpy.seen_label" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns true if the named label has executed at least once on the current user's
system, and false otherwise. This can be used to unlock scene galleries, for
example.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="related">
<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="dialogue.html" title="Dialogue and Narration"
>next</a> |</li>
<li class="right" >
<a href="language_basics.html" title="Language Basics"
>previous</a> |</li>
<li> <img src="_static/logo.png" width=19 height=21 align=center>
<li> <a href="http://www.renpy.org/">Ren'Py Home</a> |
<li><a href="index.html">Ren'Py Documentation</a></li>
</ul>
</div>
</body>
</html>
|