Ren'Py Renpy Load and Save issue

BigBoy Projects

Newbie
Game Developer
Sep 23, 2021
44
140
Hello fellow devs,

I'm here to request your advice on a problem of mine.
I'm a beginner game dev in renpy but I managed to understand this coding language.
I made a game: ( https://f95zone.to/threads/back-again-v0-6-bigboy-projects.191460/ )

The problem I have encountered is with the new update I was working on, the save and load function got crapped.
Basically when I complete the quests I made into a game and save it, the load that save file, the game loads back to the beginning of the new quest.

I can tell you that now mechanincal change has happened with the load or save function.
I just added the new content and the related variables and mechanincs.

And one of the biggest problem is that when the game loads back to the wrong place, there is no output of it, like no error or anything.
I have no clue what could go wrong so that's why I need your help.

Is there anyone out there who's willing to help or to share their experience if experienced such?

Thanks a lot.
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
5,133
7,531
You fucked up by doing something as complex as quests (that require classes) on a published project on your first time when you don't understand how coding works (At least on Ren'Py).
Without being able to look at your project, Save/Load fails like that when you define your variables wrongly (They should be on a .rpy file, outside of any label), default. Define is only for constants.
Also, when playing within a screen, the flow of the game is interrupted (When you call the screen rather than show), so saving won't work while the flow of the game is interrupted.

Could be either one of those things, or something else entirely. Either way, you should have started with something much easier imho.
 

BigBoy Projects

Newbie
Game Developer
Sep 23, 2021
44
140
Shit, that's great.
I'll take note of what you said, but it's intersting that the game was just fine only to this day. :/
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
5,133
7,531
Shit, that's great.
I'll take note of what you said, but it's intersting that the game was just fine only to this day. :/
Revert back to the previous update, and compare the two builds so you can exclude each element until you find the culprit.
If you don't have your previous update, then it's a reminder that you should either learn how to use github or at least keep a local copy of your project on an external hdd. It's especially important when doing anything code-related, but in general if you have a project, you want to have multiple copies in case something goes wrong.
 
  • Like
Reactions: BigBoy Projects

BigBoy Projects

Newbie
Game Developer
Sep 23, 2021
44
140
Thanks for you assistance. Lucky I have backups, also I will look into your game(only if you don't mind) how you build cuz the classes are something new to me. :)
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
5,133
7,531
Thanks for you assistance. Lucky I have backups, also I will look into your game(only if you don't mind) how you build cuz the classes are something new to me. :)
My game doesn't have classes, but if you google, you can find many useful tutorials that explain it:
Still, nothing you should practice on an ongoing published project imho.
 
  • Like
Reactions: BigBoy Projects

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,591
2,238
The link in your original post (v0.6) ... is that the latest "public" release?
... that is... it worked okay?

And your current development version is somehow having save issues? (that previously worked fine?)

If you could temporarily build the development version of the game as it is now and upload it somewhere. Then also upload some of the save files that no longer work how you hope - we might be able to tell you what the actual problem was.

RenPy does something called pickling when writing a save file. Each variable (or maybe the whole store area) is pickled, then saved. I've no clue what pickling is, except that not all data can be pickled. Standard variables... no problem. The more complicated (classes) the larger the chance it'll not work.

All that said, I don't think that is it.

My first guess:
Have you deleted some files in your RenPy folder recently? Or copied back part of your project from a backup?
RenPy gets into severe problems if you delete your game's .rpyc files. New saves work, old saves often don't. If the consequences are already clear... NEVER ever delete .rpyc files.

My second guess:
Have you recently changed the structure of your classes (maybe added a new property?) or changed a default statement to a define (or visa versa). That can mess with save files, but figuring out what takes some digging.

As Winterfire says, it could also be a screens issue. RenPy's internal processes only run when it gets to a pure RenPy command. Being within a screen with lots of action SetVariable() (for example) or similar actions can mean a lot of things happen without RenPy being able to do it's background processes. Especially if you then hit <Escape> and RenPy saves it's latest copy of all the variables (that still haven't been updated outside the screen space).

These are all just guesses though. If we can try it, see what you are seeing - we might be able to offer better suggestions.
 

Deveroni

New Member
Jul 24, 2024
4
0
As mentioned, Renpy does something called pickling where it tries to save the game state into a file that can be loaded later.
This works most of the time but there is a very high chance that it will break if you change the internal classes or variables.
If you are publishing versions of the game online, expect the saves to break between every version.

If you want to maintain save compatibility, then depending on what your game is like it may be easier to write your own saving/loading code. This would be less granular than the Renpy default but since you control the loading you can prevent it from breaking. For example, if your game has a number of chapters + a few choice trackers, save the chapter-number & key choices as a plain text file (optionally with a .sav extension to hide it from players) and then just manually jump the game to the right point when loading said file.

(On the topic of pickling, loading / unpickling a file is unsafe. It's possible to create a renpy save file that executes arbitrary code when loaded. I'd caution against loading any saves that other people send you.)
 

peterppp

Active Member
Mar 5, 2020
632
1,044
ffs dude, before you do anything else, clean your patreon page. now. you're asking to get banned. read up on patreon's guidelines. you're not even allowed to show nudity for cartoons and you show real porn nudity. oh my. get rid of anything looking like real porn at once
 
  • Like
Reactions: BigBoy Projects

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,561
15,520
And one of the biggest problem is that when the game loads back to the wrong place, there is no output of it, like no error or anything.
Well, it's really simple: If the save file is loaded and there's no output, it mean that there's no error, period.

Really, it's not more complicated than this.



Also, when playing within a screen, the flow of the game is interrupted (When you call the screen rather than show), so saving won't work while the flow of the game is interrupted.
Accordingly to the previous quote, my guess goes for that cause.

There's only two possibilities for Ren'Py to load at the "wrong place":

1) The label where the save happened have been heavily changed, and Ren'Py fallback at the starts of the label

2) Ren'Py load at the right place, but it don't looks like it because a big part of the content is happen in a screen that never [icore]Return[/icode]. Then, like you said, it interrupt the flow of the game.For Ren'Py you're still at the place where the screen have been called, this until the game will return from that screen.
 
  • Red Heart
Reactions: BigBoy Projects

BigBoy Projects

Newbie
Game Developer
Sep 23, 2021
44
140
Hi All,

Thanks for everyone's suggestion.
I managed to solve the issue.
The problem was that I built a:

Function(renpy.call_in_new_context, "xxx")

this caused the mess that I could not save or load the game properly.
Still don't know how but luckily managed to solve the incident.
ffs dude, before you do anything else, clean your patreon page. now. you're asking to get banned. read up on patreon's guidelines. you're not even allowed to show nudity for cartoons and you show real porn nudity. oh my. get rid of anything looking like real porn at once
Thank's for the heads up. Cheers mate.
 
  • Like
Reactions: peterppp