Diff for Twine: A script to convert parser IF transcripts into linear Twines

Tue, 10/21/2014 - 22:50 by LTue, 10/21/2014 - 23:14 by L
Changes to Body
Line 5 Line 5
var currentPassage=new Passage("Start");currentPassage.text="";var id=currentPassage.id=1;tale.get("Transcript").text.split(/\n/g).forEach(function(b){var a=b.indexOf(">");if(a===-1){currentPassage.text+=b+"\n"}else{id+=1;var c="Turn "+id;currentPassage.text+=b.slice(0,a)+"\n ''>'' [[b][/b]["+b.slice(a+1)+"|"+c+"]]\n";tale.passages[currentPassage.title]=currentPassage;currentPassage=new Passage(c);currentPassage.id=id;currentPassage.text=""}});currentPassage.text=currentPassage.text.trim()||"<[b][/b]<[b][/b]set window.close()>>";tale.passages[currentPassage.title]=currentPassage;Wikifier.formatters.forEach(function(a){if(a.name=="list"){a.match="^(?!.)(?=.)"}}); var currentPassage=new Passage("Start");currentPassage.text="";var id=currentPassage.id=1;tale.get("Transcript").text.split(/\n/g).forEach(function(b){var a=b.indexOf(">");if(a===-1){currentPassage.text+=b+"\n"}else{id+=1;var c="Turn "+id;currentPassage.text+=b.slice(0,a)+"\n ''>'' [[b][/b]["+b.slice(a+1)+"|"+c+"]]\n";tale.passages[currentPassage.title]=currentPassage;currentPassage=new Passage(c);currentPassage.id=id;currentPassage.text=""}});currentPassage.text=currentPassage.text.trim()||"<[b][/b]<[b][/b]set window.close()>>";tale.passages[currentPassage.title]=currentPassage;Wikifier.formatters.forEach(function(a){if(a.name=="list"){a.match="^(?!.)(?=.)"}});
</code> </code>
-2) Paste the entire transcript into a passage named "Transcript". +2) Paste the entire transcript, from beginning to end, into a passage named "Transcript".
When you run the game, the Start passage and all other passages will be replaced with passages derived from the transcript. Each passage will only have 1 command. When you run the game, the Start passage and all other passages will be replaced with passages derived from the transcript. Each passage will only have 1 command.
Line 11 Line 11
[b]Limitations:[/b] [b]Limitations:[/b]
* This assumes that the ">" character is only used for player commands throughout the entire story - and it also assumes that all player commands end in a line break. If these aren't the case, there'll be trouble. * This assumes that the ">" character is only used for player commands throughout the entire story - and it also assumes that all player commands end in a line break. If these aren't the case, there'll be trouble.
 +* If the transcript contains other text structures which correspond to Twine syntax, those may unwittingly activate. This script removes one fairly common occurrence - HTML bullet points denoted by * - but leaves the others present.
[b]Suggestions:[/b] [b]Suggestions:[/b]

Revision of Tue, 10/21/2014 - 23:14:

Twine: A script to convert parser IF transcripts into linear Twines

I've devised a way to convert game transcripts exported from Gargoyle (using the "script" command) directly into basic Twine games, programmatically. Here is a two-step process:

1) Include this script:

var currentPassage=new Passage("Start");currentPassage.text="";var id=currentPassage.id=1;tale.get("Transcript").text.split(/\n/g).forEach(function(b){var a=b.indexOf(">");if(a===-1){currentPassage.text+=b+"\n"}else{id+=1;var c="Turn "+id;currentPassage.text+=b.slice(0,a)+"\n ''>'' [["+b.slice(a+1)+"|"+c+"]]\n";tale.passages[currentPassage.title]=currentPassage;currentPassage=new Passage(c);currentPassage.id=id;currentPassage.text=""}});currentPassage.text=currentPassage.text.trim()||"<<set window.close()>>";tale.passages[currentPassage.title]=currentPassage;Wikifier.formatters.forEach(function(a){if(a.name=="list"){a.match="^(?!.)(?=.)"}});

2) Paste the entire transcript, from beginning to end, into a passage named "Transcript".

When you run the game, the Start passage and all other passages will be replaced with passages derived from the transcript. Each passage will only have 1 command.

Limitations:
* This assumes that the ">" character is only used for player commands throughout the entire story - and it also assumes that all player commands end in a line break. If these aren't the case, there'll be trouble.
* If the transcript contains other text structures which correspond to Twine syntax, those may unwittingly activate. This script removes one fairly common occurrence - HTML bullet points denoted by * - but leaves the others present.

Suggestions:
* Play in the Jonah format (and optionally remove the title using CSS).
* Use basic CSS to make the links larger (similar to how MS Paint Adventures displays its page links).

FAQ:
Q: Is this Lighan ses Lion compliant???
A: Naturally!