Distinct nameboxes per character

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
Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Distinct nameboxes per character

#1 Post by Errilhl »

I'm trying to figure out how to put separate/distinct nameboxes for each character. Namely, I want to change the color (so perhaps this is possible within Renpy - I am actually not sure).

What I have:

I have a textbox (two different textboxes that switch, based on whether or not the narrator or a character with a name speaks - there's a cutout in the background of the name-one to fit the namebox correctly).

That works fine, I've implemented that code in the say screen like this:

Code: Select all

        if who is not None:
            background Image("gui/textbox_cutout.png", xalign=0.5, yalign=1.0)
        else:
            background Image("gui/textbox.png", xalign=0.5, yalign=1.0)
I did it this way, because I had no luck assigning the different textboxes to each character when defining them.

So, I was hoping I could use a similar approach for the nameboxes (I have a default, grey namebox - what I want to do is have the namebox itself change background color on specific characters, instead of changing their text-color).

However, I don't know if there is a way to compare the "who" value of the say-screen, with character-variables.

I tried the following:

Code: Select all

                if who == getattr(store,"fP"):
                    background Image("gui/namebox_fp.png", xalign=0.5, yalign=0)
                elif who == getattr(store, "fM"):
                    background Image("gui/namebox_fm.png", xalign=0.5,yalign=0)
This does NOT work.
I've also tried this:

Code: Select all

                if who == fP:
                    background Image("gui/namebox_fp.png", xalign=0.5, yalign=0)
                elif who == fM:
                    background Image("gui/namebox_fm.png", xalign=0.5,yalign=0)
which doesn't work either.

So, I'm pondering how I can compare the value of the character variable (in these cases fP and fM, containing "Marten" and "Anne") respectively and define their background based on that?

It DOES work if I compare to a specific string - so for another character, an NPC with a set name, it works doing:

Code: Select all

if who == "Karen":
Currently working on: Image

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: Distinct nameboxes per character

#2 Post by Remix »

As you have found, Ren'py does not pass in the character object to the say screen, just passes a simple name string. So, it all basically depends where that name occurs in your script... maybe

if who == fSinput:
or
if who == fS.name:
Frameworks & Scriptlets:

Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Re: Distinct nameboxes per character

#3 Post by Errilhl »

Okay, but it should be possible to use the actual variables? Because, while in the script.rpy, I can display the character's name by simply doing [fP] or [fM] or so on. (Hence, the two button variable-names are present). For some reason they do not seem to work when trying to use them in the say-screen, though... might that have to do with them being defined variables? Ie, they are defined like this:

Code: Select all

define fP = Character("[fPinput]",color="#00ffff")
##
define nK = Character("Karen")
So some are defined with the input-variables, and some are defined as strings. I will test a bit more.

EDIT:
Okay - it works with fPinput and nK.name
So working code:

Code: Select all

                if who == fPinput:
                    background Frame("gui/namebox_fp.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
                elif who == fMinput:
                    background Frame("gui/namebox_fm.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
                elif who == fSinput:
                    background Frame("gui/namebox_fs.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
                elif who == nK.name:
                    background Frame("gui/namebox_nk.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
                elif who == sN.name:
                    background Frame("gui/namebox_sn.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
 
Currently working on: Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot]