Reference Manual: (offline | online) Quickstart: (offline | online)

Interaction Functions

The Ren'Py interaction functions are available so that you can customize interactions with the user taking advantage of the same code which the normal interactions use.

Statement Helper Functions

The following functions either implement new game behavior that didn't merit its own statement, or complement the behavior of statements.

Function: renpy.show_display_say( who, what, who_args={}, what_args={}, window_args={}, image=False, **kwargs)

This is called (by default) by renpy.display_say to add the widgets corresponding to a screen of dialogue to the user. It is not expected to be called by the user, but instead to be called by renpy.display_say , or by a function passed as the show_function argument to Character or renpy.display_say .

who - The name of the character that is speaking, or None to not show this name to the user.

what - What that character is saying. Please note that this may not be a string, as it can also be a list containing both text and displayables, suitable for use as the first argument of ui.text .

who_args - Additional keyword arguments intended to be supplied to the ui.text that creates the who widget of this dialogue.

what_args - Additional keyword arguments intended to be supplied to the ui.text that creates the what widget of this dialogue.

window_args - Additional keyword arguments intended to be supplied to the ui.window that creates the who widget of this dialogue.

image - If True, then who should be interpreted as an image or displayable rather than a text string.

callback - If not None, a function that should be called with no arguments before each time something is shown.

kwargs - Additional keyword arguments should be ignored.

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

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.

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

Debugging Functions

Function: renpy.log( msg)

If config.log is not set, this does nothing. Otherwise, it opens the logfile (if not already open), formats the message to 70 columns, and prints it to the logfile.

Ren'Py Statement Functions

These functions correspond to the equivalent core Ren'Py language statements.

Miscellaneous Utility Functions

# return a random float between 0 and 1
$ randfloat = renpy.random.random()

# return a random integer between 1 and 20
$ d20roll = renpy.random.randint(1, 20)

# return a random element from a list
$ randfruit = renpy.random.choice(['apple', 'orange', 'plum'])
Reference Manual: (offline | online) Quickstart: (offline | online)