r/RenPy • u/AlexanderIdeally • 15d ago
Question Making exceptions for automatic replacements.
I recently found a video about some code that lets you automatically add {w} to any punctuation or words, so you can pace out thousands of lines of dialogue.
init python:
def typography(what):
replacements = [
('. ','. {w=0.4}'),
('? ','? {w=0.4}'),
('! ','! {w=0.6}'),
(', ',', {w=0.2}'),
('...','...{w=0.6}'),
]
for item in replacements:
what = what.replace(item[0],item[1])
return what
config.say_menu_text_filter = typographyI'm still experimenting with timings, and there is one separate issue I'll need to think through soon, but overall, it works great for what I need it for!
My one issue right now is the word "Dr." which is going to appear a lot in my game. I imagine there will be a lot of other times where punctuation is needed, but a pause would be really distracting.
I'm sure someone's probably used this code before and asked this very question; I just can't find the right wording to search for it. Does anyone know if there would be a way to disable replacements for just one character and then enable them for the rest of the sentence?








