Rollback Toggle?

Omniwang

Newbie
Sep 18, 2017
29
39
Hey, new thing I want help coding. Without turning this into a pitch for my game, I have a design feature tied to the plot where time travel is a game mechanic. And I want to have a code to TOGGLE rollback in Renpy. Sort of if you have a magic feather, you can rollback the game but if you don't, the game only can move forward as normal. I see plenty of examples on how to disable for the entire game or to put a block after a decision. But can anyone help with this?

(No, there is no magic feather. I just want to disable "time travel" during the intro and then maybe take it away if necessary.)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
There's two way to do this. The first one is of Ren'py. The second one is to make the labels . In both case you'll probably need to have a generic "itsATimeTravel" flag to handle some things inside the code.
 

Omniwang

Newbie
Sep 18, 2017
29
39
I think that would just let me return to specific moments, which is useful, but I want to be able to deal with players reaching a bad decision and undoing it by stepping back a few pages. Is that part of Replay, because as I read it, Replay just lets them see an instance of a past event that can't change.
 

JohnDupont

Active Member
Modder
May 26, 2017
838
2,810
I think you want to use .
But you might need to change the value of too.

I can think of 2 solutions, but I don't know if they work:
1) Calling a label
Code:
label RollbackToggle:
    if config.rollback_enabled:
        $ config.rollback_enabled = False
    else:
        $ config.rollback_enabled = True
2) Using
Code:
ToggleField(config, "rollback_enabled",  true_value=True, false_value=False)
 

Omniwang

Newbie
Sep 18, 2017
29
39
"$ config.rollback_enabled = False"
and
"$ config.rollback_enabled = True"

are the codes I'm working with and they don't work this way. The false overrides the true every time and the toggle doesn't change anything. I've also tried having rollback values set to 120 and then to 0, but it only registers the 120.
 
  • Like
Reactions: nikto

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
The false overrides the true every time and the toggle doesn't change anything.
Anyway it's useless unless you remove the "back" option of the quick menu. Unlike the rollback generated by the PageUp key (and other), it don't care of the value assigned to config.rollback_enabled.

This said, there's a lot of , but none really suit what you want to do. And the only solutions I see are really too messy to be used in a game by someone who didn't discovered them by himself or have a solid background in coding ; too many possible side effects.
 

Omniwang

Newbie
Sep 18, 2017
29
39
I've had two ideas. In the areas where I don't want rollback, block rollback in every line as necessary.

Change the plot to disable rollback in an entire episode and enable it in the second episode and transfer data between the two through saves. What do you think? As elegant a solution as I can accomplish unless I hire someone to recode things later.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
What do you think?
You want an honest answer ? I think that the whole idea is bad from the start.
Rollback is a loved feature of Ren'py, and many people will just overpass your "you can't rollback unless you have the feather" thing. This just to be sure they can rollback when they want, even if in the end they don't do it.
Look at UnRen.bat. One of the tweak it do is preventing the blocking of rollback. Because people are like that, if there's a amazing feature which ease the way they play, they want to have it, whatever the author of the game want.
 
  • Like
Reactions: Omniwang

Omniwang

Newbie
Sep 18, 2017
29
39
Yeah, and I agree. I still want it for narrative reasons but maybe instead of whitewashing the entire thing to be less accessible I should go the other way. Instead of blocking at all times, only block when it's funny. Like you can roll back decisions whenever you want but there's moments where you can't rollback because "A powerful force is preventing me from using rewind!"

And it's when you're stuck in class listening to a lecture or on a long drive through the desert.

In the end I'm frustrated at not being able to toggle this as easily as I do most everything else in Renpy but real life writes the story.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
I still want it for narrative reasons [...]
I talk in a pure conditional way here, not knowing if it can be (more or less) easily done, but to follow the narrative reasons, there's one thing you can do : Creating your own "forced rollback".
What I mean, is that once the player got the feather, a button "back in time" is added somewhere in the screen. And if the player click on it, the game automatically rollback to a previous point ; probably right before the last choice.
Hypothetically speaking, it would works like this :
  • One or two dialog lines before the player have to make a choice, you place a rollback checkpoint ;
  • If the player have the feather, right after the menu, the "back in time" button appear ;
  • If the player click on it, the game go back to the previous rollback checkpoint ;
  • If the player don't click on it, the button disappear after X dialog lines.

You can control the button appearance/disappearance with a flag used only for this purpose. To make it appear :
Code:
   $ backInTime = True
and to make it dissappear :
Code:
   $ backInTime = False
And you have this screen in overlay:
Code:
screen backInTimeButton:
    if backInTime is True and playerHaveFeather is True: 
        textbutton "Back in time":
             action Function( renpy.rollback, force=True, checkpoints=backInTime(), greedy=True )
Forcing the rollback is done with ( force=True, checkpoints=X, greedy=True ) ; as seen in the screen above.
The problem is the value for checkpoints. It change every time the player will pass an interaction, and it depend of what checkpoint should be reached. That's why there's a backInTime function to return it. This function need to compute the right number to return...

And that's where I'm stuck. It should probably be possible with a combination of and . But honestly I never looked at them, so I don't know how they works.
Or, another possibility is to not care of the checkpoints... I mean that the feather always send you back in time for "X minutes" (here obviously X interactions). So, instead of "checkpoints=backInTime()", you have "checkpoints=10", and it should send the player 10 interaction back.
 

Omniwang

Newbie
Sep 18, 2017
29
39
As cool as that sounds, you were right the first time. This is supposed to feel like a punchline and work with the story but not get in the way of the story. So I never block it for longer than 10 screens at a time and never on something you need to reverse.