[Tutorial] Making a Contents page / screen

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Message
Author
User avatar
Lockvia
Regular
Posts: 124
Joined: Wed Mar 26, 2014 8:02 pm
Projects: Prank Masters
Organization: Lockvia Studios
Tumblr: lockvia
itch: lockvia
Location: Australia
Contact:

Re: [Tutorial] Making a Contents page / screen

#16 Post by Lockvia »

Would you believe I originally came up with this as a way for the player to see how far they were in the game?
Yes I would believe you. And it's also so great that you came up with this idea!
Image

User avatar
SilverSnow
Regular
Posts: 182
Joined: Tue Aug 27, 2013 6:28 am
Completed: Bus Stop, Before the Tale, White Book Complete Volume, See You, The Raven
Projects: Secrets...
Tumblr: stchematelier
itch: st-chem-atelier
Location: Edge of Black Hole
Discord: SHatsuyuki#1452
Contact:

Re: [Tutorial] Making a Contents page / screen

#17 Post by SilverSnow »

I tried applying the code and it works fine, but my only problem is, it doesn't seem to remember the unlocked parts. I tried checking again if it works as a release type but I still get the same results. :(
Image

User avatar
Broodelin
Regular
Posts: 193
Joined: Wed May 14, 2014 9:26 pm
Completed: A Harder Battle
Projects: Too many to list
Location: Eagleland
Contact:

Re: [Tutorial] Making a Contents page / screen

#18 Post by Broodelin »

SilverSnow wrote:I tried applying the code and it works fine, but my only problem is, it doesn't seem to remember the unlocked parts. I tried checking again if it works as a release type but I still get the same results. :(
Did you make your variables persistent by adding "persistent." to the beginning of their definitions?

ex:

Code: Select all

$ var1 = persistent."complete"
I'm fairly sure that's how to keep the data stored over multiple play sessions.[/s]

See PyTom's post below. ;)
Last edited by Broodelin on Wed May 21, 2014 10:07 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: [Tutorial] Making a Contents page / screen

#19 Post by PyTom »

Actually, persistent variables are fields on the persistent object. (For convenience, if fields on the persistent object are not set, they default to None.)

Code: Select all

$ persistent.complete = True
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
SilverSnow
Regular
Posts: 182
Joined: Tue Aug 27, 2013 6:28 am
Completed: Bus Stop, Before the Tale, White Book Complete Volume, See You, The Raven
Projects: Secrets...
Tumblr: stchematelier
itch: st-chem-atelier
Location: Edge of Black Hole
Discord: SHatsuyuki#1452
Contact:

Re: [Tutorial] Making a Contents page / screen

#20 Post by SilverSnow »

PyTom wrote:Actually, persistent variables are fields on the persistent object. (For convenience, if fields on the persistent object are not set, they default to None.)

Code: Select all

$ persistent.complete = True
I'm sorry but I don't think I get it... Can you please explain it again once more?
Excuse me for being so annoying heheh ^-^u
Image

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [Tutorial] Making a Contents page / screen

#21 Post by OokamiKasumi »

SilverSnow wrote:
PyTom wrote:Actually, persistent variables are fields on the persistent object. (For convenience, if fields on the persistent object are not set, they default to None.)

Code: Select all

$ persistent.complete = True 
I'm sorry but I don't think I get it... Can you please explain it again once more?
Excuse me for being so annoying hehehe ^-^u
A persistent variable is a variable that doesn't get erased or reset when the game is closed, the way other variables do. (That's why they're called persistent.)

The way to use this is when you reach a point in your game that you want to Permanently set to accessible (or not accessible,) you add persistent. to your variable. (Don't forget the dot!)

Example:

Code: Select all

   $ persistent.ch01 = True 
This should set ch01 to True even if you start the game over.
Last edited by OokamiKasumi on Sun May 25, 2014 6:23 pm, edited 1 time in total.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
SilverSnow
Regular
Posts: 182
Joined: Tue Aug 27, 2013 6:28 am
Completed: Bus Stop, Before the Tale, White Book Complete Volume, See You, The Raven
Projects: Secrets...
Tumblr: stchematelier
itch: st-chem-atelier
Location: Edge of Black Hole
Discord: SHatsuyuki#1452
Contact:

Re: [Tutorial] Making a Contents page / screen

#22 Post by SilverSnow »

OokamiKasumi wrote:
A persistent variable is a variable that doesn't get erased or reset when the game is closed, the way other variables do. (That's why they're called persistent.)

The way to use this is when you reach a point in your game that you want to Permanently set to accessible (or not accessible,) you add .persistent to your variable. (Don't forget the dot!)

Example:

Code: Select all

   $ persistent.ch01 = True 
This should set ch01 to True even if you start the game over.
Thanks for your help :D I figured the problem was where I was putting the persistent data. I was suppose to do:

Code: Select all

label start:
    $ persistent.end0 = False
    $ persistent.end1 = False
    $ persistent.end2 = False
    $ persistent.end3 = False
    $ persistent.end4 = False
instead of:

Code: Select all

init:
    $ persistent.end0 = False
    $ persistent.end1 = False
    $ persistent.end2 = False
    $ persistent.end3 = False
    $ persistent.end4 = False
I found it out also thanks to this thread.
Image

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: [Tutorial] Making a Contents page / screen

#23 Post by PyTom »

You generally don't want to set persistent data to False. This will clear the persistent data at the start of every game. If you're going to do that, normal variables work better.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Dylan_Bain
Regular
Posts: 101
Joined: Mon Mar 09, 2015 2:05 pm
Organization: Dylan Bain Games
Location: Scotland
Contact:

Re: [Tutorial] Making a Contents page / screen

#24 Post by Dylan_Bain »

Hey!

This tutorial is really helpful, but as I am new to Ren'Py, can you help me with something?

How do I edit a chapter_list.rpy page?

Thank you! :lol:

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [Tutorial] Making a Contents page / screen

#25 Post by OokamiKasumi »

Dylan_Bain wrote:THow do I edit a chapter_list.rpy page?
Edit...?
-- As in:
1. Change the code in a finished game that you did not make?
-- Or--
2. You've put all the code on a chapter_list.rpy page and now you can't find it to edit it?

For 1. You Don't.
For 2. Open the Renpy launcher and select: All script files. This will open all the rpy files in the game folder and display them in tabs at the top of the page. As long as the chapter_list.rpy page is in your game folder, Editra will open that one too.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
Dylan_Bain
Regular
Posts: 101
Joined: Mon Mar 09, 2015 2:05 pm
Organization: Dylan Bain Games
Location: Scotland
Contact:

Re: [Tutorial] Making a Contents page / screen

#26 Post by Dylan_Bain »

OokamiKasumi wrote:
Dylan_Bain wrote:THow do I edit a chapter_list.rpy page?
Edit...?
-- As in:
1. Change the code in a finished game that you did not make?
-- Or--
2. You've put all the code on a chapter_list.rpy page and now you can't find it to edit it?

For 1. You Don't.
For 2. Open the Renpy launcher and select: All script files. This will open all the rpy files in the game folder and display them in tabs at the top of the page. As long as the chapter_list.rpy page is in your game folder, Editra will open that one too.
Yeah... sorry, that doesn't really help me... sorry!

I mean that I am trying to create a chapter_list.rpy page. I am making my own game and haven't done it yet, as I don't know how. Also, if you know, is it possible to add the chapter select button to the main menu, instead of the in-game menu?

Just so u know i use jEdit.

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [Tutorial] Making a Contents page / screen

#27 Post by OokamiKasumi »

Dylan_Bain wrote:I mean that I am trying to create a chapter_list.rpy page. I am making my own game and haven't done it yet, as I don't know how. Just so u know i use jEdit.
Then we have a problem since I use Editra, the one that comes with Renpy.
-- I tried opening an older version of Renpy to get to jEdit, but the Java on my computer has updated (8.0) beyond what jEdit uses (7.0,) so it no longer functions.

In essence, what you have to do is Open a Blank Page in your editing software (file > new page/tab?) Copy the text for the chapter screen onto that blank page then SAVE that page in your Game Folder as an .rpy file.

Don't forget to Change or Remove the image names and file names to what you actually Have or it will cough up errors like you wouldn't believe.
Last edited by OokamiKasumi on Sun Mar 15, 2015 2:32 pm, edited 1 time in total.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
Dylan_Bain
Regular
Posts: 101
Joined: Mon Mar 09, 2015 2:05 pm
Organization: Dylan Bain Games
Location: Scotland
Contact:

Re: [Tutorial] Making a Contents page / screen

#28 Post by Dylan_Bain »

Then we have a problem since I use Editra, the one that comes with Renpy.
-- I tried opening an older version of Renpy to get to jEdit, but since the Java had updated on my computer, it no longer functions.

In essence, what you have to do is Open a Blank Page in your editing software (file > new page/tab?) Copy the text for the chapter screen onto that blank page then SAVE that page in your Game Folder as an .rpy file.

Don't forget to Remove the image names and file names that You Don't Have or it will cough up errors like you wouldn't believe.
Thanks!
Image
http://lemmasoft.renai.us/forums/viewto ... 52#p365552 Curently NOT Accepting Commisions!

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [Tutorial] Making a Contents page / screen

#29 Post by OokamiKasumi »

Oh, I almost forgot your other question!
Dylan_Bain wrote:... if you know, is it possible to add the chapter select button to the main menu, instead of the in-game menu?
Yes! You add a link to the Main Menu exactly the same way you would to the Navigation (in-game) menu.
-- However, if you go to the main menu at any time while playing, it Does Not Save that game. The player will lose all the progress in whatever game they're in.
-- Also, Starting a game at a specific chapter is not the same as starting from a Save point! Whatever the flags were set to at Game Start is what they will Still Be when that chapter starts because you are technically starting a whole new game from that point.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

PXL
Newbie
Posts: 21
Joined: Wed Oct 14, 2015 4:48 pm
Contact:

Re: [Tutorial] Making a Contents page / screen

#30 Post by PXL »

Great tutorial! This was exactly what I needed!

Post Reply

Who is online

Users browsing this forum: No registered users