Ren'Py Detecting if the label has been seen in the current playthrough

lawfullame

Active Member
Game Developer
Aug 6, 2019
669
986
Of course, when a game is to remember user choices, the most natural way is to record these choices using variables.
But if it happened to me that I forgot to record one players choice in one update, is it possible to detect if the label associated with that choice was launched in the current playthrough?
I know there is a renpy.seen_label (label) function, that does something similar through all the passages through the game.
I would need an equivalent or workaround for a single playthrough to ensure compatibility of the old saves with the new update.
 

TCMS

Quote my posts if you want an answer
Donor
Former Staff
Aug 5, 2016
5,797
30,902
I know there is a renpy.seen_label (label) function, that does something similar through all the passages through the game.
I would need an equivalent or workaround for a single playthrough to ensure compatibility of the old saves with the new update.
Couldn't you just delete the data before doing said playthrough and then check if the label was seen afterwards?
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
You can load that function right after the player loads his save file using the "afer_load" label:
Python:
label after_load:
    if renpy.seen_label("put_your_label_here"):
        $ your_variable = True
 

scrumbles

Well-Known Member
Jan 12, 2019
1,069
1,096
If it is not too late*, when the save is loaded you can inspect the _history_list variable and see if it includes a specific line of passage "A" or "B".

* the game history is limited to the last (config.history_length) entries
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
I saw this exact same thing asked a while ago on the RenPy official forums.


The answer appears to be "no". Though as scrumbles has pointed out... you might be able to search through the active game history - at least in a semi limited way. (I've no clue how that works).

There is an undocumented "feature" of label in renpy.game.seen_session... but that is only for the current play session. Exiting the game resets the list - so probably isn't suited for what you are trying to do.

But yeah... renpy.seen_label() is only helpful if the player has played the game through once. But since this is an "ever seen" type check... multiple play-throughs will mean you can't rely "why", even if the answer returns True. (Though returning False is still a valid check).

When I was looking at this same thing, I ended up just using label after_load: and setting a value consistent with "my" view of what most players would have picked. It's not perfect... but it's better than 50/50 and also better than nothing.

Also be careful to set the value to False just before the code where you set it to True. Having a default variable = False isn't enough here - since label after_load: is run after the players loads any save file.
You could inadvertently set the value to True, long before another player reaches that section of code.

You could go so far as to only set the value based on other choices the player has made (ie. if they didn't kiss Natalie in ch4, they probably didn't kiss her in ch3 either). Depends on the logic I guess.
 

lawfullame

Active Member
Game Developer
Aug 6, 2019
669
986
Couldn't you just delete the data before doing said playthrough and then check if the label was seen afterwards?
It won't help. I'm talking about a situation where a player loads an old save. I assume that this procedure would erase the data even from current playthrough, and the result would always be 'False'.

_history_list seems like the only option, but only if that decision is within history_length.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
It depend if you were cautious or not.

Like said by 79flavors , there's no native way to have this information ; What is accurate disappear at the end of the session, and what persist isn't accurate.

But it doesn't mean that there's no way at all to have this information.
The callback can easily build for you the list of all the labels passed by the player. But for this to be useful, it need to be implemented before you need to use it.
There's an example of code for it in the Variable compatibility How-to.