documentation index ◦ reference manual ◦ function index
Function: | DynamicDisplayable | (function, *args, **kwargs): |
This displayable evaluates a function, and uses the result of that function to determine what to show.
function should be function that should accept at least two arguments. The first argument is the time (in seconds) that the DynamicDisplayable has been shown for. The second argument is the number of seconds that a displayable with the same image tag has been shown for. Additional positional and keyword arguments passed to DynamicDisplayable are also given to the function. The function is expected to return a 2-tuple. The first element of this tuple should be a displayable. The second should be either the time (in seconds) that the return value is valid for, or None to indicate the return value is valid indefinitely.
The function is evaluated at least once for each interaction. It is also evaluated again when the specified time has elapsed.
Note that DynamicDisplayable does not accept properties. Instead, it uses the properties of the displayable returned by function.
Note that ConditionSwitch is a wrapper around DynamicDisplayable, and may be simpler depending on your needs.
For compatibility with pre-5.6.3 versions of Ren'Py, DynamicDisplayable also accepts a string as the function argument. In this case, the string is evaluated once per interaction, with the result being used as the displayable for that interaction.
init python: gm_background = "gmbg1.png" def game_menu_background(st, at): return gm_background, None style.gm_root.background = DynamicDisplayable(game_menu_background) label start: "Here, we'll show the game menu with background 1." $ gm_background = "gmbg2.png" "Now, we're showing it with background 2."