Trouble with updating the value of gui.interface_text_font

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
Alem
Regular
Posts: 38
Joined: Wed Mar 15, 2017 7:53 am
Contact:

Trouble with updating the value of gui.interface_text_font

#1 Post by Alem »

Greetings! A newbish question about variables here. I want to swap interface font and language at the same time from the options menu. Looks like it has to be done via action command, so I tried to do it by tinkering with language button snippet in screens.rpy. Like this:

Code: Select all

label _("Language")
                        
textbutton "English" action [SetVariable("gui.interface_text_font", "1.ttf"), Language(None)]
textbutton "Русский" action [SetVariable("gui.interface_text_font", "Double.ttf"), Language("russian")]
It results in a crash after clicking on the options button from game menu:

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 'gui.interface_text_font'
Being newbie in coding really sucks :< I guess it's not really a variable, but I''m aiming for this parameter from gui.rpy:

Code: Select all

## The font used for out-of-game text.
define gui.interface_text_font = "DejaVuSans.ttf"
Changing it directly gets the job done, but I want to be able to switch between two sets of languages and interface fonts on the fly. Is there a way to do this?

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Trouble with updating the value of gui.interface_text_fo

#2 Post by gas »

Use style preference actions.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Trouble with updating the value of gui.interface_text_fo

#3 Post by Ocelot »

gui variables are read-only (and you should use SetField to set members of class). Even if they weren't, they are read only once at startup, so changing them ingame would achieve nothing.
You want style translations: https://www.renpy.org/doc/html/translat ... anslations
Find every style which uses gui.interface_text_font in screens.rpy. For sake of the example, I assume that it is used only in style 'foo', and that gui.interface_text_font is set to "1.ttf".
You would need to add following lines to your translation:

Code: Select all

translate russian style foo:
    font "Double.ttf"
< < insert Rick Cook quote here > >

Alem
Regular
Posts: 38
Joined: Wed Mar 15, 2017 7:53 am
Contact:

Re: Trouble with updating the value of gui.interface_text_fo

#4 Post by Alem »

Ocelot wrote:gui variables are read-only (and you should use SetField to set members of class). Even if they weren't, they are read only once at startup, so changing them ingame would achieve nothing.
You want style translations: https://www.renpy.org/doc/html/translat ... anslations
Find every style which uses gui.interface_text_font in screens.rpy. For sake of the example, I assume that it is used only in style 'foo', and that gui.interface_text_font is set to "1.ttf".
You would need to add following lines to your translation:

Code: Select all

translate russian style foo:
    font "Double.ttf"
Thank you, worked like a charm.

kamti
Regular
Posts: 31
Joined: Sun Apr 12, 2015 1:50 am
Completed: The Book of Bondmaids
Contact:

Re: Trouble with updating the value of gui.interface_text_fo

#5 Post by kamti »

Ocelot wrote: Sat Mar 18, 2017 9:00 am gui variables are read-only (and you should use SetField to set members of class). Even if they weren't, they are read only once at startup, so changing them ingame would achieve nothing.
You want style translations: https://www.renpy.org/doc/html/translat ... anslations
Find every style which uses gui.interface_text_font in screens.rpy. For sake of the example, I assume that it is used only in style 'foo', and that gui.interface_text_font is set to "1.ttf".
You would need to add following lines to your translation:

Code: Select all

translate russian style foo:
    font "Double.ttf"
Thank you very much Ocelot!
So many years passed, but your reply helped me as well today!

Post Reply

Who is online

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