Differentiating the Namebox (SOLVED :3)

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
Snow Blossom
Veteran
Posts: 419
Joined: Fri May 13, 2011 10:30 pm
Location: Right. Behind. You.
Contact:

Differentiating the Namebox (SOLVED :3)

#1 Post by Snow Blossom »

After struggling with this problem for days, I still haven't been able to solve it: HOW THE HECK DO I MAKE A CERTAIN CHARACTER'S NAMEBOX DIFFERENT??? :cry:

Basically, I'm trying to shift the MC's name-box so that her sprite doesn't cover it when she's speaking. However, the other characters all have their name-boxes in the default position.
I tried doing this when defining the characters, Lin Zhi Ying being the MC:

Code: Select all

ln = Character('Lin Zhi Ying',
                        show_two_window=True,
                        style.say_who_window.background = Frame("PinkBox.png", 12, 12),
                        style.say_who_window.xpos = 100 
                        style.say_who_window.ypos = 100
                        color="#c8ffc8",
                        window_left_padding=160,
                        show_side_image=Image("Lin Zhi Ying Neutral.png", xalign=0.0, yalign=1.0))
However, whenever I launch the project, it always says,
File "game/script.rpy", line 460: keyword can't be an expression
Line 460 happens to be this line:

Code: Select all

style.say_who_window.background = Frame("PinkBox.png", 12, 12),
Please help before I bang a hole into the wall D:
Last edited by Snow Blossom on Tue Jul 12, 2011 11:46 pm, edited 1 time in total.

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Differentiating the Namebox

#2 Post by Aleema »

Hi!

This is a rarely used feature, but you're about to use it. :D

Code: Select all

show_who_window_properties={ "background": Frame("PinkBox.png", 12, 12) }
That's the only way to set individual properties to the show_two_window for each char. Also, you don't use "style.__" in character declarations either. Here's what your char should look like:

Code: Select all

ln = Character('Lin Zhi Ying',
                        show_two_window = True, 
                        show_who_window_properties={ "background": Frame("PinkBox.png", 12, 12), "xpos": 100, "ypos": 100 },
                        color="#c8ffc8",
                        window_left_padding=160,
                        show_side_image=Image("Lin Zhi Ying Neutral.png", xalign=0.0, yalign=1.0))

0ion9
Regular
Posts: 79
Joined: Thu Jun 16, 2011 9:17 am
Contact:

Re: Differentiating the Namebox

#3 Post by 0ion9 »

And.. the meaning of "keyword can't be an expression" is this.
Keyword-args are like this:

Code: Select all

 KEYWORD = VALUE
KEYWORD can never be an expression, only a name.

Code: Select all

style.say_who_window.ypos
is an expression, meaning 'the ypos property of the say_who_window property of the variable named style',
whereas

Code: Select all

show_two_window
is a name (basically, you're saying, in that line of your example, to the Character function-call : 'use the value True for the local variable "show_two_window"')

Basically, if you can't create a variable named that, it's not a valid KEYWORD.

Snow Blossom
Veteran
Posts: 419
Joined: Fri May 13, 2011 10:30 pm
Location: Right. Behind. You.
Contact:

Re: Differentiating the Namebox

#4 Post by Snow Blossom »

@ Onion9
Aah okay I think I get it now, thanks ^^

@ Aleema
Now the game runs smoothly, except that the name-box doesn't move no matter what values I input for the xpos and ypos :(
I tried fractions and whole numbers but the thing just won't move D:<

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Differentiating the Namebox

#5 Post by Aleema »

Maybe try the same thing but with show_two_window_vbox_properties or show_say_vbox_properties. I forget the difference between these 3. The name box's position will be inherited from the style.say_who_window parent if you've defined that in options.rpy already. Trial and error!

Snow Blossom
Veteran
Posts: 419
Joined: Fri May 13, 2011 10:30 pm
Location: Right. Behind. You.
Contact:

Re: Differentiating the Namebox

#6 Post by Snow Blossom »

I tried all three, separately and all together, but the name-box is still as stubborn as a mule D:

Here's how the code looks with all three together:

Code: Select all

$ ln = Character('Lin Zhi Ying',
                        show_two_window=True,
                        show_who_window_properties={ "background": Frame("PinkBox.png", 12, 12), "xpos": .5, "ypos": 1.0 },
                        show_two_window_vbox_properties={"background": Frame("PinkBox.png", 12, 12), "xpos": .5, "ypos": 1.0},
                        show_say_vbox_properties={"background": Frame("PinkBox.png", 12, 12), "xpos": .5, "ypos": 1.0},
                        color="#c8ffc8",
                        window_left_padding=160,
                        show_side_image=Image("Lin Zhi Ying Neutral.png", xalign=0.0, yalign=1.0))
Aleema wrote:The name box's position will be inherited from the style.say_who_window parent if you've defined that in options.rpy already.
But won't that mean that it'd be the default position if it's in options.rpy?

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Differentiating the Namebox

#7 Post by Aleema »

What I originally posted above totally works for me. =\ I'm running the code in a new project with all default settings, and adjusting the xpos/ypos actually moves the namebox for me. So you should go look at all the styles you've edited so far and see if anything would be locking it in place, such as any parent style.say_who_window styles. That's what I meant -- you need to go check your defaults (if you have them) and either post them here or comment them out temporarily or something until the original code I posted above works for you.

But just to cover a base, is you namebox as wide at the game screen by chance? (in case you're not actually using pinkbox from my tut)

Snow Blossom
Veteran
Posts: 419
Joined: Fri May 13, 2011 10:30 pm
Location: Right. Behind. You.
Contact:

Re: Differentiating the Namebox

#8 Post by Snow Blossom »

Although I'm not using the pinkbox from your tutorial (I just named it that lol), the one I'm using isn't as wide as the game screen.

I created a new project with only these lines in the script.rpy:

Code: Select all

init:
    $ ln = Character('Lin Zhi Ying',
                        show_two_window=True,
                        show_who_window_properties={ "background": Frame("PinkBox.png", 12, 12), "xpos": .1, "ypos": 1.0 },
                        show_two_window_vbox_properties={"background": Frame("PinkBox.png", 12, 12), "xpos": .1, "ypos": 1.0},
                        show_say_vbox_properties={"background": Frame("PinkBox.png", 12, 12), "xpos": .1, "ypos": 1.0},
                        color="#c8ffc8",
                        window_left_padding=160)
    
label start:
    ln "GAAAH"
and one thing added to the options.rpy:

Code: Select all

style.window.background = Frame("PinkBox.png", 12, 12)
And it still won't work. >3<
So I'm guessing that the problem has something to do with the style.window.background code, but I don't see how... :?

0ion9
Regular
Posts: 79
Joined: Thu Jun 16, 2011 9:17 am
Contact:

Re: Differentiating the Namebox

#9 Post by 0ion9 »

I've tried and I agree.

Code: Select all

style.window.background = Frame("PinkBox.png", 12, 12)
Don't you want style.say_who_window.background?

style.say_who_window.background = Frame("PinkBox.png", 15, 15)

works for me.

But I still can't override it per-character:

Code: Select all

# Some minimal code.
init:
    python:
        prbox = Frame ("PurpleBox.png", 15, 15)

# Declare characters used by this game.
define ln = Character('Lin Zhi Ying',
                      show_two_window=True)

define AA = Character('Quizzical', show_two_window = True, show_who_window_properties={ "background": prbox})

label start:
    ln "GAAAH"
    AA "???"
btw, you probably don't want show_two_window_vbox_properties, because that would put a pink box under those two windows ( the name and text windows).
http://www.renpy.org/wiki/renpy/doc/ref ... /Character

0ion9
Regular
Posts: 79
Joined: Thu Jun 16, 2011 9:17 am
Contact:

Re: Differentiating the Namebox

#10 Post by 0ion9 »

I managed to get a working implementation.

It involves the following:

* A new keyword arg that actually works: "show_who_window_style"

As in

Code: Select all

define AA = Character('Quizzical', show_two_window = True, show_who_window_style="say_who_window2")
* In options.rpy, setup the style you want to refer to (after you've finished defining any changes to its parent style):

Code: Select all

    style.say_who_window2 = Style ('say_who_window')
    style.say_who_window2.background = Frame("PurpleBox.png", 15, 15)
* Lastly, modify the 'say' screen in screens.rpy to understand the new keyword argument:
** Insert

Code: Select all

default who_window_style = "say_who_window"
near the start of the screen definition
** A bit further down, you'll find a section that looks sort of like this:

Code: Select all

        # The two window variant.
        vbox:
            style "say_two_window_vbox"

            if who:            
                window:
                    style who_window_style

                    text who:
                        id "who"
(-- modify it to look EXACTLY like that :)
Last edited by 0ion9 on Tue Jul 12, 2011 11:38 pm, edited 1 time in total.

Snow Blossom
Veteran
Posts: 419
Joined: Fri May 13, 2011 10:30 pm
Location: Right. Behind. You.
Contact:

Re: Differentiating the Namebox

#11 Post by Snow Blossom »

So now, the options.rpy looks like this:

Code: Select all

## The background of the window. In a Frame, the two numbers
    ## are the size of the left/right and top/bottom borders,
    ## respectively.

    style.window.background = Frame("PinkBox.png", 12, 6)
    style.say_who_window2 = Style ('say_who_window')
    style.say_who_window2.background = Frame("PinkBox.png", 15, 15)
the screens.rpy looks like this:

Code: Select all

# The two window variant.
        vbox:
            style "say_two_window_vbox"

            if who:            
                window:
                    style who_window_style

                    text who:
                        id "who"
and the script.rpy looks like this:

Code: Select all

$ ln = Character('Lin Zhi Ying',
                        show_two_window=True,
                        show_who_window_style="say_who_window2",
                        color="#c8ffc8",
                        window_left_padding=160,
                        show_side_image=Image("Lin Zhi Ying Neutral.png", xalign=0.0, yalign=1.0))
Sorry for the bombardment of codes -_-||
I'm guessing I did something wrong since it still doesn't work :|
Also, could you explain to me what part of the codes you made changes the position of the name-box? The world of codes is still a baffling mystery to me... O_O

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Differentiating the Namebox

#12 Post by Aleema »

I found the problem: it's screens.rpy. My test game did not have that file. Are you using screens.rpy? You could probably delete the entire file, OR just the screen say portion.

Either way, get right of screen say, and my first post in this thread should work. :) Sorry for the run around.

0ion9
Regular
Posts: 79
Joined: Thu Jun 16, 2011 9:17 am
Contact:

Re: Differentiating the Namebox

#13 Post by 0ion9 »

Snow Blossom wrote:So now, the options.rpy looks like this:

(cut)

and the script.rpy looks like this:

Code: Select all

$ ln = Character('Lin Zhi Ying',
                        show_two_window=True,
                        show_who_window_style="say_who_window2",
                        color="#c8ffc8",
                        window_left_padding=160,
                        show_side_image=Image("Lin Zhi Ying Neutral.png", xalign=0.0, yalign=1.0))
Sorry for the bombardment of codes -_-||
I'm guessing I did something wrong since it still doesn't work :|
Also, could you explain to me what part of the codes you made changes the position of the name-box? The world of codes is still a baffling mystery to me... O_O
It doesn't change the position, just the appearance. I was just trying to change the style at all (from a pink to a purple box, in my case). If you can change it, you can change any part of it. like say:
style.say_who_window2.xpos = .5
etc :) (I tested the above and it works, BTW)

As for code, it's just logic -- hopefully the same thing you use to work problems out in RL :) As such, I made the minimal example so I didn't have to think about any extra, possibly confusing elements (just the problem of "why can't I change the
'box style?"). When something is going wrong, it's good to stick to that policy of doing the minimum that could possibly work. (BTW, the plural of (software) code is code -- like sheep is the plural of sheep.)

EDIT: I've tried to enable dynamic styling through a few different methods, but it doesn't seem to work. On reflection, this is probably good.. you don't really want a bazillion box styles, so it's better to predefine them.

Snow Blossom
Veteran
Posts: 419
Joined: Fri May 13, 2011 10:30 pm
Location: Right. Behind. You.
Contact:

Re: Differentiating the Namebox

#14 Post by Snow Blossom »

It works now!! :D :D :D
Thank you guys!!
0ion9 wrote:(BTW, the plural of (software) code is code -- like sheep is the plural of sheep.)
lol I guess that just demonstrates my noobness :lol:

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Differentiating the Namebox

#15 Post by chocoberrie »

0ion9 wrote:I managed to get a working implementation.

It involves the following:

* A new keyword arg that actually works: "show_who_window_style"

As in

Code: Select all

define AA = Character('Quizzical', show_two_window = True, show_who_window_style="say_who_window2")
* In options.rpy, setup the style you want to refer to (after you've finished defining any changes to its parent style):

Code: Select all

    style.say_who_window2 = Style ('say_who_window')
    style.say_who_window2.background = Frame("PurpleBox.png", 15, 15)
* Lastly, modify the 'say' screen in screens.rpy to understand the new keyword argument:
** Insert

Code: Select all

default who_window_style = "say_who_window"
near the start of the screen definition
** A bit further down, you'll find a section that looks sort of like this:

Code: Select all

        # The two window variant.
        vbox:
            style "say_two_window_vbox"

            if who:            
                window:
                    style who_window_style

                    text who:
                        id "who"
(-- modify it to look EXACTLY like that :)
Oh my goodness thank you so so so much for posting this! I had no idea how to go about defining different name boxes for different characters! I had a feeling it was say_who_window, but I didn't know how to implement it.

Thanks again!! ; v ;

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Imperf3kt