Ren'Py Struggling with my gallery replay system

Gwedelino

Well-Known Member
Game Developer
Sep 4, 2017
1,024
2,084
Hello Everybody.

I'm currently working on a Ren'py game project and for the very first time, I'm completely stuck. None of my attempts has allowed me the slightest progress.
I already requested some help on the discord (even on reddit), but I hope I could get more opinions here.

SUMMARY :

I'm creating a visual novel which will have several paths. As I want to reward players who make the right decisions and don't want them to force a Game over, I want to create a gallery system that unlock every available cutscene when players complete the "GOOD PATH" while they will only unlock the cutscene of the path they are on if they took a "BAD PATH".

Here is an example of the code I use for my replay gallery system. Consider that "DEFEATAGAINSTBOSS" is the bad path while "VICTORYAGAINSTBOSS" is the good path.

Python:
screen Replay:
        tag menu
        use replay_menu (_("Replay Scenes"))

        if persistent.defeatagainstboss:
            imagebutton:
                xalign 0.31
                yalign 0.80
                idle "Scenes/thumbnail/unlockedthumbnail2.webp"
                action Replay("defeatagainstboss")

        else:
            imagebutton:
                xalign 0.31
                yalign 0.80
                idle "Scenes/thumbnail/lockedthumbnail1.webp"
                action NullAction()

        if persistent.victoryagainstboss:
            imagebutton:
                xalign 0.62
                yalign 0.80
                idle "Scenes/thumbnail/unlockedthumbnail2.webp"
                action Replay("victoryagainstboss")

        else:
            imagebutton:
                xalign 0.62
                yalign 0.80
                idle "Scenes/thumbnail/lockedthumbnail2.webp"
                action NullAction()
So, in order to make it work, I have to set flags in the script of my game. I will use 1 flag for each path.

Python:
default persistent.victoryagainstboss = False
default persistent.defeatagainstboss = False
And I will "activate" those flags at the right timing". I will only activate the "BAD PATH" flag when reaching the defeat scene, and I will activate both the "GOOD PATH" and "BAD PATH" flag on the victory scene.

Python:
label defeatagainstboss :

    $ persistent.defeatagainstboss = True
    if _in_replay:
        show screen Replayexit

label victoryagainstboss :

    $ persistent.victoryagainstboss = True
    $ persistent.defeatagainstboss = True
    if _in_replay:
        show screen Replayexit

Problem being that this doesn't work. If I reach the "defeatagainstboss" scene while playing, I rightfully unlock the bad ending cutscene. However, if I reach the "victoryagainstboss" scene, then I only unlock the good ending cutscene.

It's especially confusing since :

- Using the dev console show me that the defeatagainstboss flag has been rightfully triggered on the "GOOD PATH"

- The replay gallery show me the unlockedthumbnail picture, like if I unlocked the bad ending scene. However when I click on the imagebutton it doesn't trigger anything and the replay doesn't start.

I would like to get your opinion on it.

Thanks for your help.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,302
15,172
- The replay gallery show me the unlockedthumbnail picture, like if I unlocked the bad ending scene. However when I click on the imagebutton it doesn't trigger anything and the replay doesn't start.
Well, since everything works as expected, except the imagebutton's action property, it is where the error is, whatever it can be. Or, at worse, the error come from the label you try to replay, but you should at least have something, even if it's an error screen.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,576
2,204
It really depends on how you want your gallery to behave.

If you want the "endings" to be mutually exclusive (being defeated by the boss unlocks one gallery, but locks the other), then you want...

Python:
$ persistent.defeatagainstboss = True
$ persistent.victoryagainstboss = False

-or-

$ persistent.defeatagainstboss = False
$ persistent.victoryagainstboss = True

Achieving one, negates the other.

However, if you'd rather both endings be available (perhaps by doing multiple play-throughs)... then you want...

Python:
$ persistent.defeatagainstboss = True

-or-

$ persistent.victoryagainstboss = True

Basically, depending on the outcome, you either want to set ONE to True or set BOTH to True/False.

Right now, you've got a bit of a mix of both solutions... so I'm not surprised it's behaving in a way that isn't quite right.

IMO... Galleries using persistent variables are intended to allow the player to unlock both endings eventually. You've got 2 scenes... but imagine 20, where multiple play-throughs are required to finally unlock all of them. Just my opinion of course... your game... your choice.
 

Gwedelino

Well-Known Member
Game Developer
Sep 4, 2017
1,024
2,084
Not sure you got it 79flavors . I guess bringing some illustrations would help.

Here is a little plan that explain what I want to achieve through my gallery replay system.
It's a visual representation of my VN. Left is the beginning of the game, right the end. Each square is a different scene.
The four first scenes are linear without any choice, however, at the end of the 4th scene, the player get to choose a path between 3 different options.
Plan VN.jpg
So basically, I want to build my gallery to let players that make the right choice unlock everything in 1 playthrough, so they don't need to trigger game over to get game over cutscenes.

anne O'nymous

I don't have any error screen. I don't get why :

Python:
label defeatagainstboss :

    $ persistent.defeatagainstboss = True
    if _in_replay:
        show screen Replayexit
works, but :
Python:
label victoryagainstboss :

    $ persistent.victoryagainstboss = True
    $ persistent.defeatagainstboss = True
    if _in_replay:
        show screen Replayexit
doesn't.

They both set persistent.defeatagainstboss to True ( I checked both with a "print" command)
They both switch the locked thumbnail picture with the unlocked thumbnail picture.
But when clicking on the imagebutton, only 1 on them start the replay.

However I noticed one thing :

- This problem happens when the $ persistent."variable" = True command is not located within the label of the scene it's supposed to trigger the replay with 1 exception for the Path 1 and 3 if the $ persistent."variable" = True is located in the "Game over" label.

Which means the imagebutton for Path 1 and 3 only work if $ persistent."variable" = True is within Path 1 and 3 or within the "Game over" scene.

This is so absurd...
 

gojira667

Member
Sep 9, 2019
264
245
They both switch the locked thumbnail picture with the unlocked thumbnail picture.
But when clicking on the imagebutton, only 1 on them start the replay.
Sounds like the default value locked=None behavior of the . When locked=None only seen labels are unlocked. Assuming you are using a fresh persistent for each test.

In which case you can set an additional persistent var on the Good ending and pass that for the locked kwarg. E.G.
Code:
label victoryagainstboss :

    $ persistent.victoryagainstboss = True
    $ persistent.defeatagainstboss = True
    $ persistent.gvaab = False
    if _in_replay:
        show screen Replayexit
Code:
screen Replay:
        tag menu
        use replay_menu (_("Replay Scenes"))

        if persistent.defeatagainstboss:
            imagebutton:
                xalign 0.31
                yalign 0.80
                idle "Scenes/thumbnail/unlockedthumbnail2.webp"
                action Replay("defeatagainstboss",locked=persistent.vaab)
Untested and never actually used the locked kwarg before...
 
  • Like
Reactions: osanaiko

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,302
15,172
They both set persistent.defeatagainstboss to True ( I checked both with a "print" command)
They both switch the locked thumbnail picture with the unlocked thumbnail picture.
But when clicking on the imagebutton, only 1 on them start the replay.
Then, as I said, the error lie in the imagebutton action property...


Which means the imagebutton for Path 1 and 3 only work if $ persistent."variable" = True is within Path 1 and 3 or within the "Game over" scene.

This is so absurd...
It's not absurd. As said by the documentation for the screen action, it's how it is supposed to works:
Replay(label, scope={}, locked=None)
[...]
locked
If true, this replay is locked. If false, it is unlocked. If None, the replay is locked if the label has not been seen in any playthrough.
So, I guess that you haven't played the "defeatagainstboss" label, reason why it don't works during your test.
In the end, as I said twice, the problem lie in the action property, that should be action replay( "defeatagainstboss", locked=False ).