[SOLVED] Code for simply changing the language in Python?

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
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

[SOLVED] Code for simply changing the language in Python?

#1 Post by Obscura »

For the life of me, I can't find the answer to what's apparently a very simple question.

When the game runs, I'd like it to check to see if one of two files exists. If they DON'T exist, I'd like the game to change the language to None (English.)

I realize the engine defaults to None anyway, but this is just in case a player has yanked out the translation folder and hasn't put it back in. If I don't do this, it seems some of the fonts go wonky.

For the purposes of simplification:

Code: Select all

init -2 python:

    if not renpy.loadable("spanish.ttf") or not renpy.loadable("spanish.otf"):
       renpy.change_language(None)
     
I get:
While running game code:
File "game/translation.rpy", line 1, in script
init -2 python:
File "game/translation.rpy", line 5, in <module>
renpy.change_language(None)
TypeError: argument of type 'NoneType' is not iterable
What should the syntax be?

Thanks!
Last edited by Obscura on Mon Jan 21, 2019 7:07 pm, edited 1 time in total.
Coming Out On Top - An Adult Gay Dating Sim
website

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Code for simply changing the language in Python?

#2 Post by IrinaLazareva »

Maybe this function is not applicable at the init stage..so try:

Code: Select all

label splashscreen:
    if not renpy.loadable("spanish.ttf") or not renpy.loadable("spanish.otf"):
       $ renpy.change_language(None)
    return

User avatar
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

Re: Code for simply changing the language in Python?

#3 Post by Obscura »

Thanks IrinaLazareva, that did the trick!!! (I tried Language(None) as well under python, it did nothing.)
Coming Out On Top - An Adult Gay Dating Sim
website

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], RandomHuman64