Can't init persistent data before the menu page

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
Mirrodin
Regular
Posts: 114
Joined: Sun Mar 19, 2017 2:56 pm
Contact:

Can't init persistent data before the menu page

#1 Post by Mirrodin »

Hi guy's,

I want my players can choose the langage in the main page with imagebutton so here is the code:

Code: Select all

 imagebutton idle "gui/bouton_menu/eng.png" hover "gui/bouton_menu/eng_hover.png" selected_idle "gui/bouton_menu/eng_selected.png" selected_hover "gui/bouton_menu/eng_hover_selected.png" action SetVariable("persistent.lang","english") xpos 900 ypos 50
Until here, all is good !
I init my persistent variable like this :

Code: Select all

init python :
    persistent.lang = "english"
But when I launch the game, I have this error :

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00action_data.rpy", line 50, in get_selected
    return getattr(self.object, self.field) == self.value
AttributeError: 'StoreModule' object has no attribute 'persistent.lang'

Windows-8-6.2.9200
Ren'Py 6.99.14.1.3218
debugging version 0.3.0 
Wed Mar 07 14:31:57 2018
What did I do wrong ?

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Can't init persistent data before the menu page

#2 Post by rayminator »

don't space the :

Code: Select all

init python:
    persistent.lang = "english"

User avatar
Mirrodin
Regular
Posts: 114
Joined: Sun Mar 19, 2017 2:56 pm
Contact:

Re: Can't init persistent data before the menu page

#3 Post by Mirrodin »

Code: Select all

don't space the :
Yeah, thanks. But this isn't this. I still have the error.

User avatar
Mirrodin
Regular
Posts: 114
Joined: Sun Mar 19, 2017 2:56 pm
Contact:

Re: Can't init persistent data before the menu page

#4 Post by Mirrodin »

Problem solved.
I remove the "persistent." and all is good.

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Can't init persistent data before the menu page

#5 Post by Milkymalk »

But that makes it no longer a persistent variable.
Try using the Function() action on the button to call a function that changes the persistent variable.
Also, always check for existing persistents or you will overwrite them:

Code: Select all

init python:
    if not persistent.lang:
        persistent.lang = "english"
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

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: Can't init persistent data before the menu page

#6 Post by Remix »

You should consider Ren'py's built in language support, basically config.language = ... also supports action Language('kilngon') rather than having to use SetVariable etc

https://www.renpy.org/dev-doc/html/tran ... t-language
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot]