Automatic flowchart for RenPy story scrips

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
Alessio
Miko-Class Veteran
Posts: 576
Joined: Fri May 07, 2004 9:40 am
Completed: GO! Magical Boy (2006), Angelic Orbs (soundtrack)
Projects: Cyberlin (in progress)
Location: Finland
Contact:

Automatic flowchart for RenPy story scrips

#1 Post by Alessio »

Hello everyone,

To support the writing of my branching stories, I wrote a Python tool (see attachment) to create a flowchart of the story line. The tool parses the RenPy story files (.rpy) in the game directory for label and jump commands and creates a .graphml file that can then be opened with yEd (free graph editor). The flow chart allows direct jumps to the correct line of an .rpy file in the Atom editor. Hopefully this is helpful, feel free to edit/improve it! I use it in Windows, the code might need some adapting to work in Apple/Linux environments (folder paths probably).

There is a short demo video at https://www.youtube.com/watch?v=7dfGgJRAEZY.

Short instructions:
  • Create a new folder inside RenPy's "game" directory, copy the VNavigator.py file into it and execute it.
  • Non-story files gui.rpy, options.rpy, and screens.rpy are skipped.
  • Comments (#) behind label and jump commands are copied to the flowchart.
  • After opening the .graphml file with yEd, select Layout > Hierarchical to optimize the flowchart.
  • To prevent labels from being taken into account, start their comment with a "-".
Attachments
Example screenshot of flow chart
Example screenshot of flow chart
VNavigator.py
VNavigator Python code
(9.05 KiB) Downloaded 205 times
Last edited by Alessio on Sat Feb 18, 2023 5:45 am, edited 1 time in total.
Current projects: Visual Novel "Cyberlin"

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Automatic flowchart for RenPy story scrips

#2 Post by _ticlock_ »

Alessio wrote: Sat Jan 28, 2023 6:10 am
I recommend posting this tool in RenPy Cookbook.

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

Re: Automatic flowchart for RenPy story scrips

#3 Post by Ocelot »

Looks good. Can it understand screen-based navigation (For example, answering a phone message in a certain way can immediately jump to another label) or show conditional choices (if certain conditions are true jump to label1 otherwise proceed to label2)?

You can also check similar tool made before:
viewtopic.php?f=8&t=61517
< < insert Rick Cook quote here > >

Alessio
Miko-Class Veteran
Posts: 576
Joined: Fri May 07, 2004 9:40 am
Completed: GO! Magical Boy (2006), Angelic Orbs (soundtrack)
Projects: Cyberlin (in progress)
Location: Finland
Contact:

Re: Automatic flowchart for RenPy story scrips

#4 Post by Alessio »

_ticlock_ wrote: Sun Jan 29, 2023 12:37 am I recommend posting this tool in RenPy Cookbook.
I thought about that initially, but this is not a RenPy code how-to recipe, it's an external Python program. Hmm, maybe splitting hairs. But double-posting at this stage probably makes no sense.
Current projects: Visual Novel "Cyberlin"

Alessio
Miko-Class Veteran
Posts: 576
Joined: Fri May 07, 2004 9:40 am
Completed: GO! Magical Boy (2006), Angelic Orbs (soundtrack)
Projects: Cyberlin (in progress)
Location: Finland
Contact:

Re: Automatic flowchart for RenPy story scrips

#5 Post by Alessio »

Ocelot wrote: Sun Jan 29, 2023 4:56 am Looks good. Can it understand screen-based navigation (For example, answering a phone message in a certain way can immediately jump to another label) or show conditional choices (if certain conditions are true jump to label1 otherwise proceed to label2)?

You can also check similar tool made before:
viewtopic.php?f=8&t=61517
Can't believe I missed the "Routes analyser" tool, thanks for the link! I thought I'd searched everywhere and made my tool since I couldn't find anything similar. :-/

My tool is fairly simple and hunts down any label and jump statement. Jumps contained in a menu with multiple choices should be recognized. When there are conditions/multiple choices, I recommend adding a comment behind the jump statement so the text shows up on the flow chart's arrow.

The tool is not interpreting any logic though, so it won't recognize jumps that are impossible to reach, jumps to dynamic labels (when a label is a variable determined during runtime), implicit jumps (pass, continuing to the next label) etc. Also, for the purpose of visualizing the actual story flow, I did not add recognition of call/return statements.
Current projects: Visual Novel "Cyberlin"

Post Reply

Who is online

Users browsing this forum: No registered users