Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
I'm trying to do that thing where when a text is displayed with cps a sound is played every time a letter appears. I found how to do it in the renpy documentation but I can't make it work.
Here is what I have at the beginning in my scipt (I also tried putting it on screens and gui):
I'm not sure it's possible using text-tags, since they only replace strings and return them.
But I came up with a solution (since this is a fun little thing). Here is a function that does it all for you. Just put your beepwords into <THIS>. This function uses an audiofile called "beep.ogg" by the way, you may want to change that. Normal text tags still work by the way.
init python:
import re
def beepsay(who, what, cps=3):
# store what was said so far
past = ""
# get a list of all substrings not beeping
nobeeps = re.split("<[^>]+>", what)
# go through every beepword <BEEP> we can find
for i, beepword in enumerate(re.findall("<([^>]+)>", what)):
# say what was said so far (fast) and the current nobeep string normally
renpy.say(who, f"{past}{{fast}}{nobeeps[i]}{{nw}}")
past += nobeeps[i]
for letter in beepword:
renpy.say(who, f"{past}{{fast}}{{cps={cps}}}{letter}{{/cps}}{{nw}}")
renpy.play("audio/beep.ogg")
past += letter
# check if there are still things to say
end = nobeeps[i+1] if i < len(nobeeps)-1 else ""
renpy.say(who, f"{past}{{fast}}{end}")
return
label start:
$ beepsay(eileen, "Hey, I am a <ROBOT> and my name is <EILEEN>.")
$ beepsay(None, "And I am...{w=0.4} uhm...{w=0.4} a very slow <ROBOT-NARRATOR>...", cps=1)
return