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, no_ctc_what=..., **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.

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.imagemap( ground, selected, hotspots, unselected=None, overlays=False, style='imagemap', with_none=None, **properties)

Displays an imagemap. An image map consists of two images and a list of hotspots that are defined on that image. When the user clicks on a hotspot, the value associated with that hotspot is returned. Despite the name, this takes arbitrary displayables, not just image manipulators.

ground - The name of the file containing the ground image. The ground image is displayed for areas that are not part of any hotspots.

selected - The name of the file containing the selected image. This image is displayed in hotspots when the mouse is over them.

hotspots - A list of tuples defining the hotspots in this image map. Each tuple has the format (x0, y0, x1, y1, result). (x0, y0) gives the coordinates of the upper-left corner of the hotspot, (x1, y1) gives the lower-right corner, and result gives the value returned from this function if the mouse is clicked in the hotspot.

unselected - If provided, then it is the name of a file containing the image that's used to fill in hotspots that are not selected as part of any image. If not provided, the ground image is used instead.

overlays - If True, overlays are displayed when this imagemap is active. If False, the overlays are suppressed.

with_none - If True, causes a "with None" statement to be run after each interaction. If None (the default), checks config.implicit_with_none to determine if a "with None" should be run.

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.

Scene List Access

These functions let you query the scene lists.

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)