@videlais/

Tracery + Ink: Functions

Nodejs

No description

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

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.8797794421593255","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"dmFyIFN0b3J5ID0gcmVxdWlyZSgnaW5ranMnKS5TdG9yeTsKdmFyIFRyYWNlcnkgPSByZXF1aXJlKCd0cmFjZXJ5LWdyYW1tYXInKTsKdmFyIGZzID0gcmVxdWlyZSgnZnMnKTsKCnZhciBpbmtKU09OID0gSlNPTi5wYXJzZSggZnMucmVhZEZpbGVTeW5jKCcuL1RyYWNlcnlJbmsuanNvbicsICdVVEYtOCcpLnJlcGxhY2UoL15cdUZFRkYvLCAnJykgKTsKCnZhciBpbmtTdG9yeSA9IG5ldyBTdG9yeShpbmtKU09OKTsKCnZhciB0cmFjZXJ5SlNPTiA9IEpTT04ucGFyc2UoZnMucmVhZEZpbGVTeW5jKCcuL3RyYWNlcnkuanNvbicpICk7IAoKdmFyIGdyYW1tYXIgPSBUcmFjZXJ5LmNyZWF0ZUdyYW1tYXIodHJhY2VyeUpTT04pOwoKdmFyIG5hbWUgPSBncmFtbWFyLmZsYXR0ZW4oIiNuYW1lIyIpOwp2YXIgbW9vZCA9IGdyYW1tYXIuZmxhdHRlbigiI21vb2QjIik7CnZhciBhbmltYWwgPSBncmFtbWFyLmZsYXR0ZW4oIiNhbmltYWwjIik7CgppbmtTdG9yeS5FdmFsdWF0ZUZ1bmN0aW9uKCJzZXROYW1lIiwgW25hbWVdKTsKaW5rU3RvcnkuRXZhbHVhdGVGdW5jdGlvbigic2V0TW9vZCIsIFttb29kXSk7Cmlua1N0b3J5LkV2YWx1YXRlRnVuY3Rpb24oInNldEFuaW1hbCIsIFthbmltYWxdKTsKCmNvbnNvbGUubG9nKGlua1N0b3J5LkNvbnRpbnVlKCkgKTsK"},"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('./TraceryInk.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.EvaluateFunction("setName", [name]);
inkStory.EvaluateFunction("setMood", [mood]);
inkStory.EvaluateFunction("setAnimal", [animal]);

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