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: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Language chooser loop error

#1 Post by neometalero »

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 many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Language chooser loop error

#2 Post by Kia »

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: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Language chooser loop error

#3 Post by xavimat »

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!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Language chooser loop error

#4 Post by neometalero »

Tks I will try this, and see if its works.
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Language chooser loop error

#5 Post by neometalero »

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 many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

Post Reply

Who is online

Users browsing this forum: 102_funny