File: character_callbacks.rst

package info (click to toggle)
renpy 7.1.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 107,352 kB
  • sloc: python: 42,124; ansic: 4,781; makefile: 43; sh: 14
file content (62 lines) | stat: -rw-r--r-- 1,841 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
.. _character-callbacks:

Character Callbacks
===================

Ren'Py includes the ability to execute callbacks when various events
occur during dialogue. This is done by giving the `callback` argument
to :func:`Character`, or setting the :var:`config.character_callback` or
:var:`config.all_character_callbacks` variables.

The character callback is called with a single positional argument, the event
that occured. Possible events are:

"begin"
    Called at the start of a say statement.

"show"
    Called before showing each segment of dialogue. Dialogue may be separated
    into multiple segments by the {w} or {p} text tags, but always consists of
    at least one segment.

"show_done"
    Called after showing each segment of dialogue.

"slow_done"
    Called after slow text finishes showing. Note that this event may occur
    after "end", in cases where dialogue does not cause an interaction
    to occur.

"end"
    Called at the end of a say statement.

The callback is called with at least one keyword argument:

`interact`
    This is true if the dialogue causes an interaction to occur.

Other values of the positional argument and additional keyword arguments may
be supplied in the future. The callback should written to ignore arguments it
does not understand.

Example
-------

This example plays beeps in place of a character voice, when slow
text is enabled::

    init python:
        def beepy_voice(event, interact=True, **kwargs):
            if not interact:
                return

            if event == "show_done":
                renpy.sound.play("beeps.ogg")
            elif event == "slow_done":
                renpy.sound.stop()

    define pike = Character("Christopher Pike", callback=beepy_voice)

    label start:

        pike "So, hanging out on Talos IV, minding my own business, when..."