Making a Side Image stay [Solved!]

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
CheeryMoya
Miko-Class Veteran
Posts: 892
Joined: Sun Jan 01, 2012 4:09 am

Making a Side Image stay [Solved!]

#1 Post by CheeryMoya »

Antithesis of this thread much?

I'm helping redeyesblackpanda with coding Witch Apprentice, and the first day I got my hand on the code there were lines of unnecessary defining images everywhere. I managed to cut down the code by loads, but the thing with WA is that there's a side image of Adriana no matter who the speaker is, even during narration. Here's an example of the code they're running:

Code: Select all

init:
    $ narrator = Character(None,
              color="#c8ffc8",
              show_side_image=ConditionSwitch(
              "aemo == 'neutral'", "a/a neutral.png",
              "aemo == 'awkward'", "a/a awkward-smile.png",
              "aemo == 'grin'", "a/a big_grin.png",
              "aemo == 'eh'", "a/a cocked-brow.png",
              "aemo == 'ugh'", "a/a grimace.png",
              "aemo == 'surprise'", "a/a surprised.png",
              "aemo == 'sigh'", "a/a sigh.png",
              "aemo == 'blush'", "a/a sweet_blush.png",
              "aemo == 'serious'", "a/a very-serious.png",
              "aemo == 'happy'", "a/a happy.png",
              "aemo == 'plain'", "a/a melancholy.png", xalign=0.0, yalign=1.0,        
            )
        )
define npc = DynamicCharacter('npcname',
          color="#c8ffc8",
          show_side_image=ConditionSwitch(
          "aemo == 'neutral'", "a/a neutral.png",
          "aemo == 'awkward'", "a/a awkward-smile.png",
          "aemo == 'grin'", "a/a big_grin.png",
          "aemo == 'eh'", "a/a cocked-brow.png",
          "aemo == 'ugh'", "a/a grimace.png",
          "aemo == 'surprise'", "a/a surprised.png",
          "aemo == 'sigh'", "a/a sigh.png",
          "aemo == 'blush'", "a/a sweet_blush.png",
          "aemo == 'serious'", "a/a very-serious.png",
          "aemo == 'happy'", "a/a happy.png",
          "aemo == 'plain'", "a/a melancholy.png", xalign=0.0, yalign=1.0,        
        )
    )
#etc.

label day_1:
    $ aemo = "plain"
    "Text and stuff, I'm at the left."
Every speaker shows a side image of the same one character, and that's pretty inefficient to define everything like this. There is a way to make the side image stick though (check the thread I linked at the beginning), but I can't seem to get it to work when using Conditional Side Images. I tried:

Code: Select all

init python:
     config.side_image_tag = "a"
     config.side_image_only_not_showing = False
init:
    $ narrator = Character(None,
              color="#c8ffc8")
label day_1:
    $ aemo = "plain"
    "Text and stuff, I'm at the left."
But that didn't work.

Rather than spend my time trying to figure out how to trim down the code, I'd rather get to renaming all the files. Can someone help me out with this?
Last edited by CheeryMoya on Sun Nov 04, 2012 12:41 am, edited 1 time in total.

User avatar
Arowana
Miko-Class Veteran
Posts: 531
Joined: Thu May 31, 2012 11:17 pm
Completed: a2 ~a due~
Projects: AXIOM.01, The Pirate Mermaid
Organization: Variable X, Navigame
Tumblr: navigame-media
itch: navigame
Contact:

Re: Making a Side Image stay

#2 Post by Arowana »

I could be wrong about this, but I get the impression from the documentation that "config.side_image_tag" is only useful for the "image side" method, which uses multiply-defined side images rather than ConditionSwitch sprites. From your Character definitions, it seems that you're using "show_side_image=" instead, so I don't think "config.side_image_tag" will work here.

If you want the same side image to always be on the textbox, the most straightforward way I can think of doing that is to modify the "say" screen directly. If you look at the very end of the "say" screen, you'll see the section that controls the side sprite.

Code: Select all

    # If there's a side image, display it above the text.
    if side_image:
        add side_image
    else:
        add SideImage() xalign 0.0 yalign 1.0
This code is checking to see if there is a side image assigned to the current Character and adds said image accordingly. However, you want the same side image there all the time, so there's no need for the "if" statement. As a result, you can cut all that out and replace it with:

Code: Select all

    # If there's a side image, display it above the text.
    add "adriana_side" #you can adjust the position here using xpos/ypos, etc.
where "adriana_side" is your side image, e.g. defined as:

Code: Select all

init:
    image adriana_side = ConditionSwitch(
        "aemo == 'neutral'", "a/a neutral.png",
        "aemo == 'awkward'", "a/a awkward-smile.png",
        "aemo == 'grin'", "a/a big_grin.png",
        # and so forth

You might also want to adjust the left padding on your textbox to accommodate the side sprite. There are 2 locations in your "say" screen where you'll have to change the padding - one for the "one window variant" and one for the "two window variant". It will probably look something like:

Code: Select all

       
window:
    id "window"
    left_padding 180 #<-------put in extra padding for the side sprite (depending on how much space you need)


Of course, you could always add extra padding/side sprites to all your Characters, but I generally find that if you're going to change a screen setting for everything, it's easier to change the screen directly. :)
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)

Image

CheeryMoya
Miko-Class Veteran
Posts: 892
Joined: Sun Jan 01, 2012 4:09 am

Re: Making a Side Image stay

#3 Post by CheeryMoya »

Success! It works perfectly and you saved the script.rpy over 84 lines of code before the actual game even began O: Am I the only who hates seeing that space above label start: be oh-so very long?

In case I ever need an ADV speaker that doesn't show a side image though, is there a single speaker code I can use to nullify the base setting? Thanks for your help so far :3

User avatar
Arowana
Miko-Class Veteran
Posts: 531
Joined: Thu May 31, 2012 11:17 pm
Completed: a2 ~a due~
Projects: AXIOM.01, The Pirate Mermaid
Organization: Variable X, Navigame
Tumblr: navigame-media
itch: navigame
Contact:

Re: Making a Side Image stay

#4 Post by Arowana »

Sure, we can use the "show_" option in the Character definition to do that. The explanation of this in the documentation (very bottom) isn't great, but, basically, if you put a keyword beginning with "show_" in a Character definition, the "show_" prefix is stripped off and the rest of the keyword is sent as a variable to the "say" screen.

For example, let's define a new variable called "noMC". If "noMC" is True, we'll revert back to the original side image code (i.e. only show a side image if it's specified in the Character's definition), else we'll keep the MC side image. So the side image code at the bottom of the "say" screen is now:

Code: Select all

    # If there's a side image, display it above the text.
    default noMC = False # noMC is False by default, since we want to show the MC side image
    
    if noMC: #if noMC is True, we use the original side image code
        if side_image:
            add side_image
        else:
            add SideImage() xalign 0.0 yalign 1.0
    else: #else, we use the MC's side image
        add "adriana_side"


Now we can change the value of "noMC" for a given Character by writing "show_noMC = True" in their Character definition. For instance, here's a character that will have no side image (and who will also readjust the left padding on the text to 0):

Code: Select all

define b = Character("Blah", color="#c8ffc8", show_noMC = True, window_left_padding = 0)
Hope that works! Let me know if you have any issues!

(Haha, the space above my "start" label" has become quite messy - I need to start organizing stuff into new .rpy files)
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)

Image

CheeryMoya
Miko-Class Veteran
Posts: 892
Joined: Sun Jan 01, 2012 4:09 am

Re: Making a Side Image stay

#5 Post by CheeryMoya »

Thank you so much it works ;u; I'm going to hug the crap out of you bless your soul

Post Reply

Who is online

Users browsing this forum: No registered users