Other Functions and Variables link

We're in the process of migrating the documentation over to a new tool. As not every page has been migrated yet, this exists to document new functionality that has no other place to go.

renpy.language_tailor(chars, cls) link

This can be used to override the line breaking class of a character. For example, the linebreaking class of a character can be set to ID to treat it as an ideograph, which allows breaks before and after that character.

chars
A string containing each of the characters to tailor.
cls
A string giving a character class. This should be one of the classes defined in Table 1 of UAX #14: Unicode Line Breaking Algorithm.
layout.yesno_screen(message, yes=None, no=None) link

This causes the a yes/no prompt screen with the given message to be displayed. The screen will be hidden when the user hits yes or no.

message
The message that will be displayed.
yes
An action that is run when the user chooses yes.
no
An action that is run when the user chooses no.

Ren'Py Version link

renpy.version(tuple=False) link

If tuple is false, returns a string containing "Ren'Py ", followed by the current version of Ren'Py.

If tuple is true, returns a tuple giving each component of the version as an integer.

renpy.version_string link

The version number of Ren'Py, as a string of the form "Ren'Py 1.2.3.456".

renpy.version_only link

The version number of Ren'Py, without the Ren'Py prefix. A string of the form "1.2.3.456".

renpy.version_tuple link

The version number of Ren'Py, as a tuple of the form (1, 2, 3, 456).

renpy.version_name link

A human readable version name, of the form "Example Version."

renpy.license link

A string giving license text that should be included in a game's about screen.

Platform Detection link

Ren'Py includes a number of variables that are set based on which platform it's running on.

renpy.windows link

True when running on Windows.

renpy.macintosh link

True when running on macOS.

renpy.linux link

True when running on Linux or other POSIX-like operating systems.

renpy.android link

True when running on Android.

renpy.ios link

True when running on iOS.

renpy.emscripten link

True when running in the browser.

renpy.mobile link

True when running on Android or iOS or in the browser.

These are only set when running on the actual devices, not when running on in the emulators. These are more intended for use in platform-specific Python. For display layout, use screen variants.

Memory Profiling link

renpy.diff_memory(update=True) link

Profiles objects, surface, and texture memory use by Ren'Py and the game. Writes (to memory.txt and stdout) the difference in memory usage from the last time this function was called with update true.

The accounting is by names in the store and in the Ren'Py implementation that the memory is reachable from. If an object is reachable from more than one name, it's assigned to the name it's most directly reachable from.

As it has to scan all memory used by Ren'Py, this function may take a long time to complete.

renpy.profile_memory(fraction=1.0, minimum=0) link

Profiles object, surface, and texture memory use by Ren'Py and the game. Writes an accounting of memory use by to the memory.txt file and stdout.

The accounting is by names in the store and in the Ren'Py implementation that the memory is reachable from. If an object is reachable from more than one name, it's assigned to the name it's most directly reachable from.

fraction
The fraction of the total memory usage to show. 1.0 will show all memory usage, .9 will show the top 90%.
minimum
If a name is accounted less than minimum bytes of memory, it will not be printed.

As it has to scan all memory used by Ren'Py, this function may take a long time to complete.

renpy.profile_rollback() link

Profiles memory used by the rollback system. Writes (to memory.txt and stdout) the memory used by the rollback system. This tries to account for rollback memory used by various store variables, as well as by internal aspects of the rollback system.

Contexts link

renpy.context() link

Returns an object that is unique to the current context. The object is copied when entering a new context, but changes to the copy do not change the original.

The object is saved and participates in rollback.

renpy.context_nesting_level() link

Returns the nesting level of the current context. This is 0 for the outermost context (the context that is saved, loaded, and rolled-back), and is non-zero in other contexts, such as menu and replay contexts.

renpy.random link

This object is a random number generator that implements the Python random number generation interface. Randomness can be generated by calling the various methods this object exposes. See the Python documentation for the full list, but the most useful are:

  • renpy.random.random()

Return the next random floating point number in the range (0.0, 1.0).

  • renpy.random.randint(a, b)

Return a random integer such that a <= N <= b.

  • renpy.random.choice(seq)

Return a random element from the non-empty sequence seq.

  • renpy.random.shuffle(seq)

Shuffles the elements of the sequence seq in place. This does not return a list, but changes an existing one.

Unlike the standard Python random number generator, this object cooperates with rollback, generating the same numbers regardless of how many times we rollback. It should be used instead of the standard Python random module.

# 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'])
  • renpy.random.Random(seed=None)

Returns a new random number generator object separate from the main one, seeded with the specified value if provided.