how to swicth textbox when narration

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
LiveinAPuddle
Newbie
Posts: 3
Joined: Wed May 17, 2023 12:58 pm
Contact:

how to swicth textbox when narration

#1 Post by LiveinAPuddle »

I've type code like in screens.rpy:

Code: Select all

init python:

    def calculate_window_style(who):
        return "window1" if who is 0 else "window"


python:
    window_style = calculate_window_style(who) 

screen say(who, what):
    style_prefix "say"

    python:
        window_style = calculate_window_style(who)

    window:
        id "window"
        style window_style

        if who is not None:
            window:
                id "namebox"
                style "namebox"
                text who id "who"

        text what id "what"
    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0
        init python:
    config.character_id_prefixes.append('namebox')

style window is default
style window1 is default
style say_label is default
style say_dialogue is default
style say_thought is say_dialogue

style namebox is default
style namebox_label is say_label


style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

    background Image("gui/textbox.png", xalign=0.5, yalign=1.0)
style window1:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

    background Image("gui/UI111.png", xalign=0.5, yalign=1.0)
But I can't use style window1 when I type:

Code: Select all

"afhaifhaifahf"
    "sfalkhakfhalf"
    "fahufhkfahefh"
And it still show style window.

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

Re: how to swicth textbox when narration

#2 Post by Ocelot »

I do not understand what you are trying to do there. who is a string, it cannot be a number.
< < insert Rick Cook quote here > >

LiveinAPuddle
Newbie
Posts: 3
Joined: Wed May 17, 2023 12:58 pm
Contact:

Re: how to swicth textbox when narration

#3 Post by LiveinAPuddle »

Ocelot wrote: Sat Dec 16, 2023 12:26 pm I do not understand what you are trying to do there. who is a string, it cannot be a number.
I hope when character said something,it used first style and when there's no character,it'll use another style.

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

Re: how to swicth textbox when narration

#4 Post by Ocelot »

You can just set style you want for the narrator character:

Code: Select all

define narrator = Character(kind=narrator, window_style="window1")

# . . .
screen say(who, what):
    style_prefix "say"
    window:
        id "window"
        style "window" # no need for conditions, characte-specific style will override that

# . . .
"Hi" # uses window1 style
"Man" "Are you talking to me?" # uses window style
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: No registered users