Ren'Py [SOLVED]Toggle on/off Side Images in the settings menu?

Nov 15, 2019
13
34
Hello, I'm a beginner at renpy (started 2 months ago) and im trying my best to understand everything. I'm currently developing a 2d game that has a sandbox type(i know im going to pull my hair out on this one later on. But it's ok, hard work pays off! XD) I really love to customize everything in the main menu and I currently came across an issue of sometimes people who test my build, they tell me sometimes its hard to see who's talking unless they keep looking back at the name. I didn't color code the name since I didn't want to lol So instead, i decided to put side images in it to show who's talking along with the name of the person.

Well, long story short, I'm not quite sure if everyone likes sides images so I wanted to input a code into the settings for players having the ability to toggle side images on and off. I managed to make the side images work even with different expressions and whatnot. But when I search online for how to toggle the side images in the settings, I found one but when i tried it, it doesn't work. The toggle in the setting is there but when i click on it and test out the game, it does absolutely nothing since the side images is still there. I was wondering if there is anything wrong with the code or maybe im doing something wrong completely.

Here is the code:

Python:
init python:
    if persistent.side_images is None:
        persistent.side_images = True

screen say(who, what):
    tag menu
    style_prefix "say"

    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"

        text what id "what"

    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0


also here is the textbutton code i placed for the preferences section:

Python:
textbutton _("{b}Toggle Side Images{/b}") action [ToggleField(persistent, "side_images"), SelectedIf(persistent.side_images)]



my names section for side images look like this:
Python:
#Main Character
define b = Character("Blake", ctc="ctcanim", ctc_position="nestled", image="blake")
define p = Character("[pname]", ctc="ctcanim", ctc_position="nestled", image="blake")


the images section for side images of different expression look like this:

Python:
#blake
image side blake kid = "sideblakekid.png"
image side blake ksad = "sideblakekidsad.png"
image side blake kidangry1 = "sideblakekidangry2.png"
image side blake kidangry2 = "sideblakekidangry.png"
image side blake teenmask = "sideblaketeenmask.png"
image side blake teenangry = "sideblaketeenangry.png"

The side images works fine and im able to set different expression based on the scenes. the code is in there since when i go to the settings, I can see the toggle on and off for side images like this:

Screen Shot 2020-06-04 at 3.00.55 PM.jpg




Even when i uncheck the box in the settings, it's still there. The side images look like this:
Screen Shot 2020-06-04 at 3.01.48 PM.jpg



To sum it up, the code is not working since even when i turn it off, it's still there. If anyone can give me any pointers or help to see what I'm doing wrong, that would be really helpful.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,110
14,782
Python:
screen say(who, what):
[...]
    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0
The problem is in those two lines. They have to be conditioned with the flag displaying, or not, the side image :
Code:
    if persistent.side_images and not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0
 
Nov 15, 2019
13
34
The problem is in those two lines. They have to be conditioned with the flag displaying, or not, the side image :
Code:
    if persistent.side_images and not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0

OMG! THANK YOU SO MUCH! IT WORKS NOW! Really thank you! I've been trying to figure it out since monday! Thank you!