[SOLVED] Unwanted screen appearing when rolling back. How to exclude things from rollback?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
zombiehead
Newbie
Posts: 10
Joined: Sun Jul 26, 2020 8:45 am
Contact:

[SOLVED] Unwanted screen appearing when rolling back. How to exclude things from rollback?

#1 Post by zombiehead »

I have a screen that displays a notification of an in game 'text message' that then hides itself after 2 seconds using a timer. It works great until you bring rollback into the mix.

If i'm in the kitchen for example and I get a text message, the notification pops up and in 2 seconds will hide itself. If i move out of the kitchen (BEFORE the 2 seconds have passed) and into the living room, the notification will still hide itself as intended when the timer is up but the problem occurs when I move to a third room and then roll back to the second room. Upon rolling back, the screen is shown again and gets stuck there.

I'm not sure how rollback works in detail but i'm assuming it's remembering that the screen was being shown when we were last in the living room so it displays it but the issue is the code triggering the notification was in the kitchen so the timer never fires so the notification never dissapears? I dont really know.

I tried to show it as best I could below. Numbered to try and make it easier to follow.

Pseudo code:

Code: Select all

screen notification:
	#Display notification here
	timer 2.0 action Hide("notification")

label Kitchen:
	imagebutton jump Living_Room #takes you to the living room. I know these should be in a screen etc but this is just an example 
	
	show screen notification
		
	# 1. notification is displayed
	# 2. Imagebutton is used to move to the living_room label
	
label Living_Room:
	imagebutton jump Kitchen #takes you to the kitchen
	imagebutton jump Bathroom #takes you to the bathroom
	
	# 3. Entered living room while the notification is on screen.
	# 4. Notification hides as expected. Imagebutton is used to enter the bathroom label 
	-----------------------------------------------------------------------------------------------------
	# 6. Back in the living room after roll back and the notification is back on the screen and is now stuck there. 
	     The timer in the screen doesnt seem to fire and even if i jump to another label it's still stuck on screen, 
	     at least until i go back to the kitchen where the code to show the screen is fired again, which resets it.
             
label Bathroom:
	imagebutton jump Living_Room #takes you to the living room
	
	# 5. Now in the bathroom. Perform rollback, using mousewheel, to go back one step to the living room
	
Sorry if this isn't all that clear.

So how do i stop it from being shown again when rollingback? or can i exclude this screen from rollback? I'm a bit stumped.

Thanks in advance
Last edited by zombiehead on Sun Aug 09, 2020 5:41 am, edited 1 time in total.

User avatar
dGameBoy101b
Regular
Posts: 31
Joined: Sun Aug 12, 2018 8:32 am
itch: dgameboy101b
Contact:

Re: Unwanted screen appearing when rolling back. How to exclude things from rollback?

#2 Post by dGameBoy101b »

You can suspend the rollback using renpy.suspend_rollback. This would probably work best if you put these around the statement that shows the notification screen.
https://www.renpy.org/doc/html/save_loa ... d_rollback

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Unwanted screen appearing when rolling back. How to exclude things from rollback?

#3 Post by Alex »

zombiehead wrote: Tue Jul 28, 2020 1:28 pm ...Upon rolling back, the screen is shown again and gets stuck there. ...
Just a thoughts:
- wait 2 seconds to see if the notification screen will hide,
- try to add 'repeat True' parameter for the timer.

User avatar
zombiehead
Newbie
Posts: 10
Joined: Sun Jul 26, 2020 8:45 am
Contact:

Re: Unwanted screen appearing when rolling back. How to exclude things from rollback?

#4 Post by zombiehead »

Been a bit so I dont remember fully but i think i fixed this by basically checking whether the screen is currently being shown AND if we're currently in rollback, if that's true then hide the screen.

Code: Select all

if renpy.get_screen("phone_notification") and renpy.in_rollback():
	hide screen phone_notification
Probably a bit of a hack rather than a clean fix but it works haha.

Thanks for the replies though.

Post Reply

Who is online

Users browsing this forum: Sugar_and_rice