How to move the namebox for certain 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
ConerNSFW
Regular
Posts: 40
Joined: Sun Oct 23, 2016 5:08 pm
Contact:

How to move the namebox for certain characters?

#1 Post by ConerNSFW »

I would like to move the namebox and change the background for certain characters. I've looked up several guides and the information seems to either be incorrect or outdated.

User avatar
KuroOneHalf
Regular
Posts: 129
Joined: Fri Apr 25, 2014 6:18 pm
Completed: Cuttlebone
Projects: Somewhere In The Shade
Deviantart: KuroOneHalf
itch: kuroonehalf
Contact:

Re: How to move the namebox for certain characters?

#2 Post by KuroOneHalf »

Inside the say screen you can identify what character is speaking and change what assets you display by doing something like this:

Code: Select all

define m = Character("Mary")
define j = Character("Jim")
screen say:
    ...
    window:
            id "window"

            if who == "Mary":
                background "mary_textbox.png"
            elif who == "Jim":
                background "jim_textbox.png"
            ...

Alternatively, if you just want to change the textbox background, you can do something like this:

Code: Select all

define m = Character("Mary", window_background="mary_textbox.png")
define j = Character("Jim", window_background="jim_textbox.png")

ConerNSFW
Regular
Posts: 40
Joined: Sun Oct 23, 2016 5:08 pm
Contact:

Re: How to move the namebox for certain characters?

#3 Post by ConerNSFW »

With your help I managed to get what I wanted.

I use a variable to define if the game is in a cutscene or not and the say screen display different things based on this variable.

Code: Select all

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

        
        if not cutscene:
            background "gui/textbox.png"
            text what id "what"
            if who is not None:

                window:
                    style "namebox"
                    text who id "who"
        elif cutscene:
            background "gui/textbox_cutscene.png"
            text what id "what":
                xpos 100
            if who is not None:

                window:
                    style "namebox2"
                    text who id "who"
Anyway thanks for the help.

Post Reply

Who is online

Users browsing this forum: Google [Bot]