[Solved]Problem with characters

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
Andredron
Miko-Class Veteran
Posts: 535
Joined: Thu Dec 28, 2017 2:37 pm
Completed: Kimi ga nozomu renpy-port(demo), Albatross Koukairoku(demo)
Projects: Sisters ~Natsu no Saigo no Hi~(renpy-port)
Location: Russia
Contact:

[Solved]Problem with characters

#1 Post by Andredron » Sat Sep 03, 2022 9:01 am

Good afternoon, please help with the code

I need to turn on the subtitles mode in the settings, but I don't have enough ideas how to adjust the screen

Youtube subtitle screen

Code: Select all

screen cap(who, what):
    frame:
        style "empty"               # The empty style resets the frame to no background, margins, or padding.
        background "#000"           # Set the background to black.
        padding (5, 5)              # Add a bit of padding.
        xalign 0.5                  # Center the text.
        yalign 1.0 yoffset -25

        text what:
            id "what"               # Ren'Py needs this for a say screen to work.
            pos (0, 0)              # This screen needs the text to be positioned at (0, 0)
            layout "subtitle"       # Subtitle layout tries to make all lines even.
            text_align 0.5          # Center the text within the text block.
            size 25                 # Set the text size.
And in the character, if you register it, it works fine

Code: Select all

define au = Character(None, screen="cap")
But when I try to register in the settings, the mode (YouTube or normal), the program does not want to react in any way.

Roughly speaking, I'm trying to do this

Code: Select all

default youtube_mode = False

if youtube_mode == True:
    define au= Character(None, screen="cap")
else:
    define au = Character('???', color="#f7f4f4", what_color="#f7f4f4", window_background="gui/bac.png")
In the settings screen

Code: Select all

screen preferences():
    add "images/pref.png"
    add "images/pref2.png"
    tag menu
    fixed:
        label _("{size=25}{color=#ffffff}Font"):
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            xalign 0.23 yalign 0.16
        textbutton_("Default"):
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            xalign 0.46 yalign 0.17
            action gui.SetPreference("font", "DejaVuSans.ttf")
        textbutton _("DuduCyrillic"):
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            xalign 0.62 yalign 0.17
            action gui.SetPreference("font", "font/duducyrillic.ttf")
        textbutton _("Philosopher"):
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            xalign 0.75 yalign 0.17
            action gui.SetPreference("font", "font/philosopher.ttf")
        
        label _("{size=24}{color=#ffffff}Skip"):
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            xalign 0.23 yalign 0.24
        textbutton _("Viewed text only"):
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            xalign 0.5 yalign 0.24
            action Preference("skip", "seen")
        textbutton _("All text"):
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            xalign 0.75 yalign 0.24
            action Preference("skip", "all")
        
        label _("{size=22}{color=#ffffff}AutoRead"):
             text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
             xalign 0.23 yalign 0.32
         textbutton _("Enable"):
             text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
             xalign 0.5 yalign 0.32
             action [Preference("auto-forward", "enable", Preference("auto-forward after click", "toggle"))]
         textbutton _("Disable"):
             text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
             xalign 0.75 yalign 0.32
             action [Preference("auto-forward", "disable"), Preference("auto-forward after click", "toggle")]
        
        label _("{size=22}{color=#ffffff}Youtub\nmode"):
            xalign 0.23 yalign 0.4
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
        textbutton _("Enable"):
            text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ]
            xalign 0.5 yalign 0.4
            action SetField(persistent, "youtube_mode", True)
        textbutton _("Disable"):
            xalign 0.75 yalign 0.4 text_outlines [ (absolute(1), "#333333", absolute(1), absolute(1)) ] action SetField(persistent, "youtube_mode", False)
        
        
        textbutton _("{size=25}{color=#ffffff}Return") xalign 0.05 yalign 0.9 action Return()
please help me to set the mode
Last edited by Andredron on Sat Sep 03, 2022 6:48 pm, edited 4 times in total.
I'm writing a Renpy textbook (in Russian). https://disk.yandex.ru/i/httNEajU7iFWHA (all information is out of date) Update 22.06.18

Help me to register in QQ International

Honest Critique

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

Re: Problem with characters

#2 Post by Ocelot » Sat Sep 03, 2022 9:15 am

define statements are executed in init time. Conditional statements as written do not.

default statement executed in runtime too, so you cannot rely on it in init time conditions.

If you do not need ability to change youtube_mode during the game:

Code: Select all

define youtube_mode = False

init:
    if youtube_mode:
        define au= Character(None, screen="cap")
    else:
        define au = Character('???', color="#f7f4f4", what_color="#f7f4f4", window_background="gui/bac.png")
If it is something you want to change during the game:

Code: Select all

default youtube_mode = False
default au = Character(None, screen="cap") if youtube_mode else Character('???', color="#f7f4f4", what_color="#f7f4f4", window_background="gui/bac.png")
# or
label start:
    python:
        if youtube_mode:
            au= Character(None, screen="cap")
        else:
            au = Character('???', color="#f7f4f4", what_color="#f7f4f4", window_background="gui/bac.png")
[/code]
Or any other way of setting variable in runtime.
< < insert Rick Cook quote here > >

Post Reply

Who is online

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