Ren'Py How to lock the back button

chickenscratchgames

Newbie
Game Developer
Jan 18, 2021
79
61
So I have been building my game and now that I have a substantial amount of dialogue I use the back button to check all the different dialogue choices. I clicked it one to many times and it jumped to a sex scene that you can only get if you did certain actions. I want to avoid that, what do I add to my code so you can’t use the back button to access content?
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
The answer to your question is to disable rollback.

Put define config.rollback_enabled = False somewhere in your code (ideally the options.rpy file).

Alternatively, you can stop RenPy rolling back beyond certain points in your code by leaving rollback on, but putting the
statement at any place you want to stop the player being able to go back through.

All that said... DON'T DO IT!

It only pisses off players and you'll spend half your time on any support forums explaining why you felt you needed to switch it off. It became a short trend a couple of years ago for developers to disable rollback to force players to live with their decisions. It did not go well and nobody benefited.

RenPy is designed to use rollback. All the important game states and variables are kept intact throughout rollbacks.
If there is something in your game that breaks when a player uses rollback... then your game is broken. You need to fix the underlying flaws rather than just dealing with the symptoms.

If I had to guess you're using or . Though I suppose it's also possible you've created a custom python class/object without referencing RevertableObject() or similar structure. If you hadn't guessed by the context... all these would be bad. Both "seen" functions work as a "seen ever". So multiple playthroughs break things, likewise rolling back. Their main use is things like galleries, where you want the player to unlock stuff with multiple playthroughs.
 

chickenscratchgames

Newbie
Game Developer
Jan 18, 2021
79
61
Thanks that did help a bit but to try an explain it better I do not mind players going back to choose different options what I am more talking about is like hitting the back button while for example in a menu will jump you to the scene right above it. Which for example is a sex scene because in the script it’s right above the menu so you can access it that way with out actually doing the requirements. I just care about locking people out from that more then anything
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
I just care about locking people out from that more then anything

Then $ renpy.block_rollback() sounds like the solution you are looking for.

[...] for example is a sex scene because in the script it’s right above the menu so you can access it that way with out actually doing the requirements.

There's something wrong here. Something we're missing. Rollback doesn't work that way. It isn't based on where code is positioned, only what code was previously executed.

So if you mean the player sees sex scene -> menu -> {rollback} -> different sex scene -> menu... that just shouldn't happen and sounds like a mistake in how you are selecting which sex scene is to be shown.

If however you mean the player sees whatever -> menu -> {rollback} -> entirely new sex scene... well, that is... I want to say impossible. Rollback just doesn't work that way. If this or something like it is happening, there's some fundamental flaw we're missing.
 
Last edited:
  • Like
Reactions: S.O.M.

S.O.M.

Member
Game Developer
Jan 30, 2021
461
1,080
You can create choices that will only appear when you perform certain actions.
For ex:
1) menu:
"Fuck her" if girllove >= 10: (player can see this option when he/she have 10 or more points)
"Leave":
2) menu:
"Fuck her" if girllove == True: (player can choose this only when girllove = True)
"Leave":

So, you don't need to disabled rollback. As 79flavors said, this feature may disappoint some players. Don't waste your time protecting your game so that players don't miss anything, don't use tricks to open the content. Anyone who needs it can always find a way to "hack" your game, imho.
 

S.O.M.

Member
Game Developer
Jan 30, 2021
461
1,080
Thanks that did help a bit but to try an explain it better I do not mind players going back to choose different options what I am more talking about is like hitting the back button while for example in a menu will jump you to the scene right above it. Which for example is a sex scene because in the script it’s right above the menu so you can access it that way with out actually doing the requirements. I just care about locking people out from that more then anything
hmm, maybe you should create a different labels.
for ex:

label a: text (when girllove false)
label b: text + sex (when girl love true)
label c: menu (after "a" and "b")

So, when player use rollback, he/she will return to the previous label on which he/she was because of points of the game.
 
Apr 24, 2020
192
257
I would honestly take an extra look at how you structure those dialogue options. It sounds like something else is wrong if a player would want to roll back and pick another option.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,360
15,270
I clicked it one to many times and it jumped to a sex scene that you can only get if you did certain actions.
The rollback just revert the game to a previous state, restoring everything in the exact state it was at this exact moment.

Let's say that you've this code :
Code:
default myVar = 0

label whatever:
   menu:
       "Choice 1":
           $ myVar += 1
           "You are happy."
       "Choice 2:"
           jump thatLabel
       "Choice 3":
           "It's raining men, Alleluia !"
    Jump somewhereElse

label thaLabel:
    $ myVar += 2
    "Be ready to encounter your faith."
You start with myVar at 0, and you test the "Choice 1". Then, myVar value will pass at 1.
But, when you rollback, and reach again the menu, myVar value will come back to 0.
And it will be the same if you test the "Choice 2". myVar walue will pass at 2, but the rollback will revert it to 0.


Therefore, if testing your different options, through the use of the rollback feature, lead you to a sex scene that you shouldn't see, it's not the rollback that is the problem, but your code.

Of course, you can disable the rollback. It will hide the problem, but it will not solve it ; it's like putting the dust under the carpet.



All that said... DON'T DO IT!

It only pisses off players and you'll spend half your time on any support forums explaining why you felt you needed to switch it off.
And meanwhile advanced players, or those who know where to ask, while just put back the rollback and play the game without carrying about his own preferences regarding it.


If I had to guess you're using or . [...] Both "seen" functions work as a "seen ever". So multiple playthroughs break things, likewise rolling back. Their main use is things like galleries, where you want the player to unlock stuff with multiple playthroughs.
Exactly. They are persistent values intended to either to handle persistent information (like galleries), or to offer the possibility to put variation in your game when someone play it more than once. They can also be used to handle a completion factor, telling the player that, by example, he'd still missed a scene.

But they carry "meta information". What mean that at no time they have to be used to handle a playthrough or as flag telling what decisions were made by the player.
 
  • Like
Reactions: S.O.M.