Language chooser loop error

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
neometalero
Regular
Posts: 107
Joined: Sun Oct 23, 2016 3:51 am
Deviantart: neometalero
Contact:

Language chooser loop error

#1 Post by neometalero » Sun Jul 28, 2019 1:51 pm

Im using this language chooser, but after the restart if I start the game again it goes to this menu again, is there any way so I can save the chose option?

Code: Select all

label language_chooser:
    scene black
    menu:
        "English":
            $ renpy.change_language(None)
        "Español":
            $ renpy.change_language("espaniol")
    $ renpy.utter_restart() 
also if I dont put the line

Code: Select all

 $ renpy.utter_restart()
the code continues but then the correct language is not selected (only the default one). Any ideas?
Working on Attack Helicopter Dating Simulator

Image

User avatar
Kia
Miko-Class Veteran
Posts: 883
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Skype: KiaAzad
Contact:

Re: Language chooser loop error

#2 Post by Kia » Mon Jul 29, 2019 12:48 pm

you can use a persistent variable: https://www.renpy.org/doc/html/persistent.html

Code: Select all

if not persistent.lang_check:
    menu:
        "English":
            $ renpy.change_language(None)
        "Español":
            $ renpy.change_language("espaniol")
    $  persistent.lang_check = True
    $ renpy.utter_restart() 

User avatar
xavimat
Eileen-Class Veteran
Posts: 1433
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: xavimat
Location: Italy
Contact:

Re: Language chooser loop error

#3 Post by xavimat » Wed Jul 31, 2019 9:59 am

The "change language" function already restarts renpy (or something like that). It's possible that your lines after the menu are not executed. Be sure to change the persistent variable immediately before the change_language but not before the menu:

Code: Select all

if not persistent.lang_check:
    menu:
        "English":
            $  persistent.lang_check = True
            $ renpy.change_language(None)
        "Español":
            $  persistent.lang_check = True
            $ renpy.change_language("espaniol")
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Cops&Robbers A two-player experiment
Fear&Love Why can’t we simply express our feelings? Why am I afraid to say ‘I love you’?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
neometalero
Regular
Posts: 107
Joined: Sun Oct 23, 2016 3:51 am
Deviantart: neometalero
Contact:

Re: Language chooser loop error

#4 Post by neometalero » Thu Aug 01, 2019 4:06 pm

Tks I will try this, and see if its works.
Working on Attack Helicopter Dating Simulator

Image

User avatar
neometalero
Regular
Posts: 107
Joined: Sun Oct 23, 2016 3:51 am
Deviantart: neometalero
Contact:

Re: Language chooser loop error

#5 Post by neometalero » Thu Aug 01, 2019 4:59 pm

Kia wrote:
Mon Jul 29, 2019 12:48 pm
you can use a persistent variable: https://www.renpy.org/doc/html/persistent.html

Code: Select all

if not persistent.lang_check:
    menu:
        "English":
            $ renpy.change_language(None)
        "Español":
            $ renpy.change_language("espaniol")
    $  persistent.lang_check = True
    $ renpy.utter_restart() 
this one worked fine for me tks!
Working on Attack Helicopter Dating Simulator

Image

Post Reply

Who is online

Users browsing this forum: No registered users