antiknuckles asked: Hello, I'm just starting on Ren'Py and making a practice game as I study as a practical way to memorize what I'm learning. Though I've been looking for a while I haven't seen anything on making the text 'type' itself out instead of appearing all at once on the screen. I know you can do this with individual lines, but is there a way to make each of the characters appear a bit slower?
Hey there antiknuckles, thanks for phoning in!
The display speed of the text in the game is handled by the interpreter. It has a default speed, which you can modify, as you stated, by individual lines. This modification deals with how many characters per second appear inside the bracket. This way, someone can say something extra fast or slow.
However, if you want the speed for all characters up or down, the best way to do this is to create a new style, and then apply that style to the characters themselves.
Characters use a default style inside of Ren’Py unless you override it by specifying one. We’ll get to that in a moment. First I’ll walk you through making a new style with the characteristics you want.
In order to make a new style(that you’re using for all your Characters), first you have to create a new Python block. This needs to have an initialization priority *before* any of the characters that use this style. Characters have an initialization of 0, and run before the game loads.
“A priority number can be placed between init and python. When a priority is not given, 0 is used. Init statements are run in priority order, from lowest to highest. Init statements of the same priority are run in unicode order by filename, and then from top to bottom within a file.“ Renpy Documentation: Init Python Statement
So you’ll want to create your style with a priority of -1 or less. if you don’t your game will crash as the game tries to assign a style that doesn’t exist yet. Most of the other styles native to Ren’Py, for example in the screens file) have an init of -2, so I stick my own styles with the same priority.
Example:
init -2 python:
Simple as that. The everything in that Python block has an init priority of -2.
From there, you need to create the actual style in name and other characteristics.
The specific function to do so can be found here: Defining Styles: Python
For the style in question you can name it Default Character Style or something. If you name is something with more than one word, you need to use underscores in place of spaces for it to work.
Example:
init -2 python:
style.default_character_style = Style(style.default)
Inside the initiation of the new Style class you have to specify it’s parent style. The default would work well for this purpose, but if you want to make another style based on this one you could specify this new still instead.
Example:
init -2 python:
style.new_style = Style(style.default_character_style)
This was the new style inherent everything already specified in the previous style and then the new stuff is added on top. You can use this to create a default style for all of your characters and then a new one for a specific one that is a variation on the typical style without having to make it all from scratch again.
In order to change the speed of the characters appearing on screen, you have to specify has fast you want them to appear instead. The best way to get it how you want is to experiment. Pick a number and then run some parts of the game. If it’s too fast or slow adjust it. Here’s how you would get a chance into the game though.
Example:
init -2 python:
style.default_character_style = Style(style.default)
style.default_character_style.slow_cps = 20
And then any other default things you want to add to the style.
Finally, when it comes to the Characters themselves, when you make the character, you have to specify that you want it to use your custom style instead of the default one.
To do that, you specify the “what” style.(”who” is for the name; “what” is for what’s said) So, you could theoretically have the name and dialogue in two different styles. When you make the Character, it would look like this:
Example:
define pov = Character(_(”[povname]”), what_style =“default_character_style”)
Simple as that. Now whenever you make changes to that style all the characters will change with it. Character as a class take a large number of arguments so you can specify everything from the color of the name to a suffix or prefix to be appended to the dialogue.(say for example if you want quotation marks to always appear that way you didn’t have to write them in and use escape characters on every line.)
I hope this helps!
Remember loyal followers, if you’re code won’t compile and you don’t know why? Who ya gonna call? The Ren’Py Help Desk!