File: Ren%27Py_Script_Structure.html

package info (click to toggle)
renpy 6.10.2.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 19,468 kB
  • ctags: 5,383
  • sloc: python: 17,801; ansic: 7,116; makefile: 127; sh: 15
file content (89 lines) | stat: -rw-r--r-- 6,096 bytes parent folder | download
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
<html><head><title>Ren&amp;#39;Py Script Structure - Ren'Py Visual Novel Engine</title><link href="../shared.css" rel="stylesheet"><link href="../monobook.css" rel="stylesheet"><link href="../common.css" rel="stylesheet"><link href="../monobook2.css" rel="stylesheet"><link href="../docs.css" rel="stylesheet" /></link></link></link></link></head><body><div id="bodyContent">
			<p class="docnav"><a href="../index.html">documentation index</a></p><table class="toc" id="toc" summary="Contents">
<tr>
<td>
<div id="toctitle">
<h2>Contents</h2>
</div>
<ul>
<li class="toclevel-1"><a href="#Ren.27Py_Script_Structure"><span class="tocnumber">1</span> <span class="toctext">Ren'Py Script Structure</span></a>
<ul>
<li class="toclevel-2"><a href="#Init_Blocks"><span class="tocnumber">1.1</span> <span class="toctext">Init Blocks</span></a></li>
<li class="toclevel-2"><a href="#Labels"><span class="tocnumber">1.2</span> <span class="toctext">Labels</span></a></li>
<li class="toclevel-2"><a href="#Comments"><span class="tocnumber">1.3</span> <span class="toctext">Comments</span></a></li>
<li class="toclevel-2"><a href="#Multiple_files"><span class="tocnumber">1.4</span> <span class="toctext">Multiple files</span></a></li>
</ul>
</li>
</ul>
</td>
</tr>
</table>
<script type="text/javascript">
//
 if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } 
//
</script>
<p><a id="Ren.27Py_Script_Structure" name="Ren.27Py_Script_Structure"></a></p>
<h2><span class="mw-headline">Ren'Py Script Structure</span></h2>
<div id="init" />
<p><a id="Init_Blocks" name="Init_Blocks"></a></p>
<h3><span class="mw-headline">Init Blocks</span></h3>
<p>Every Ren'Py script has information, such as characters, images, and music which you need to declare outside of the story. This is done with init blocks. An init block looks like this:</p>
<pre>
<span class="kwa">init</span><span class="sym">:</span>
    $ john <span class="sym">=</span> <span class="kwd">Character</span><span class="sym">(</span><span class="str">"John Smith"</span><span class="sym">)</span>
    $ percy <span class="sym">=</span> <span class="kwd">Character</span><span class="sym">(</span><span class="str">"Sir Percival Blakely"</span><span class="sym">)</span>

    <span class="kwa">image</span> black <span class="sym">=</span> <span class="str">"#000000"</span>
</pre>
<p>Later sections will explain what goes in the init block, for the moment we're just pointing out what they look like. They can come anywhere in a file, but it's generally best to put them at the top. Init blocks are not indented, and the statements following an init block which are indented are <i>in</i> that init block. Once you type a statement (usually a label) which is not indented, the init block is finished. You can have any number of statements in an init block.</p>
<p>And that's all you need to know about them for now.</p>
<div id="labels" />
<p><a id="Labels" name="Labels"></a></p>
<h3><span class="mw-headline">Labels</span></h3>
<p>Labels allow you to give names to points in your story. Using them to change the flow of your story is discussed in <a href="../tutorials/Branching_%26_Recombining_the_Story.html" title="renpy/doc/tutorials/Branching &amp; Recombining the Story">Branching &amp; Recombining the Story</a>. Right now, the important thing to know is that every Ren'Py script has to have one label in it, called "<b>start</b>". That's where Ren'Py starts executing your story. It looks like this:</p>
<pre>
<span class="kwa">label</span> start<span class="sym">:</span>
</pre>
<p>So, generally, the beginning of a simple Ren'Py script would look like:</p>
<pre>
<span class="kwa">init</span><span class="sym">:</span>
    $ j <span class="sym">=</span> <span class="kwd">Character</span><span class="sym">(</span><span class="str">"John"</span><span class="sym">)</span>

<span class="kwa">label</span> start<span class="sym">:</span>
    j <span class="str">"Hello, World!"</span>
</pre>
<p><br /></p>
<div id="comments" />
<p><a id="Comments" name="Comments"></a></p>
<h3><span class="mw-headline">Comments</span></h3>
<p>You will occasionally see comments in a Ren'Py script explaining what a line in the script is for. Comments look like this:</p>
<pre>
 <span class="slc"># lines that start with an octothorpe (a.k.a. a number sign,</span>
 <span class="slc"># hash, or sharp) are comments. If you want to have comments</span>
 <span class="slc"># continue over several lines, you have to put the hash mark</span>
 <span class="slc"># at the start of each line.</span>
</pre>
<p>People playing Ren'Py games never see comments, they're only for you and anyone collaborating with you on a Ren'Py game. Ren'Py ignores comments, so you can put anything that you like in them. They're also useful for removing lines from the story which you're not ready to lose forever:</p>
<pre>
<span class="slc"># j "Nice shoes, Jen."</span>
</pre>
<p><a id="Multiple_files" name="Multiple_files"></a></p>
<h3><span class="mw-headline">Multiple files</span></h3>
<p>As your game gets bigger, you might decide to split the game file up, to make it easier to find things without all that scrolling. You can call the files whatever makes sense to you, but they must be in the "game" folder for that project, and must end with the extension ".rpy"</p>
<table align="center" border="1" cellpadding="10" cellspacing="1" style="background: #fff0e0; text-align: center;" width="80%">
<tr>
<td width="30%">Previous:<br />
<a href="../tutorials/Thinking_in_Ren%27Py.html" title="renpy/doc/tutorials/Thinking in Ren&apos;Py">Thinking in Ren'Py</a></td>
<td width="40%"><b><a href="../tutorials/Ren%27Py_Web_Tutorial.html" title="renpy/doc/tutorials/Ren&apos;Py Web Tutorial">Ren'Py Web Tutorial</a></b></td>
<td width="30%">Next:<br />
<a href="../tutorials/Defining_Characters.html" title="renpy/doc/tutorials/Defining Characters">Defining Characters</a></td>
</tr>
</table>




<div class="visualClear" />
		<hr /><p class="docnav"><a href="../index.html">documentation index</a></p></div>
	</body></html>