@videlais/

Tracery + Ink

Nodejs

No description

fork
loading
Files
  • index.js
  • InkStory.json
  • package-lock.json
  • package.json
  • tracery.json

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.3569545836424579","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"dmFyIFN0b3J5ID0gcmVxdWlyZSgnaW5ranMnKS5TdG9yeTsKdmFyIFRyYWNlcnkgPSByZXF1aXJlKCd0cmFjZXJ5LWdyYW1tYXInKTsKdmFyIGZzID0gcmVxdWlyZSgnZnMnKTsKCnZhciBpbmtKU09OID0gSlNPTi5wYXJzZSggZnMucmVhZEZpbGVTeW5jKCcuL0lua1N0b3J5Lmpzb24nLCAnVVRGLTgnKS5yZXBsYWNlKC9eXHVGRUZGLywgJycpICk7Cgp2YXIgaW5rU3RvcnkgPSBuZXcgU3RvcnkoaW5rSlNPTik7Cgp2YXIgdHJhY2VyeUpTT04gPSBKU09OLnBhcnNlKGZzLnJlYWRGaWxlU3luYygnLi90cmFjZXJ5Lmpzb24nKSApOyAKCnZhciBncmFtbWFyID0gVHJhY2VyeS5jcmVhdGVHcmFtbWFyKHRyYWNlcnlKU09OKTsKCnZhciBuYW1lID0gZ3JhbW1hci5mbGF0dGVuKCIjbmFtZSMiKTsKdmFyIG1vb2QgPSBncmFtbWFyLmZsYXR0ZW4oIiNtb29kIyIpOwp2YXIgYW5pbWFsID0gZ3JhbW1hci5mbGF0dGVuKCIjYW5pbWFsIyIpOwoKaW5rU3RvcnkudmFyaWFibGVzU3RhdGVbIm5hbWUiXSA9IG5hbWU7Cmlua1N0b3J5LnZhcmlhYmxlc1N0YXRlWyJtb29kIl0gPSBtb29kOwppbmtTdG9yeS52YXJpYWJsZXNTdGF0ZVsiYW5pbWFsIl0gPSBhbmltYWw7Cgpjb25zb2xlLmxvZyhpbmtTdG9yeS5Db250aW51ZSgpICk7Cg=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var Story = require('inkjs').Story;
var Tracery = require('tracery-grammar');
var fs = require('fs');

var inkJSON = JSON.parse( fs.readFileSync('./InkStory.json', 'UTF-8').replace(/^\uFEFF/, '') );

var inkStory = new Story(inkJSON);

var traceryJSON = JSON.parse(fs.readFileSync('./tracery.json') ); 

var grammar = Tracery.createGrammar(traceryJSON);

var name = grammar.flatten("#name#");
var mood = grammar.flatten("#mood#");
var animal = grammar.flatten("#animal#");

inkStory.variablesState["name"] = name;
inkStory.variablesState["mood"] = mood;
inkStory.variablesState["animal"] = animal;

console.log(inkStory.Continue() );
node v10.16.0