Factorio Standard Library

by Kryzeth

Unofficial fork of the Factorio Standard Library, which was a project to bring Factorio modders high-quality, commonly-required utilities and tools. Compatibility with older mods which relied on the original stdlib mod is not guaranteed.

Internal
3 days ago
2.0 - 2.1
96.7K

FAQ

How to use

From within your mod, add a require line for each module you wish to use at the top of each file where you plan to use them.
These are some of the most common modules used during data, data-updates, and data-final-fixes:

local Data = require('__kry_stdlib__/stdlib/data/data')
local Item = require('__kry_stdlib__/stdlib/data/item')
local Recipe = require('__kry_stdlib__/stdlib/data/recipe')
local Tech = require('__kry_stdlib__/stdlib/data/technology')
local Entity = require('__kry_stdlib__/stdlib/data/entity')
local Setting = require('__kry_stdlib__/stdlib/data/mod-setting')

These can only be used when Space Age is enabled:

local Planet = require('__kry_stdlib__/stdlib/data/planet')
local Location = require('__kry_stdlib__/stdlib/data/space-location')
local Connection = require('__kry_stdlib__/stdlib/data/space-connection')

These are all considered "wrappers" for Factorio data.raw objects of the same type. For example, these two definitions are generally equivalent:

Recipe("iron-gear-wheel")
data.raw.recipe["iron-gear-wheel"]

In both cases, you can access their fields directly, the biggest difference is the additional functionality
Instead of modifying the ingredients table directly, it can be accessed more safely

data.raw.recipe["iron-gear-wheel"].ingredients = {{name="iron-plate",amount=2,type='item"}}
Recipe("iron-gear-wheel"):set_ingredient_amount("iron-plate", 2)