I recently became interested in using Twine to storyboard so I could take advantage of node maps for branching stories. This tool is for building a story in Twine with Ren'py code (except using Twine's macros for jump/call/etc. to utilize the node map), testing as needed, then exporting to an .rpy with the macros converted to the Ren'py equivalents. See the examples in the .zip.
twine2rpy converts PassageTitle to label, internalLinks to jump, <<display>> to call, <<choice>> to jump, <<set>>, <<print>>, and if blocks. It doesn't convert multiple variable assignment or multiple conditions (using ;) or ternary operators.
Run the script from the command line: twine2rpy.py source.txt
The .zip includes a sample .tws, .txt, and .rpy.
Update: v 1.1 replaces tabs with 4 spaces. Ren'Py doesn't like tabs. If you already converted using the previous version you can fix it yourself by using your editor's replace function to replace "\t" with four spaces (check the regular expression field).
Converting Twine source to .rpy files
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.
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.
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Converting Twine source to .rpy files
- Attachments
-
- twine2rpy-1.1.zip
- (4.78 KiB) Downloaded 489 times
Last edited by saguaro on Thu Mar 07, 2013 1:13 pm, edited 3 times in total.
- chronodekar
- Newbie
- Posts: 3
- Joined: Wed Feb 27, 2013 10:46 am
- Contact:
Re: Converting Twine source to .rpy files
Haven't checked out your tool, but Twine looks interesting. Thanks for sharing !
-chronodekar
-chronodekar
Re: Converting Twine source to .rpy files
Thanks heaps for sharing!
I just know a little twine is going to help me go a long way from my usually disorganised script writing xD.
I just know a little twine is going to help me go a long way from my usually disorganised script writing xD.
Avatar made by xSugar-ZooZoo
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: Converting Twine source to .rpy files
Yeah, I think it's definitely helping me stay organized on my current project.
The only two issues I've encountered so far are copy-pasting from a word processor without converting to utf-8 first (Twine won't export non-Unicode, so you have to find/replace) and the fact that Twine exports the nodes left-right top-bottom, so you need to set up nodes that way if you want the exported labels to have any kind of order.
The only two issues I've encountered so far are copy-pasting from a word processor without converting to utf-8 first (Twine won't export non-Unicode, so you have to find/replace) and the fact that Twine exports the nodes left-right top-bottom, so you need to set up nodes that way if you want the exported labels to have any kind of order.
Re: Converting Twine source to .rpy files
Oh I see
Thanks for explaining that because I was considering copy and pasting and wouldn't have figured out those technical issues ^^;
Appreciate it
Thanks for explaining that because I was considering copy and pasting and wouldn't have figured out those technical issues ^^;
Appreciate it
Avatar made by xSugar-ZooZoo
-
- Newbie
- Posts: 1
- Joined: Sun Jun 19, 2016 4:12 pm
- Contact:
Re: Converting Twine source to .rpy files
This seems like a terrific tool, but I can't get it to work! Is it still supported?
- jesusalva
- Regular
- Posts: 88
- Joined: Mon Jul 22, 2013 5:05 pm
- Organization: Software in Public Interest, Inc.
- IRC Nick: jesusalva
- Github: pazkero
- itch: tmw2
- Location: Brazil
- Discord: Jesusalva#4449
- Contact:
Re: Converting Twine source to .rpy files
In December 2014, Twine released a new version, Twine 2.monstergrin wrote: ↑Sun Jun 19, 2016 4:14 pm This seems like a terrific tool, but I can't get it to work! Is it still supported?
This is the version which Twine gives you by default, and it only exports HTML documents.
This script was made for Twine 1, which is still available to download as of writing, but doesn't receive updates since 2016 (according to github).
You can try Twine 1 to make use of this script at your own risk.
A small experiment I did:
I actually wrote in about 40 minutes a quick python script which will read the HTML file and extract the most relevant tidbits from it.
It is not meant for production; Currently it can only make simple narrator texts and simple menus. (If you go past page 2 of Twine Quickstart this script will give up).
Do note that I was only tinkering to see if it would be possible to make such tool (the answer is: Yes, it is possible), so I did not even bother to try it on Python3. (So yep, another short-lived utility script).
It is not meant for production; Currently it can only make simple narrator texts and simple menus. (If you go past page 2 of Twine Quickstart this script will give up).
Do note that I was only tinkering to see if it would be possible to make such tool (the answer is: Yes, it is possible), so I did not even bother to try it on Python3. (So yep, another short-lived utility script).
Jesusaves/Jesusalva
-
- Regular
- Posts: 25
- Joined: Sat Apr 11, 2020 1:28 pm
- Contact:
Re: Converting Twine source to .rpy files
Wow I didn't know Twine can do that :O
All I know is that Twine can only export to .html Ha HA
Thanks for sharing! @saguaro
All I know is that Twine can only export to .html Ha HA
Thanks for sharing! @saguaro
Who is online
Users browsing this forum: No registered users