[Tool] Convert Choicescript to a Graphviz .dot file

I found a github repo that converts choicescript to a graphviz .dot file. Here’s my fork of it: GitHub - Flurrywinde/choicescript-graphviz: visualize ChoiceScript files as graphs using graphviz/dot

If you can get it working, it can produce output like:

Zoomed in on just part of it:

Sadly, it’s incomplete, and I had to jerry-rig it to not error out on things like *gosub, *return, *else, etc.

It’s in java, so you have to compile it. Then you need a graphviz viewer like xdot.

I’m wondering if this could be put on the web somewhere, so people could upload or paste in their choicescript, hit a button, and get the resultant flowchart. Anyone know how to do that?

16 Likes

Oh I’ve been wondering if something like this was possible! I’ll definitely be following this topic. I’m sure many others would be interested in creating flowcharts if someone can get a simplified tool up somewhere for popular use

Interesting find!

Unfortunately with it being Java, you’d need to host it on a server somewhere (i.e. it’d cost some money to host, and time in maintenance). By no means impossible, but it raises the bar a little for a hobbyist.

Note #1: The choicescript .txt file must use tabs for indentation (not spaces).

This is a pretty big limitation. Worth noting in the first post?

4 Likes

Maybe, but it’s pretty easy to fix, I think. I forget what it’s like to not be a programmer sometimes. I just did retab! in vim to convert spaces to tabs. Maybe just for fun I’ll learn enough java to support spaces too, as this kind of flowchart is something I’d get a lot of use out of. Maybe others will as well if we can get it into an easily usable form.

2 Likes

Yeah, I’d wager 80-90% of the forum have no clue what vim even is :grin:

4 Likes

Very cool. Reminds me of how Twine displays branches and passages. Would definitely be interested in seeing it developed further.

1 Like

I’d wager higher :joy:.

I’ve been growing less and less interested in ChoiceScript itself (still like IF though), but this problem seems interesting and not that hard.

You don’t even need a full parser, you only need to parse flow control commands such as goto, gosub, if and their variations, and labels. Then build a tree and plot using D3.js or something similar. If you use only JavaScript then you can run it in any browser locally.

1 Like