Ren'Py Animated gender specific gallery imagebutton

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,327
22,776
Alright, this might be getting a bit complex, so be aware^^

I have my gallery setup like this:

You don't have permission to view the spoiler content. Log in or register now.
and some of these imagebuttons use animations that are gender specific:
Python:
image bjhmovpov = ConditionSwitch(
    "pcgender == 'woman'", Movie(play="anim/bjh2_fem.webm"),
    "True", Movie(play="anim/bjh2.webm"))
I'm trying to show them separately in the gallery. At first I thought it would show the gender last played, which would've been okay, but it doesn't. It seems to take the default value all the time which is male, so I tried to force a gender by putting the same "image" twice in the list with different gender (hence the second empty value in the list) and setting $ pcgender = nameByID[i][1] within the loop, but that also doesn't work, it's always the male version that's shown.
I want to avoid using a menu for choosing the gender here and would prefer to have the animations (images) only shown when it really was seen in the game previously.
I think I'm missing something here, but I can't figure it out :unsure:
 
Apr 24, 2020
192
257
I'm not sure what is going on, but by the sound of $ pcgender = nameByID[i][1] it seems like the 1 points to one gender and 0 points to another, in which case your problem is that all your image button code uses the reference nameByID[i][0].
There just doesn't seem to be any point where you actually refer to the gender of the person when creating the image buttons. I would have expected something more along the lines of this:

You don't have permission to view the spoiler content. Log in or register now.

I haven't tested it, but I hope you get the idea.
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,327
22,776
I'm not sure what is going on, but by the sound of $ pcgender = nameByID[i][1] it seems like the 1 points to one gender and 0 points to another, in which case your problem is that all your image button code uses the reference nameByID[i][0].
There just doesn't seem to be any point where you actually refer to the gender of the person when creating the image buttons. I would have expected something more along the lines of this:

You don't have permission to view the spoiler content. Log in or register now.

I haven't tested it, but I hope you get the idea.
Thanks but that won't work, the first value [0] in the list is the image name and what I meant is that I put the gender value into the list as second value [1] where apliable:
Python:
define nameByID = [["bla","male"],
                   ["blubb","female"],
                   ...
and then use $ pcgender = nameByID[i][1], where pcgender is the variable I use in ConditionSwitch in the image declaration, but that didn't work. Maybe it can't be changed in runtime, but I'm not sure about it.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,964
16,209
Note: it's the first day of lockdown chapter 2 here, and more than 1 hour that my upstairs neighbors decided to drill holes in all the walls of his flat. So I give no guaranty that I'll not make a lot of errors :(


[...] I tried to force a gender by putting the same "image" twice in the list with different gender (hence the second empty value in the list) and setting $ pcgender = nameByID[i][1] within the loop, but that also doesn't work, it's always the male version that's shown.
You mean something like this :
Code:
screen g_images():
    grid 3 3:
        for i in range(page*gridSize,(page+1)*gridSize):
            if i < len(nameByID):
                if pcgender == "woman":
                    $ pcgender = "man"
                else:
                    $ pcgender = "woman"
                [...]
or like that :
Code:
screen g_images():
    grid 3 3:
        for i in range(page*gridSize,(page+1)*gridSize):
            if i < len(nameByID):
                $ pcgender = "man"
                imagebutton [...]
                $ pcgender = "woman"
                imagebutton [...]
It can't works. ConditionSwitch is evaluated in real time. So, each time you change the value of pcgender all the images changes immediately.


What you need is to have a switch in the gallery menu, to offer the possibility to choose what version will be shown :
Code:
screen g_images():
    hbox:
        text "Gender : "
        textbutton "[pcgender]":
            action ToggleVariable( "pcgender", true_value="man", false_value="woman" )

   [...]
It should let you switch between male and female version of the animation with a click. Either the player see their male version, or he see their female version.


[...] and would prefer to have the animations (images) only shown when it really was seen in the game previously.
If you mean that the player can only see the female version if he already see it, even if he saw the male version of the animation, it's not possible ; at least not with your code. But if you mean the animation whatever the gender, then your code is correct.
 
  • Like
Reactions: recreation

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
To ask an obvious question... but when are you invoking the gallery?
(from main_menu or game_menu or both?)

If you're accessing the gallery before the game starts, then the player will not have a picked a gender by that point and so of course the game will use the default. (maybe store the latest gender picked in a persistent variable in addition to the standard one and use that persistent variable as your ConditionSwitch() ?)
 
Last edited:

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,327
22,776
It can't works. ConditionSwitch is evaluated in real time. So, each time you change the value of pcgender all the images changes immediately.
Ahaaa, so it's the opposite of what I was thinking, but wouldn't that mean that in if I set it to female last that it would only show female images? Because that's what I did and it showed male images :unsure:
What you need is to have a switch in the gallery menu, to offer the possibility to choose what version will be shown :
That's exactly what I don't want, I want either both (if seen), or only the last one played. I do have the gender variable in a persistent since I use them in the scenes gallery already, which has a gender choice, but there it's no problem since I have a lot of images to chose from as preview image (I can use images where the mc isn't visible, so the gender is only important when he already clicked on the image).
Note: it's the first day of lockdown chapter 2 here, and more than 1 hour that my upstairs neighbors decided to drill holes in all the walls of his flat.
Yikes, you have my sympathy.

To ask an obvious question... but when are you invoking the gallery?
(from main_menu or game_menu or both?)

If you're accessing the gallery before the game starts, then the player will not have a picked a gender by that point and so of course the game will use the default. (maybe store the latest gender picked in a persistent variable in addition to the standard one and use that persistent variable as your ConditionSwitch() ?)
Yes, it's only accessible from the main menu, so I guess the last played gender is the only option, huh? :(
It's a shame, I actually have both genders saved in a variable if both have been played.

Thanks you both.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
Your other option would be to make the gallery available from the game_menu rather than the main_menu and only AFTER the player has selected a gender and continue to use the player's selected gender for the current playthrough.

That way, either the player will have picked a gender or be loading a saved game with a gender already selected.

The only other variation I can think of would be to hold a persistent array of genders per unlockable gallery image. Instead of storing a single gender variable for the whole game, store a persistent array (probably a ) of image names and the gender that was being played when that image was (first/last) unlocked (using the image name as the key and the gender as the data). It would at least get around the issue of using renpy.seen_image() which could unlock different images during different playthroughs using different genders. That would be difficult to implement though, since your game has already been played A LOT by players.
 
  • Like
Reactions: recreation

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,327
22,776
Your other option would be to make the gallery available from the game_menu rather than the main_menu and only AFTER the player has selected a gender and continue to use the player's selected gender for the current playthrough.

That way, either the player will have picked a gender or be loading a saved game with a gender already selected.

The only other variation I can think of would be to hold a persistent array of genders per unlockable gallery image. Instead of storing a single gender variable for the whole game, store a persistent array (probably a ) of image names and the gender that was being played when that image was (first/last) unlocked (using the image name as the key and the gender as the data). It would at least get around the issue of using renpy.seen_image() which could unlock different images during different playthroughs using different genders. That would be difficult to implement though, since your game has already been played A LOT by players.
That would be a bit much, I agree. Interesting idea nonetheless.
I guess I'll go with the last played gender. That seems to be the less painfull idea and will probably safe my sanity and people from yelling at me because "the gallery doesn't work anymore" xD
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,964
16,209
Ahaaa, so it's the opposite of what I was thinking, but wouldn't that mean that in if I set it to female last that it would only show female images? Because that's what I did and it showed male images :unsure:
It's Ren'py, sometimes you need to sacrifice a virgin and you don't know why.


That's exactly what I don't want, I want either both (if seen), or only the last one played.
Well, you've both since it's a switch directly on the gallery screen, but I understand.
This said, the "if seen" will not works. Since your images use a ConditionSwitch, renpy.seen_image will return True once the player will see one of the two images. And this ConditionSwitch is also what make impossible to see both in the same time ; the two versions exist in parallel, there you can't make them appear in serial on the gallery.

The only thing possible is to have the last played gender by following what 79flavors said.
 
  • Like
Reactions: recreation

Madmanator99

Member
May 1, 2018
225
466
I don't know much about renpy, but when I hear "have seen or not", maybe check if the variable's value, after you watched the animation, is set correctly for each gender? If the gallery uses the default value, maybe it's because the variable you check is not updated during the gameplay? Just use the console to check the value. Again I may sound like an idiot, but hey, this is how I troubleshoot my variables problems.

Also 79flavors and anne O'nymous are way better than me.
 
Last edited:

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,327
22,776
I just don't use the animations anymore in the image gallery, too many problems, it's easier to just use images.
I have an additional scenes gallery anyway, so not a big loss.