Using Multi-game persistent data
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.
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.
- octacon100
- Regular
- Posts: 163
- Joined: Thu Sep 12, 2013 11:23 pm
- Projects: Regeria Hope
- Organization: Golden Game Barn
- IRC Nick: Octacon100
- Location: Boston, MA
- Contact:
Using Multi-game persistent data
Hi all,
With Regeria Hope, I'm hoping to have choices in the first episode affect future episodes. With that in mind, I was thinking about using the MultiPersistant class. I'm guessing I could have users choose from three slots to save their multi-persistent data, then have the game know to use that slot when saving and loading multi-persistant data. I'd like to know if anyone out there has any experience with multi-persistant data, and possible pitfalls of using it.
I guess the other way I could get this to work is to include extra episodes in updates to the base episode, but then there's in game stores and extra bits to make. I'm thinking that the mult-persistant data within different game packages is the easier and less intrusive way to go, but any feedback would be very appreciated.
Thanks!
With Regeria Hope, I'm hoping to have choices in the first episode affect future episodes. With that in mind, I was thinking about using the MultiPersistant class. I'm guessing I could have users choose from three slots to save their multi-persistent data, then have the game know to use that slot when saving and loading multi-persistant data. I'd like to know if anyone out there has any experience with multi-persistant data, and possible pitfalls of using it.
I guess the other way I could get this to work is to include extra episodes in updates to the base episode, but then there's in game stores and extra bits to make. I'm thinking that the mult-persistant data within different game packages is the easier and less intrusive way to go, but any feedback would be very appreciated.
Thanks!
- mjshi
- Regular
- Posts: 179
- Joined: Wed Mar 13, 2013 9:55 pm
- Completed: MazeSite01, Ponderings of Time
- Contact:
Re: Using Multi-game persistent data
You could solve this with normal persistent variables-
In options.rpy, set the
folder names to be equal. For example, if I made a Traditional Adventures in Scarftown 2, and set the save directory to the same directory as the first one, it would use the same save directory and the same persistent variables.
One small flaw to this system is that save files from the first game will also appear in the second.
However, loading a first game save file in the second game won't do anything and is equivalent to pressing the start button on the second game. Normal variables from the first game will not carry over to the second game when loading a first game save file.
It's more of a "eh, it looks kind of bad" complaint than anything. If it bothers you a lot and you feel that players might load the wrong file-
1) they could always right click then reload the correct file
2) you could always attach a "Episode 1" text next to everything saved in the first episode and an "Episode 2" text next to anything saved in the second episode.
Otherwise, good luck with the game, and I'll look up the MultiPersistent thing.
In options.rpy, set the
Code: Select all
config.save_directory = "Traditional Adventures in Scarftown-1420660909"One small flaw to this system is that save files from the first game will also appear in the second.
However, loading a first game save file in the second game won't do anything and is equivalent to pressing the start button on the second game. Normal variables from the first game will not carry over to the second game when loading a first game save file.
It's more of a "eh, it looks kind of bad" complaint than anything. If it bothers you a lot and you feel that players might load the wrong file-
1) they could always right click then reload the correct file
2) you could always attach a "Episode 1" text next to everything saved in the first episode and an "Episode 2" text next to anything saved in the second episode.
Otherwise, good luck with the game, and I'll look up the MultiPersistent thing.
- mjshi
- Regular
- Posts: 179
- Joined: Wed Mar 13, 2013 9:55 pm
- Completed: MazeSite01, Ponderings of Time
- Contact:
Re: Using Multi-game persistent data
Okay, got back to this.
Read up on this: http://www.renpy.org/doc/html/persisten ... Persistent
I'll break it down now--
Of course, you could still use "init" and put a $ in front of the mp and it would still work. The demo.renpy.org in the "" is basically what Ren'Py will try to look for between games, so if Bob made a game that used multipersistents and Alice made a game that used multipersistents, and their "" weren't exactly the same thing, their multipersistent variables wouldn't mash together and create some kind of horrid multipersistent Alice-Bob monster. The multipersistent doesn't need to be named mp, and the "" doesn't need fancy periods or other stuff, just make it unique enough so that games won't clash.
The almighty period basically says, "Okay so here's this big variable mp, which is a category, and under it are tiny little variables, which are like sub... sub-things, I guess." Official programming language call it parent/child, I believe. So beat_part_1 is defined as a variable under the multipersistent category mp.
The $ mp.save() is self-explanatory.
Second part!
mp is defined again so that RenPy can link the two games. Make sure this is the same thing.
Checking to see if the earlier mp variable exists, then proceeding with the dialogue depending on the answer.
I don't quite understand what you mean by "I'm guessing I could have users choose from three slots to save their multi-persistent data, then have the game know to use that slot when saving and loading multi-persistant data." The data automatically loads, the player won't even know that it's being loaded. I don't think there's any such thing as slots, although you could do that if you really wanted to (such as something like--
Then when loading--
By all means I am no expert, but feel free to ask/wait for others to reply while I go petition for a "Spoiler" button to hide excessively long blocks of code.
Read up on this: http://www.renpy.org/doc/html/persisten ... Persistent
I'll break it down now--
Code: Select all
init python:
mp = MultiPersistent("demo.renpy.org")Code: Select all
$ mp.beat_part_1 = True
$ mp.save()
e "You beat part 1. See you in part 2!"The $ mp.save() is self-explanatory.
Second part!
Code: Select all
init python:
mp = MultiPersistent("demo.renpy.org")Code: Select all
label start:
if mp.beat_part_1:
e "I see you've beaten part 1, so welcome back!"
else:
e "Hmm, you haven't played part 1, why not try it first?"I don't quite understand what you mean by "I'm guessing I could have users choose from three slots to save their multi-persistent data, then have the game know to use that slot when saving and loading multi-persistant data." The data automatically loads, the player won't even know that it's being loaded. I don't think there's any such thing as slots, although you could do that if you really wanted to (such as something like--
Code: Select all
init python:
mp = MultiPersistent("demo.renpy.org")
mp1 = MultiPersistent("demo1.renpy.org")
mp2 = MultiPersistent("demo2.renpy.org")
init:
$ tempmp = None
label start:
# game stuff happens
$ tempmp.failedtest = True
# more game stuff happens
$ tempmp.dogdied = True
# more game stuff
$ tempmp.carcrash = False
# end of game, time to ask user to save stuff
menu:
"Which slot would you like to save your persistent variables?"
"Slot 1":
$ mp.failedtest = tempmp.failedtest
$ mp.dogdied = tempmp.dogdied
$ mp.carcrash = tempmp.carcrash
"Slot 2":
$ mp1.failedtest = tempmp.failedtest
$ mp1.dogdied = tempmp.dogdied
$ mp1.carcrash = tempmp.carcrash
"Slot 3":
$ mp2.failedtest = tempmp.failedtest
$ mp2.dogdied = tempmp.dogdied
$ mp2.carcrash = tempmp.carcrash
return
Code: Select all
init:
$ mp = None
label start:
menu:
"Load game data"
"Slot 1":
$ mp = MultiPersistent("demo.renpy.org")
"Slot 2":
$ mp = MultiPersistent("demo1.renpy.org")
"Slot 3":
$ mp = MultiPersistent("demo2.renpy.org")
- octacon100
- Regular
- Posts: 163
- Joined: Thu Sep 12, 2013 11:23 pm
- Projects: Regeria Hope
- Organization: Golden Game Barn
- IRC Nick: Octacon100
- Location: Boston, MA
- Contact:
Re: Using Multi-game persistent data
Hi mjshi, thanks very much for looking into it!
Yeah, that's exactly what I was thinking! Does that seem doable? I'm trying to figure out if that is a good way to do it or not. Having the variables be set at the end makes some sense as well, that way it's easy to see how it transfers. Will probably have to tie a save game screen in there as well. I figure that 3-5 save slots should probably be enough for people, so hopefully that makes sense.
I also like the idea of using the same folder as well. Maybe I could filter out how the save games are picked up, like a filter on the name of a save or something. That way I could have the save game include a "ep1ep2" when finished, or a "ep1" when it's still happening. I'll have to look into it in more detail, but the multi persistent class was my first start.
There's a few options out there, so I was hoping someone that has done it before would have some feedback.
Yeah, that's exactly what I was thinking! Does that seem doable? I'm trying to figure out if that is a good way to do it or not. Having the variables be set at the end makes some sense as well, that way it's easy to see how it transfers. Will probably have to tie a save game screen in there as well. I figure that 3-5 save slots should probably be enough for people, so hopefully that makes sense.
I also like the idea of using the same folder as well. Maybe I could filter out how the save games are picked up, like a filter on the name of a save or something. That way I could have the save game include a "ep1ep2" when finished, or a "ep1" when it's still happening. I'll have to look into it in more detail, but the multi persistent class was my first start.
There's a few options out there, so I was hoping someone that has done it before would have some feedback.
- mjshi
- Regular
- Posts: 179
- Joined: Wed Mar 13, 2013 9:55 pm
- Completed: MazeSite01, Ponderings of Time
- Contact:
Re: Using Multi-game persistent data
Definitely doable, if you don't mind the saves appearing or have some way to suppress the saves(I'll need to look into that, but you seem to already have an idea, so I'll leave you be and let the more experienced coders look at it ^^), the first one is your best choice as it's a lot less hassle/remembering to use the different classes, but if you absolutely hate the fact that the save file is visible and can't find a way to hide it,, go with the MultiPersistent classes.
Who is online
Users browsing this forum: No registered users

