Saving and restoring screen state

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
RewindTheGame
Regular
Posts: 62
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Saving and restoring screen state

#1 Post by RewindTheGame »

Hello all,

I have an issue I'm trying to resolve, but don't really know where to start on this one.

In my game, there is a button permanently displayed which displays an inventory screen. On the inventory screen, there is another button which calls (not jumps) to code which displays a virtual computer system (think DDLC). When the user logs off from this virtual computer, a RETURN is issued which takes them back to the line following the original call, so that they once again see the inventory.

The problem is this. The inventory can be activated at any time, which means that the virtual computer system writes all over whatever was on the screen. When the user closes the inventory and returns to the game, they are still looking at the graphics from the virtual computer instead of what was there before - so I need to be able to somehow save the screen state including all displayed graphics and layers before the call and restore them afterwards. How do I do this?

It's too late to implement the virtual computer as a screen, because I'd have to rewrite thousands of lines of code.

TIA,
Simon

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2406
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Saving and restoring screen state

#2 Post by Ocelot »

RewindTheGame wrote: Sat Jan 13, 2024 7:57 am It's too late to implement the virtual computer as a screen, because I'd have to rewrite thousands of lines of code.
Welcome to the reality of software development.
But if you want a qick fix, you can call you label in new context which should create a basically a new game state:
https://www.renpy.org/doc/html/label.html#contexts
< < insert Rick Cook quote here > >

RewindTheGame
Regular
Posts: 62
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Re: Saving and restoring screen state

#3 Post by RewindTheGame »

Ocelot wrote: Sat Jan 13, 2024 8:30 am
RewindTheGame wrote: Sat Jan 13, 2024 7:57 am It's too late to implement the virtual computer as a screen, because I'd have to rewrite thousands of lines of code.
Welcome to the reality of software development.
But if you want a qick fix, you can call you label in new context which should create a basically a new game state:
https://www.renpy.org/doc/html/label.html#contexts
Thank you, this works perfectly :).

Post Reply

Who is online

Users browsing this forum: No registered users