Ren'Py multiple stories code

Alexer91

New Member
May 11, 2019
4
0
Hi everyone.
Speaking of Python and ren'py code.

If I have two stories of 3 chapters each:


Menu_Story1 = Chapter_1 => Chapter_2 => Chapter_3

Menu_Story2 = Chapter_1 => Chapter_2 => Chapter_3


And the character will always have to go through "Menu_story" to access the chapters.

How can I make "Menù story" understand, for example, to continue with "Chapter_2" if I have already done "Chapter _1"?


Ex:

Menu_story1 = If "Chapter_1" has already been visited, "Chapter_2" will begin.

Menu_story2 = If "Chapter_2" has already been visited, you can see "Chapter_3"
 

mickydoo

Fudged it again.
Game Developer
Jan 5, 2018
2,446
3,557
A simple way would be like this. Define default values for each chapter.

default Chapter_1 = False (Prolly don't even need that one)
default Chapter_2 = False
default Chapter_3 = False

Then you would play Menu_story then Chapter_1, then put the variable after chapter_1.
Python:
label Menu_story:
    if Chapter_2 == True:
        jump Chapter_2
    if Chapter_3 == True:
        jump Chapter_3 
    else:
        Jump Chapter_1
      
label Chapter_1:
    "This is my story"
    "Yay you have finished Chapter 1"
    $ Chapter_2 = True
    jump Menu_story
  
label Chapter_2: 
    "Welcome to Chapter 2"
    "Welll done, you have finished Chapter 2"
    $ Chapter_3 = True
    jump Menu_story
  
label Chapter_3:
    "This is the final Chapter"
That would be the simplest way.
 
  • Like
Reactions: Alexer91

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
Another way would be to actually split your game into two separate games.

Call the first game "My_Game - Episode 1"
Call the second game "My_Game - Episode 2".

Unless there is a massive number of shared images, the overlap shouldn't create a huge addition in additional disk space.

That is unless decisions in "Story1" affect things in "Story2"... in which case, I'm not sure why Story2 wouldn't just be Chapters 4, 5 and 6.

As far as the chapters... I'm not entirely sure why you'd need to do anything with them.
By which I mean you're aiming for a game where you have to play through chapter 1 to reach chapter 2, etc.
But if you just coded it in a linear way... that's how it would play out anyway.

... All you would need is some sort of transition/slideshow to draw the player's attention to the fact they're advancing from Chapter 1 -> 2 -> 3, etc.

I'm thinking of something along the lines of:

You don't have permission to view the spoiler content. Log in or register now.

The end result would still be the same... Chapter 1 would flow into Chapter 2 which would flow into Chapter 3. You couldn't start Chapter 2 without finishing Chapter 1 first.

The only difference I can see is that you wouldn't be able to select Chapter 2 or 3 from the main RenPy menu. But then I'm not sure why you'd want to if they have to be played in order anyway.

If you do decide to follow mickydoo's suggestion of variables to control things (and it IS a good idea), I'd perhaps consider using slightly less generic names. Something like:

Python:
default chapter_2_unlocked = False
default chapter_3_unlocked = False

And as a last thought... If I've perhaps got the wrong end of the stick and you're trying to do something like allowing the player to start at Chapter 2 if they've previously ever finished Chapter 1... you might want to have a look at data. Though keep in mind that jumping straight to the middle of your game as a new play-through might cause you some headaches with regards to choices that the player is skipping past, earlier in the game.
 
Last edited:
  • Thinking Face
Reactions: Alexer91

Alexer91

New Member
May 11, 2019
4
0
I really don't know how to thank you.

Hi Mickydoo, everything works up to chapter_2, to then create an endless loop of chapter_2.
In summary it does not arrive at chapter_3.

79flavors, The reason I want to structure my game this way is because I'm trying to create an "Open World" (if I can call it that way in a visual novel).
Therefore the player will have to be able to select more autonomous stories at will.
 

mickydoo

Fudged it again.
Game Developer
Jan 5, 2018
2,446
3,557
I really don't know how to thank you.

Hi Mickydoo, everything works up to chapter_2, to then create an endless loop of chapter_2.
In summary it does not arrive at chapter_3.

79flavors, The reason I want to structure my game this way is because I'm trying to create an "Open World" (if I can call it that way in a visual novel).
Therefore the player will have to be able to select more autonomous stories at will.
Oh yeah, at the end of chapter_2 make it false again ie

$ chapter_2 = False

So chapter_3 is true but chapter_2 is false again , so then when you jump back it will go to chapter_3
 
  • Like
Reactions: Alexer91

mickydoo

Fudged it again.
Game Developer
Jan 5, 2018
2,446
3,557
Thanks so much, all works now. :)
Yeah sorry, noob mistake lol, I'm in Australia, it's not summer yet and it's fucking hot already. 38 deg C today, hard to think.

There would be flasher code like the one above, but my whole game is a basic code that I can understand, the rest just goes over my head, it's a good way to start learning if nothing else.
 
  • Haha
Reactions: Alexer91

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
79flavors, The reason I want to structure my game this way is because I'm trying to create an "Open World" (if I can call it that way in a visual novel).
Make sense.

I still feel you could probably do it without selecting choices from the main menu... since at some point you'll need to set the chapter_02 flag to True... In my imagination about how you'd implement that in a more free roaming style, there'd be nothing stopping you either immediately jumping to Chapter 2 at that same point... or jumping there the next time you reach your "open world hub" point (home / end of day / whatever makes sense to your game).

I only offer up the option, not as criticism, but as an alternative.
At the end of the day, you're WAY more familiar with your game than I am.

As for the Chapter 2 looping... I see you've already solved it.

Another solution could have been to check for Chapter 3 before checking for Chapter 2.
It's a good habit to pick up for advancing systems based on some sort of progression.

So something like:
Python:
label Menu_story:
    if Chapter_3_unlocked == True:
        jump chapter_3_start

    if Chapter_2_unlocked == True:
        jump chapter_2_start

    jump chapter_1_start

That way you could leave Chapter_2_unlocked as True. I doubt it would make any difference... Again... sometimes alternate solutions matter less now and more the next time you come across a similar problem.
 

Alexer91

New Member
May 11, 2019
4
0
Yeah sorry, noob mistake lol, I'm in Australia, it's not summer yet and it's fucking hot already. 38 deg C today, hard to think.

There would be flasher code like the one above, but my whole game is a basic code that I can understand, the rest just goes over my head, it's a good way to start learning if nothing else.
Beautiful Australia, I think we have the same sensitivity to heat.:LOL:

Make sense.

I still feel you could probably do it without selecting choices from the main menu... since at some point you'll need to set the chapter_02 flag to True... In my imagination about how you'd implement that in a more free roaming style, there'd be nothing stopping you either immediately jumping to Chapter 2 at that same point... or jumping there the next time you reach your "open world hub" point (home / end of day / whatever makes sense to your game).

I only offer up the option, not as criticism, but as an alternative.
At the end of the day, you're WAY more familiar with your game than I am.
You do well, every opinion is welcome. I'm still a beginner and if I managed to do something it's only thanks to YouTube tutorials and advice from victorious souls like you.
So thanks again. :D