Ren’py Tidbits

I’ve been a little dead on this blog latley as I’ve been focusing on a ren’py project that didn’t really have a lot of tech art related topics to write about.

The demo for that project can be found here for anyone who likes solving detective mysteries!

I’m working on it more, as well as another prototype, so figured I’d post about a couple of neat tidbits I’ve done.

Dialog Blips

In order for this to work, the text speed needs to be slow. The speed of the text can be changed on line 122 of options.rpy. It is 0 by default, which makes the text appear instantly. Larger numbers will make the text appear more slowly.

default preferences.text_cps = 15

The blips are implemented by providing a callback function to the character when it is created.

define e = Character(“Eileen”, callback = dialog_beep)

When the callback is called, it is given an event argument which tells us when the callback occurred. For the dialog, we use show done and slow done, which are when text is shown and when an entire line of slow text are finished showing, respectively. What we’re doing here is playing a sound when the text starts displaying, looping that sound, then stopping it when the dialog line finishes.

Because there is a slight pause between each beep, it gives the impression that the words and beeps are connected, but really we’re just displaying some text slowly and looping a beep sound until the text is finished displaying.

def dialog_beep (event, interact=True, **kwargs):
if not interact:
return

if event == “show_done”:
renpy.sound.play(“audio/beep.wav”, loop=True)
elif event == “slow_done”:
renpy.sound.stop()

More info can be found on the ren’py documentation.

Handling Screen Variables

I’ve been working on a new prototype that relies heavily on custom screens which has a couple of gotchas in terms of when variables are updated and refreshed.

A hacky fix for some issues can be to refresh the screen by restarting the interaction.

renpy.restart_interaction()

Another thing to note is that variables set in screens should use the SetScreenVariable method rather than just being set manually, as this will cause the whole screen to be updated appropriately.

SetScreenVariable(“number_pressed”, number_pressed + str(i+1))

Hiding the Say Screen

I haven’t found a non-hacky way to do this yet, but in order to hide the say screen and only interact though my custom screen, I used the pause function after displaying my screen. As it refreshes its interactions separate from the say screen, we don’t get blocked from interacting by the pause.

label start:
show screen remote()
$ renpy.pause()
return

renpy