if side_image with styles

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
Pierrou
Regular
Posts: 53
Joined: Fri Dec 05, 2014 8:25 pm
Projects: Togainu no Chi, DMMD, Omerta, ...
Skype: pierrouney
Location: France
Contact:

if side_image with styles

#1 Post by Pierrou » Sat Sep 26, 2015 2:10 pm

Hi !

I'm trying to change the style if there's a side_image or not.

We have 3 text-boxes.
1) Narrator
2) Character (without side_image)
3) Character (with side_image)

I wanted to do something like :

in options.rpy :

Code: Select all

    style.window.background = "image/box/box1.png"
in screens.rpy (screen say)

Code: Select all

    if side_image:
        add SideImage() xpos 44 ypos 398
        $ style.window.background = "image/box/box3.png"
        $ style.say_who_window.left_padding = 150
    else:
        $ style.window.background = "image/box/box2.png"
        $ style.say_who_window.left_padding = 60
I've no error but it doesn't work... When i start a game, i can see the side_image if i put one in script.rpy but the style doesn't change. BUT when i start the game another time, the style is now changed x) So i have the left_padding for all my sentences...

How can i do something like that ?

Thank you :)
Sorry for my english, it's not my native language. :s

User avatar
Donmai
Eileen-Class Veteran
Posts: 1919
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: if side_image with styles

#2 Post by Donmai » Sat Sep 26, 2015 2:47 pm

I would suggest you to change the dialogue boxes and padding using your character definitions. Something like:

1) Narrator

Code: Select all

define narrator = Character(None, window_background="box1.png")
2) Character (without side_image)

Code: Select all

define e = Character("Eileen", window_background="box2.png")
3) Character (with side_image)

Code: Select all

define e = Character("Eileen", image="eileen", window_background="box3.png", window_left_padding=220)
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
Pierrou
Regular
Posts: 53
Joined: Fri Dec 05, 2014 8:25 pm
Projects: Togainu no Chi, DMMD, Omerta, ...
Skype: pierrouney
Location: France
Contact:

Re: if side_image with styles

#3 Post by Pierrou » Sat Sep 26, 2015 3:14 pm

Thank you to answer me ^^
Donmai wrote:2) Character (without side_image)

Code: Select all

define e = Character("Eileen", window_background="box2.png")
3) Character (with side_image)

Code: Select all

define e = Character("Eileen", image="eileen", window_background="box3.png", window_left_padding=220)
It's not possible to do that, isn't it ? e is already used for the Eileen (without side_image).

I used this before but i had

Character (without side_image)

Code: Select all

define e = Character("Eileen", window_background="box2.png")
Character (with side_image)

Code: Select all

define es = Character("Eileen", image="eileen", window_background="box3.png", window_left_padding=220)
but in the script i'll have to do :

Code: Select all

e "hello i don't have any side image"
es angry "i have a side image"
it will be so hard to not do an error... That's why I don't wanted to declare all my characters twice :wink: I don't understand why we can't just do "if there is a side_image you apply this style" :oops:

EDIT :
You'll maybe understand better with my scripts :

characters.rpy (just one character)

Code: Select all

init:
    $ aki = Character("Akira",
        voice_tag="akira",
        ctc="ctc_blink", ctc_pause="ctc_blink",
        what_prefix='"', what_suffix='"',
        image="akira")

#AKIRA
image akira                           = "image/chara/akira/st_akira1.png" #never used
image side akira shirt grief          = "image/charas/akira/akira_1.jpg"
image side akira shirt pain           = "image/charas/akira/akira_2.jpg"
image side akira shirt anxious        = "image/charas/akira/akira_3.jpg"
image side akira shirt talk           = "image/charas/akira/akira_4.jpg"
image side akira shirt eyeshut        = "image/charas/akira/akira_5.jpg"
image side akira shirt shy            = "image/charas/akira/akira_6.jpg"
image side akira shirt blush          = "image/charas/akira/akira_7.jpg"
image side akira shirt smile          = "image/charas/akira/akira_8.jpg"
image side akira shirt glare          = "image/charas/akira/akira_9.jpg"
image side akira shirt shock          = "image/charas/akira/akira_10.jpg"
image side akira shirt notag pain     = "image/charas/akira/akira_11.jpg"
image side akira shirt notag talk     = "image/charas/akira/akira_12.jpg"
image side akira jacket notag pain    = "image/charas/akira/akira_13.jpg"
image side akira jacket notag anxious = "image/charas/akira/akira_14.jpg"
image side akira jacket notag talk    = "image/charas/akira/akira_15.jpg"
image side akira jacket notag eyeshut = "image/charas/akira/akira_16.jpg"
image side akira jacket notag glare   = "image/charas/akira/akira_17.jpg"
image side akira jacket notag shock   = "image/charas/akira/akira_18.jpg"
image side akira jacket grief         = "image/charas/akira/akira_19.jpg"
image side akira jacket pain          = "image/charas/akira/akira_20.jpg"
image side akira jacket anxious       = "image/charas/akira/akira_21.jpg"
image side akira jacket talk          = "image/charas/akira/akira_22.jpg"
image side akira jacket eyeshut       = "image/charas/akira/akira_23.jpg"
image side akira jacket shy           = "image/charas/akira/akira_24.jpg"
image side akira jacket blush         = "image/charas/akira/akira_25.jpg"
image side akira jacket smile         = "image/charas/akira/akira_26.jpg"
image side akira jacket glare         = "image/charas/akira/akira_27.jpg"
image side akira jacket shock         = "image/charas/akira/akira_28.jpg"
image side akira naked grief          = "image/charas/akira/akira_29.jpg" #NakedGrief
image side akira naked pain           = "image/charas/akira/akira_30.jpg"
image side akira naked anxious        = "image/charas/akira/akira_31.jpg"
image side akira naked talk           = "image/charas/akira/akira_32.jpg"
image side akira naked shy            = "image/charas/akira/akira_34.jpg"
image side akira naked blush          = "image/charas/akira/akira_35.jpg"
image side akira naked eyeshut        = "image/charas/akira/akira_36.jpg"
screen say

Code: Select all

screen say:

    default side_image = None
    default two_window = True

    window:
        id "window"

        has vbox:
            style "say_vbox"

            text what:
                id "what"
                line_spacing 10

    if side_image:
        add SideImage() xpos 44 ypos 398
        $ style.say_what_window.left_padding = 150
        $ style.window.background = "image/box/box3.png"
    else:
        $ style.say_what_window.left_padding = 60
        $ style.window.background = "image/box/box2.png"

    if who:
        window:
            style "say_who_window"

            text who:
                id "who"
                xalign .5
Sorry for my english, it's not my native language. :s

User avatar
Donmai
Eileen-Class Veteran
Posts: 1919
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: if side_image with styles

#4 Post by Donmai » Sat Sep 26, 2015 4:45 pm

Pierrou wrote:It's not possible to do that, isn't it ? e is already used for the Eileen (without side_image).
You are right. My bad. I just forgot to rename the second character. As far as I know, styles can only be changed at init time. Maybe someone else can find another solution.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: if side_image with styles

#5 Post by philat » Sat Sep 26, 2015 11:22 pm

Styles are not changeable after init time. You have to have two different styles initialized and applied. I haven't tested this code, and I don't know if side_image (the screen variable) actually indicates whether or not there is a side image since the else refers to a SideImage() which I believe is actually the side image that gets shown, but in concept, I think you should do something like the following:

Code: Select all

init:
    style sideimagestyle is say_window:
        background "blah"
        left_padding 150
    style normalstyle is say_window:
        background "blah"
        left_padding 60

screen say(who, what, side_image=True, two_window=False):

    # Decide if we want to use the one-window or two-window variant.
    if not two_window:

        # The one window variant.
        window:
            id "window"
            if side_image:
                style "sideimagestyle"
            else:
                style "normalstyle"

Post Reply

Who is online

Users browsing this forum: Bing [Bot]