Download Renpy Programming Manual PDF

TitleRenpy Programming Manual
TagsComputer File Python (Programming Language) Menu (Computing) Control Flow Scripting Language
File Size2.4 MB
Total Pages294
Document Text Contents
Page 2

Renpy Programming Manual



2

Contenido
The Ren'Py Launcher ........................................................................................................... 10

A Simple Game ...................................................................................................................... 10

Characters .............................................................................................................................. 12

Images..................................................................................................................................... 13

Transitions ............................................................................................................................. 15

Positions ................................................................................................................................. 16

Music and Sound ................................................................................................................... 16

Ending the Game ................................................................................................................... 17

Menus, Labels, and Jumps ................................................................................................... 17

Python and If Statements ..................................................................................................... 18

Releasing Your Game ........................................................................................................... 19

Script of The Question .......................................................................................................... 20

The Structure of Ren'Py Scripts ............................................................................................... 20

Lines..................................................................................................................................... 20

Comments ........................................................................................................................... 21

Blocks .................................................................................................................................. 22

Init Blocks ................................................................................................................................ 22

Defining Images ................................................................................................................... 23

Defining Characters ............................................................................................................. 23

Basic Script Commands ........................................................................................................... 24

Speech ................................................................................................................................. 24

Show .................................................................................................................................... 25

Hide ..................................................................................................................................... 26

Scene ................................................................................................................................... 27

With ..................................................................................................................................... 27

Audio ....................................................................................................................................... 28

Play ...................................................................................................................................... 28

Stop ..................................................................................................................................... 30

Queue .................................................................................................................................. 30

Labels ....................................................................................................................................... 32

Jump .................................................................................................................................... 33

Call and Return .................................................................................................................... 34

Variables and Control Structures ............................................................................................ 35

Page 147

Renpy Programming Manual



147

callback - If not None, a function that should be called with no arguments

before each time something is shown.

no_ctc_what - The contents of what before the click-to-continue indicator was

appended.

kwargs - Additional keyword arguments should be ignored.

This function is required to return the ui.text widget displaying the what text.

Function: renpy.shown_window ():

This should be called when a window is shown on the screen. Calling this

prevents config.empty_window from being called when _window is true.

(And hence, prevents the empty window from being shown.)

Function: renpy.transition (trans, layer=None, always=False):

Sets the transition that will be used for the next interaction. This is useful

when the next interaction doesn't take a with clause, as is the case with

interactions in the renpy.pause, renpy.input, and renpy.imagemap functions.

trans - The desired transition.

layer - If the layer setting is not None, then the transition will be applied only

to the layer named. Please note that only some transitions can be applied to

specific layers.

always - If True, forces the transition to be used, potentially overriding the

game preference setting for showing all or no transitions.

Function: renpy.restart_interaction ():

Calling this restarts the current interaction, while keeping any ongoing

transitions.

This should be called whenever displayables are added or removed over the

course of an interaction, or when the information used to construct the overlay

changes.





http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.text
http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.shown_window
http://www.renpy.org/wiki/renpy/doc/reference/Configuration_Variables#config.empty_window
http://www.renpy.org/wiki/renpy/doc/reference/Store_Variables#_window
http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.transition
http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.pause
http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.input
http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.imagemap
http://www.renpy.org/wiki/renpy/doc/reference/Transitions
http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.restart_interaction

Page 148

Renpy Programming Manual



148

Function: renpy.reshow_say ():

Reshows the last say statement. Does not cause an interaction to occur.

Function: renpy.roll_forward_info ():

When re-executing a statement after rollback, this returns the data stored using

renpy.checkpoint the last time this statement was executed. If this statement is

not being re-executed due to a rollback, this returns None.

Often, this data is passed as the roll_forward parameter of ui.interact. It's

important to check to ensure that the value is valid before using it in this way.

Context Functions

Contexts store the current scene lists and execution location. Ren'Py supports

a stack of contexts, but only the top-level context is saved to the save file.

Function: renpy.context ():

Returns an object that is unique to the current context, that participates in

rollback and the like.

Function: renpy.call_in_new_context (label):

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.)

Use this to begin a second interaction with the user while inside an interaction.

Function: renpy.invoke_in_new_context (callable, *args, **kwargs):

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.

Additional arguments and keyword arguments are passed to the callable.

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

http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.reshow_say
http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.roll_forward_info
http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.checkpoint
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.interact
http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.context
http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.call_in_new_context
http://www.renpy.org/wiki/renpy/doc/reference/functions/renpy.invoke_in_new_context

Page 293

Renpy Programming Manual



293

 theme.image labels

 theme.outline

 theme.roundrect

 theme.roundrect red

 Transform

 ui.add

 ui.adjustment

 ui.at

 ui.autobar

 ui.bar

 ui.button

 ui.callsinnewcontext

 ui.clear

 ui.close

 ui.detached

 ui.fixed

 ui.frame

 ui.gamemenus

 ui.grid

 ui.hbox

 ui.image

 ui.imagebutton

 ui.imagemap

 ui.input

 ui.interact

 ui.jumps

 ui.jumpsoutofcontext

 ui.keymap

 ui.layer

 ui.menu

 ui.null

 ui.pausebehavior

 ui.remove

 ui.returns

 ui.saybehavior

 ui.side

 ui.sizer

 ui.soundstopbehavior

 ui.tag

 ui.text

 ui.textbutton

 ui.timer

 ui.transform

 ui.vbox

http://www.renpy.org/wiki/renpy/doc/reference/functions/theme.image_labels
http://www.renpy.org/wiki/renpy/doc/reference/functions/theme.outline
http://www.renpy.org/wiki/renpy/doc/reference/functions/theme.roundrect
http://www.renpy.org/wiki/renpy/doc/reference/functions/theme.roundrect_red
http://www.renpy.org/wiki/renpy/doc/reference/functions/Transform
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.add
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.adjustment
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.at
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.autobar
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.bar
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.button
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.callsinnewcontext
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.clear
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.close
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.detached
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.fixed
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.frame
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.gamemenus
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.grid
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.hbox
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.image
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.imagebutton
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.imagemap
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.input
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.interact
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.jumps
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.jumpsoutofcontext
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.keymap
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.layer
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.menu
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.null
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.pausebehavior
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.remove
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.returns
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.saybehavior
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.side
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.sizer
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.soundstopbehavior
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.tag
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.text
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.textbutton
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.timer
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.transform
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.vbox

Page 294

http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.viewport
http://www.renpy.org/wiki/renpy/doc/reference/functions/ui.window
http://www.renpy.org/wiki/renpy/doc/reference/functions/VBox
http://www.renpy.org/wiki/renpy/doc/reference/functions/Viewport
http://www.renpy.org/wiki/renpy/doc/reference/functions/Window
http://www.renpy.org/wiki/renpy/doc/reference/functions/Zoom

Similer Documents