This page is work-in-progress. You can reach me on twitter or mail to rezoner1337@gmail.com

Playground - Data

Playground can load text or json data from another file.

this.loadData("example");

This will look into data/example.json

JSON will get parsed and saved as an object - which you can easily access:

this.data.example

Text data

this.loadData("example.txt");

This will look for data/example.txt and will not attempt to parse it as a JSON

Merging data

Playground will merge data that is put in subsequent folders.

this.loadData("items", "items/weapons", "items/food");

This will look for

data/items.json data/items/weapons.json data/items/food.json

And put them into one this.data.items object overwriting repeated keys

If the root doesn't exist an empty object will be created and overwritten:

/* that's legit */

this.loadData("items/weapons", "items/food");

This also works for text files in which case they will get concatenated.

Ask question:

Fork me on GitHub