@videlais/

Tracery + Ink: Functions

Nodejs

No description

fork
loading
Files
  • index.js
  • package-lock.json
  • package.json
  • tracery.json
  • TraceryInk.json
index.js
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