/usr/share/doc/renpy/html/cds.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 311 312 313 314 315 316 | <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Creator-Defined Statements — 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="Character Callbacks" href="character_callbacks.html" />
<link rel="prev" title="Creator-Defined Displayables" href="udd.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="character_callbacks.html" title="Character Callbacks"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="udd.html" title="Creator-Defined Displayables"
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="#">Creator-Defined Statements</a><ul>
<li><a class="reference internal" href="#lint-utility-functions">Lint Utility Functions</a></li>
<li><a class="reference internal" href="#example">Example</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="udd.html"
title="previous chapter">Creator-Defined Displayables</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="character_callbacks.html"
title="next chapter">Character Callbacks</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="creator-defined-statements">
<h1>Creator-Defined Statements<a class="headerlink" href="#creator-defined-statements" title="Permalink to this headline">¶</a></h1>
<p>Creator-defined statements allow you to add your own statements to Ren'Py. This
makes it possible to add things that are not supported by the current syntax of
Ren'Py. creator-defined statements are currently limited to a single line, and may
not contain blocks.</p>
<p>Creator-defined statements must be defined in a python early block. What's more,
the filename containing the user-defined statement must be be loaded earlier
than any file that uses it. Since Ren'Py loads files in unicode sort order, it
generally makes sense to prefix the name of any file containing a user-defined
statement with 01, or some other small number.</p>
<p>A user-defined statement cannot be used in the file in which it is defined.</p>
<p>Creator-defined statement are registered using the renpy.register_statement
function.</p>
<dl class="function">
<dt id="renpy.register_statement">
<tt class="descclassname">renpy.</tt><tt class="descname">register_statement</tt><big>(</big><em>name</em>, <em>parse=None</em>, <em>lint=None</em>, <em>execute=None</em>, <em>predict=None</em>, <em>next=None</em>, <em>scry=None</em>, <em>block=False</em>, <em>init=False</em>, <em>translatable=False</em><big>)</big><a class="headerlink" href="#renpy.register_statement" title="Permalink to this definition">¶</a></dt>
<dd><p>This registers a user-defined statement.</p>
<dl class="docutils">
<dt><cite>name</cite></dt>
<dd>This is either a space-separated list of names that begin the statement, or the
empty string to define a new default statement (the default statement will
replace the say statement).</dd>
<dt><cite>parse</cite></dt>
<dd>This is a function that takes a Lexer object. This function should parse the
statement, and return an object. This object is passed as an argument to all the
other functions. The lexer argument has the following methods:</dd>
<dt><cite>lint</cite></dt>
<dd>This is called to check the statement. It is passed a single object, the
argument returned from parse. It should call renpy.error to report errors.</dd>
<dt><cite>execute</cite></dt>
<dd>This is a function that is called when the statement executes. It is passed a
single object, the argument returned from parse.</dd>
<dt><cite>predict</cite></dt>
<dd>This is a function that is called to predict the images used by the statement.
It is passed a single object, the argument returned from parse. It should return
a list of displayables used by the statement.</dd>
<dt><cite>next</cite></dt>
<dd>This is called to determine the next statement. It is passed a single object,
the argument returned from parse. It should either return a label, or return
None if execution should continue to the next statement.</dd>
<dt><cite>scry</cite></dt>
<dd>Used internally by Ren'Py.</dd>
<dt><cite>block</cite></dt>
<dd>True if this takes a block, false otherwise.</dd>
<dt><cite>init</cite></dt>
<dd>True if this statement should be run at init-time. (If the statement
is not already inside an init block, it's automatically placed inside
an init 0 block.)</dd>
</dl>
</dd></dl>
<p>The parse method takes a Lexer object:</p>
<dl class="class">
<dt id="Lexer">
<em class="property">class </em><tt class="descname">Lexer</tt><a class="headerlink" href="#Lexer" title="Permalink to this definition">¶</a></dt>
<dd><dl class="method">
<dt id="Lexer.eol">
<tt class="descname">eol</tt><big>(</big><big>)</big><a class="headerlink" href="#Lexer.eol" title="Permalink to this definition">¶</a></dt>
<dd><p>True if the lexer is at the end of the line.</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.match">
<tt class="descname">match</tt><big>(</big><em>re</em><big>)</big><a class="headerlink" href="#Lexer.match" title="Permalink to this definition">¶</a></dt>
<dd><p>Matches an arbitrary regexp string.</p>
<p>All of the statements in the lexer that match things are implemented
in terms of this function. They first skip whitespace, then attempt
to match against the line. If the match succeeds, the matched text
is returned. Otherwise, None is returned.</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.keyword">
<tt class="descname">keyword</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#Lexer.keyword" title="Permalink to this definition">¶</a></dt>
<dd><p>Matches <cite>s</cite> as a keyword.</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.name">
<tt class="descname">name</tt><big>(</big><big>)</big><a class="headerlink" href="#Lexer.name" title="Permalink to this definition">¶</a></dt>
<dd><p>Matches a name. This does not match built-in keywords.</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.word">
<tt class="descname">word</tt><big>(</big><big>)</big><a class="headerlink" href="#Lexer.word" title="Permalink to this definition">¶</a></dt>
<dd><p>Matches any word, including keywords. Returns the</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.string">
<tt class="descname">string</tt><big>(</big><big>)</big><a class="headerlink" href="#Lexer.string" title="Permalink to this definition">¶</a></dt>
<dd><p>Matches a Ren'Py string.</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.integer">
<tt class="descname">integer</tt><big>(</big><big>)</big><a class="headerlink" href="#Lexer.integer" title="Permalink to this definition">¶</a></dt>
<dd><p>Matches an integer, returns a string containing the integer.</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.float">
<tt class="descname">float</tt><big>(</big><big>)</big><a class="headerlink" href="#Lexer.float" title="Permalink to this definition">¶</a></dt>
<dd><p>Matches a floating point number, returns a string containing the
floating point number.</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.simple_expression">
<tt class="descname">simple_expression</tt><big>(</big><big>)</big><a class="headerlink" href="#Lexer.simple_expression" title="Permalink to this definition">¶</a></dt>
<dd><p>Matches a simple python expression, returns it as a string.</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.rest">
<tt class="descname">rest</tt><big>(</big><big>)</big><a class="headerlink" href="#Lexer.rest" title="Permalink to this definition">¶</a></dt>
<dd><p>Skips whitespace, the returns the rest of the line.</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.checkpoint">
<tt class="descname">checkpoint</tt><big>(</big><big>)</big><a class="headerlink" href="#Lexer.checkpoint" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns an opaque object representing the current state of the lexer.</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.revert">
<tt class="descname">revert</tt><big>(</big><em>o</em><big>)</big><a class="headerlink" href="#Lexer.revert" title="Permalink to this definition">¶</a></dt>
<dd><p>When <cite>o</cite> is the object returned from checkpoint(), reverts the state
of the lexer to what it was when checkpoint() was called. (This is
used for backtracking.)</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.subblock_lexer">
<tt class="descname">subblock_lexer</tt><big>(</big><big>)</big><a class="headerlink" href="#Lexer.subblock_lexer" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a Lexer for the block associated with the current line.</p>
</dd></dl>
<dl class="method">
<dt id="Lexer.advance">
<tt class="descname">advance</tt><big>(</big><big>)</big><a class="headerlink" href="#Lexer.advance" title="Permalink to this definition">¶</a></dt>
<dd><p>In a subblock lexer, advances to the next line. This must be called
before the first line, so the first line can be parsed.</p>
</dd></dl>
</dd></dl>
<div class="section" id="lint-utility-functions">
<h2>Lint Utility Functions<a class="headerlink" href="#lint-utility-functions" title="Permalink to this headline">¶</a></h2>
<p>These functions are useful in writing lint functions.</p>
<dl class="function">
<dt id="renpy.check_text_tags">
<tt class="descclassname">renpy.</tt><tt class="descname">check_text_tags</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#renpy.check_text_tags" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks the text tags in s for correctness. Returns an error string if there is
an error, or None if there is no error.</p>
</dd></dl>
</div>
<div class="section" id="example">
<h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2>
<p>This creates a new statement "line" that allows lines of text to be specified
without quotes.</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="k">python</span> <span class="n">early</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">parse_smartline</span><span class="p">(</span><span class="n">lex</span><span class="p">):</span>
<span class="n">who</span> <span class="o">=</span> <span class="n">lex</span><span class="o">.</span><span class="n">simple_expression</span><span class="p">()</span>
<span class="n">what</span> <span class="o">=</span> <span class="n">lex</span><span class="o">.</span><span class="n">rest</span><span class="p">()</span>
<span class="k">return</span> <span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">what</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">execute_smartline</span><span class="p">(</span><span class="n">o</span><span class="p">):</span>
<span class="n">who</span><span class="p">,</span> <span class="n">what</span> <span class="o">=</span> <span class="n">o</span>
<span class="n">renpy</span><span class="o">.</span><span class="n">say</span><span class="p">(</span><span class="n">who</span><span class="p">,</span> <span class="n">what</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">lint_smartline</span><span class="p">(</span><span class="n">o</span><span class="p">):</span>
<span class="n">who</span><span class="p">,</span> <span class="n">what</span> <span class="o">=</span> <span class="n">o</span>
<span class="k">try</span><span class="p">:</span>
<span class="nb">eval</span><span class="p">(</span><span class="n">who</span><span class="p">)</span>
<span class="k">except</span><span class="p">:</span>
<span class="n">renpy</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s">"Character not defined: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="n">who</span><span class="p">)</span>
<span class="n">tte</span> <span class="o">=</span> <span class="n">renpy</span><span class="o">.</span><span class="n">check_text_tags</span><span class="p">(</span><span class="n">what</span><span class="p">)</span>
<span class="k">if</span> <span class="n">tte</span><span class="p">:</span>
<span class="n">renpy</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="n">tte</span><span class="p">)</span>
<span class="n">renpy</span><span class="o">.</span><span class="n">register_statement</span><span class="p">(</span><span class="s">"line"</span><span class="p">,</span> <span class="n">parse</span><span class="o">=</span><span class="n">parse_smartline</span><span class="p">,</span> <span class="n">execute</span><span class="o">=</span><span class="n">execute_smartline</span><span class="p">,</span> <span class="n">lint</span><span class="o">=</span><span class="n">lint_smartline</span><span class="p">)</span>
</pre></div>
</div>
<p>This can be used by writing:</p>
<div class="highlight-renpy"><div class="highlight"><pre><span class="n">line</span> <span class="n">e</span> <span class="s">"These quotes will show up,"</span> <span class="n">Eileen</span> <span class="n">said</span><span class="p">,</span> <span class="s">"and don't need to be backslashed."</span>
</pre></div>
</div>
</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="character_callbacks.html" title="Character Callbacks"
>next</a> |</li>
<li class="right" >
<a href="udd.html" title="Creator-Defined Displayables"
>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>
|