Code Monkey home page Code Monkey logo

renpy-graphviz's Introduction

Ren'Py Graphviz

Ren'Py graph visualizer - branches flowchart generator

Go Reference Go Report Card

GitHub Repo stars

This is a tool written in Go that allows you to visualize the routes of your Ren'Py story

Routes of the Question Extract Routes of the Question, the classic Ren'Py example

Table of Contents

Examples

Doki Doki Litterature Club Extract Doki Doki Litterature Club will no longer have secrets for you!

Coalescence Extract An extract from my personal VN, Coalescence. You can't imagine handling a heavy VN like this one without graphic tools... The labels are blurred due to the preview image

๐Ÿ”Ž HOW TO USE?

Online version - try online

You can test this tool in the browser. If you want to get .png files, please download the software version. Note that this website will not be maintained and it is not guaranteed to represent the library fully.

https://ewenquim.github.io/renpy-graphviz

Software version -install it on your computer

The command line version is more powerful as you can add flags and a path, see the documentation by typing renpy-graphviz -h.

  • Download the latest version
  • Move the program to your game folder
  • Run it from the command line ./renpy-graphviz or by clicking on the icon in your file manager
    • You might need to provide permissions, this program is not a virus. On Unix, run chmod +x renpy-graphviz*.
  • renpy-graphviz.png should appear, enjoy!

Go library

go install pkg.amethysts.studio/renpy-graphviz@latest

If you are a Go user and want to integrate this in a Go lib/program, it is possible. The /parser module is very powerful.

๐Ÿท Tags

Since Ren'Py scripting isn't strict, therefore the script can't know what is going on in the .rpy file in some cases. So, this program uses a tag system to enforce some behaviors. For example;

label chapter_1: #renpy-graphviz: TITLE

Before tags, you must write renpy-graphviz in a comment to ensure there are no collisions with existing words in your VN. Here are the tags available:

  • BEHAVIOUR TAGS
    • BREAK breaks the current flow for linear labels, creating a new parallel
    • IGNORE ignores the current label. Jumps to this label will be drawn
    • SKIPLINK avoids long arrows by creating shortcuts marked with an asterisk. These shortcuts can't have child nodes
    • FAKE_LABELS simulates labels and jumps, creating a new parallel
    • INGAME_LABELS interacts with real labels and jumps, similar to fake labels
  • STYLE TAGS

BREAK

Cancels any "guessed link".

Expectedwith BREAKscript.rpy

Example image of Break, Before

Example image of Break, After

label one:
  "blah blah"

label two:
"bla bla"

# renpy-graphviz: BREAK

label three:
"the end"

IGNORE

Ignores the current line. If this is a jump to a label that isn't ignored, the label will still appear on the graph but not the arrow that should go towards it. Similarly, if this is a jump from a label that isn't ignored but the jump destination is, the arrow will not appear on the graph.

ExpectedIGNOREscript.rpy

Example image of Ignore, Before

Example image of Ignore, After

label one:
label two: # renpy-graphviz: IGNORE
label three:

SKIPLINK

Avoids long arrows by creating another label with the same name. Beware, the label can't have any children and is marked by an asterisk to show it is a copy. Jumps will not be directed to this label if there is an original label displayed, if not, the jump is ignored.

ExpectedSKIPLINKscript.rpy

Example image of Skiplink, Before

Example image of Skiplink, After

label one:
    if condition:
        jump six # renpy-graphviz: SKIPLINK
    else:
        pass

label two:
label three:
label four:
label five:
label six:

FAKE_LABEL(a) & FAKE_JUMP(a, b)

Creates a node or an arrow in the graph without having to create a label in your Ren'Py script. It is disconnected from the normal flow, label and jump in your script.

FAKESscript.rpy

Example image of Fakes

# You can mix different tags on the same line
# renpy-graphviz: FAKE_LABEL(a) TITLE
# If b/c does not exists, it creates it
# renpy-graphviz: FAKE_JUMP(b, c)

label real_1:
# There will be no 'indirect link' from `real_1` to `d`
# renpy-graphviz: FAKE_LABEL(d)

# Implicit jump from `real_one` to `real_two`
# (normal behaviour as `d` is ignored by the normal flow)
label real_2:

# No jump from `real_two` to `a` or `d`
# renpy-graphviz: FAKE_JUMP(a, d)

INGAME_LABEL(i, a) & INGAME_JUMP(i, b)

Same as above but interacts with label, call and jump in your normal flow in the Ren'Py script. You need to specify an indentation level.

# renpy-graphviz: INGAME_JUMP(8, destination)

is the equivalent of:

        jump destination
INGAMESscript.rpy

Example image of Label & Jump

# renpy-graphviz: INGAME_LABEL(0, start)
# renpy-graphviz: INGAME_JUMP(4, option_one)

# Creates a link from `start` to `option_two` even
# if there was a jump before -like normal jumps
# renpy-graphviz: INGAME_JUMP(4, option_two)

label option_one:
    "dialogue"

# should follow the previous label (implicit jump)
# renpy-graphviz: INGAME_LABEL(0, indirect_label)

# jumps from `indirect_label` to `option_two`
    jump option_two

TITLE & GAMEOVER

Sets styles.

TITLE / GAMEOVERscript.rpy

Example image of Title

label routeone :  # renpy-graphviz: TITlE
    d "Hello World!"
    if condition:
        jump bad_ending

label routeAlternative:
    d "Normal bubble"
    jump good_ending


label bad_ending: # renpy-graphviz: GAMEOVER
    d "Bad ending"
    return

SHAPE & COLOR

You can set yourself a custom color or shape for a label.

SHAPE and/or COLORscript.rpy

Example image of Shape Color

label first: # renpy-graphviz: SHAPE(rect) COLOR(red)
    jump second # renpy-graphviz: SHAPE(septagon) COLOR(#ffdd67)

Some examples of shapes and colors can be found here.

Shapes Colors
Rectangle Red
Septagon Blue
Egg Purple
Diamond White

graph.go file also supports line styling, font size and line thickness. Default values can also be changed inside the graph.go file.

Limitations

This requires your VN to be structured in a certain way, so this may not be perfect for you. Feel free to raise an issue here, or to change your VN structure, by adding tags manually.

Your contribution to the project is appreciated!

CONTRIBUTING

See the CONTRIBUTING.md file

LICENSE

This program is free and under the AGPLv3 license.

Beware, if you use this program, you must credit it somewhere on your game.

Used Renpy Graph Vizualiser from EwenQuim

Enjoy! โค๏ธ

renpy-graphviz's People

Contributors

dependabot[bot] avatar ewenquim avatar ozgurozbek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

renpy-graphviz's Issues

Could the browser version support HTTPS public repos?

Assuming the browser version is still client based. It would be nice if it could work without the API key, like normal git when only reading. Just passing in the public git HTTPS link. That way stuff like gitlab, bitbucket etc. could work too, without needing an API key per platform!

Website - Add xxx/yyy to the game list

BEFORE FILING THIS:

  • My game is made with the Ren'Py visual novel game engine
  • My game is uploaded on GitHub
  • I have tried the online tool by entering myusername/mygame and it works

Hello,

I make Renpy games in Chinese.

Label_name use Chinese won't be able to run.

Label_name use English can run, but the Chinese menu can't display properly.(I guess Japanese has the same problem.)

image

Thanks.

Underscores in labelnames not showing in image

Haven't found a mention of this, but I noticed that underscores in label names don't get drawn on the outputted image.

If you're not familiar with the renpy code, it'll take some guessing attempts to find the correct label.

Chinese menu can't display properly

BEFORE FILING THIS:

  • My game is made with the Ren'Py visual novel game engine
  • My game is uploaded on GitHub
  • I have tried the online tool by entering myusername/mygame and it works

Hello,

I make Renpy games in Chinese.

Label_name use Chinese won't be able to run.

Label_name use English can run, but the Chinese menu can't display properly.(I guess Japanese has the same problem.)

image

Thanks.

Segfault on jump after return

label a:
	return
	jump b

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x50a616]

goroutine 1 [running]:
pkg.amethysts.studio/renpy-graphviz/parser.(*RenpyGraph).AddEdge(0xc000123d80, 0x0, 0x0, 0xc000123de0, 0x3, 0x3)
renpy-graphviz/parser/graph.go:115 +0x136
pkg.amethysts.studio/renpy-graphviz/parser.Graph(0xc000062180, 0x4, 0x4, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
renpy-graphviz/parser/parser.go:48 +0x50f
main.main()
renpy-graphviz/main.go:17 +0xa5

The logic in the example is faulty, but it doesn't break RenPy, so it shouldn't break renpy-graphviz either. A call or a duplicate return or "" after return don't crash the tool, so, without digging deep into the source I can't figure out why jump does.

Segfault on BOM

The tool crashes if the .rpy file has a UTF-8 BOM marker (EF BB BF) at the start. Test file attached:
test_bom.rpy.txt

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x509c16]

goroutine 1 [running]:
pkg.amethysts.studio/renpy-graphviz/parser.(*RenpyGraph).AddEdge(0xc0000cdd80, 0x0, 0x0, 0xc0000cdde0, 0x3, 0x3)
/source/parser/graph.go:115 +0x136
pkg.amethysts.studio/renpy-graphviz/parser.Graph(0xc0000d6100, 0x3, 0x4, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/source/parser/parser.go:48 +0x50f
main.main()
/source/main.go:17 +0xa5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.