[solved]Change characters per second based on language

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.
Post Reply
Message
Author
User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

[solved]Change characters per second based on language

#1 Post by ComputerArt.Club »

Aside from going into every single line of text and manually setting the CPS for each, is there anyway of changing the CPS separately for each language. The problem I am running into now is that I Japanese and Chinese are should have a much lower CPS than English, especially as I am trying to get it to sync with the speech.

Code: Select all

## Preference defaults #########################################################

## Controls the default text speed. The default, 0, is infinite, while any other
## number is the number of characters per second to type out.

default preferences.text_cps = 6
Can I add a conditional here? What would that look like? Or can I some how get this line to appear in the translated script? (by default it is only adding in game text but lines of code like this).

Thanks you for your patience and taking the time to read this.
Last edited by ComputerArt.Club on Mon Jul 01, 2019 10:33 am, edited 1 time in total.

User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: Change characters per second based on language

#2 Post by ComputerArt.Club »

OK, so I have fixed the problem and created a new one.

Code: Select all

translate chinese python:
    preferences.text_cps = 4
Fixes the speed for Chinese and Japanese, and I can set them both independently, but once I change English is also affected.
Since English is the default language, I need to figure out how to get the CPS to reset once it goes back to English.

I tried

Code: Select all

translate none python:
    preferences.text_cps = 0
and other speeds but it doesn't work. No error, just English still takes the same speed of the translated languages.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Change characters per second based on language

#3 Post by Remix »

None would (if it works) be Capitalized, though I suspect the parser makes it a string

I would approach the problem from a step higher tbh... brief pseudo-code

Code: Select all

default language_cps = {
    # current, maximum
    None : [ 15, 200 ],
    'chinese' : [ 4, 15 ], 
    ## etc
    }

# bit where you select a language
textbutton "Chinese" action [ SetField( preference, "text_cps", language_cps['chinese'][0] ), Language('chinese') ]

# bit where you adjust cps
value Preference("text speed", range=language_cps[preference.language])
#
# and shoehorn in a bit somewhere that (maybe when you close the prefs screen) takes text_cps and adjusts the language_cps mapping current val
Hope that makes sense
Frameworks & Scriptlets:

User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: Change characters per second based on language

#4 Post by ComputerArt.Club »

Remix wrote: Mon Jul 01, 2019 6:30 am None would (if it works) be Capitalized, though I suspect the parser makes it a string

I would approach the problem from a step higher tbh... brief pseudo-code

Code: Select all

default language_cps = {
    # current, maximum
    None : [ 15, 200 ],
    'chinese' : [ 4, 15 ], 
    ## etc
    }

# bit where you select a language
textbutton "Chinese" action [ SetField( preference, "text_cps", language_cps['chinese'][0] ), Language('chinese') ]

# bit where you adjust cps
value Preference("text speed", range=language_cps[preference.language])
#
# and shoehorn in a bit somewhere that (maybe when you close the prefs screen) takes text_cps and adjusts the language_cps mapping current val
Hope that makes sense
Thanks for this! For this particular game I killed off and replaced the old preferences menu, stripped it down to the bear minimum of what I need for the game. So they only get the set cps. Changing it from none to None actually worked and I was able to fix some other problems with the new translate None code, such as the spacing issues I was having as a result of ruby text in the Japanese translation. Your above code looks really interesting if someone is keeping the preferences menu. I'm sure either I or someone else will learn from it for future games. Thanks again Remix! You are amazing!

Post Reply

Who is online

Users browsing this forum: Semrush [Bot]