0.1.3 • Published 5 years ago

factorio-recipes-json v0.1.3

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

factorio-recipes-json

Build Status license factorio version

A database of Factorio Recipes in JSON designed for HTML visualizations of the game's recipes. Recursive algorithms can be used to determine item dependancies. Of course, this repository has automated build, test, and deployment in honour of Factorio's style. :smile:

Please note that the database is still under development, there may be signficant changes before the complete version is released

See the demo recipe browser here.

Recipe Data sourced from the Official Factorio Wiki and the official game's Lua recipe files. Send me pull requests if you find any inconsistencies or errors.

How to use

The database is a JSON list of all the recipes in the game. Recipe dependancies can be searched by their IDs. It also includes some item types like Resources (e.g. Iron) and Liquids (e.g. Water) to help recursive algorithms terminate properly. See Addtional Notes below for more information

1. Import the file

You can use one of the two flavors of the database: Array or Dictionary. The Array list is the canonical used for development. The dictionary uses the id of the recipe as the key. Use one of the following links below to get the file for your project:

CDN coming soon.

2. Using the file

In JQuery, You can fetch the latest version of the JSON file from GitHub:

$.getJSON("https://kevinta893.github.io/factorio-recipes-json/recipes.min.json", function (json, err){
    if (err != "success"){
        console.log("Error cannot load json\n" + err);
        return;
    }

    var recipesList = json;
    //TODO your code here
});
   

In Node.js, you can synchronously or asynchronously get the file from your machine locally (synchronous example below):

var recipesList = JSON.parse(fs.readFileSync('recipes.json', 'utf8'));			//synchronous

Data Fields

FieldDescription
idThe internal name of the item
nameThe user friendly name
typeThe item type of the resulting item. One of: Machine, Resource, Liquid, Intermediate product, Item, Science Pack, Combat, Process, Tool, null
wiki_linkA link to the Factorio Wiki
recipeThe item's recipe (normal mode)
recipe->ingredientsA list of ingredients to make the recipe, each ingredient has is an item with an id and amount.
recipe->timeThe factorio time to produce the object
recipe->yieldThe amount of the product produced by this recipe

Addtional Notes

Here is a list of exceptions to take note of in the database:

  • Ores and liquids are recipes. Copper, Iron, Stone, Coal, Crude oil, Steam, etc are recipes that have no ingredients and their time and yield are both null. This is to allow recursive algorithms to have a base case to stop at but still have some object to reach.

Tips & Tricks

  • The database can be recursively traced like a tree. For all recipes, the leaf nodes of the recipe tree will always end at an Resource or Liquid type. See the build-ci for a tool or example of how to accomplish this.
  • More coming soon...
0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago