Concepts

Commonly used conventions for passing data between mods and Factorio
type Position
type Vector
type BoundingBox
type Color
struct GameViewSettings
showcontrollergui :: boolean [RW] Show the controller GUI elements.
showminimap :: boolean [RW] Show the chart in the upper right-hand corner of the screen.
showresearchinfo :: boolean [RW] Show research progress and name in the upper right-hand corner of the screen.
showentityinfo :: boolean [RW] Show overlay icons on entities.
showalertgui :: boolean [RW] Show the flashing alert icons next to the player's toolbar.
updateentityselection :: boolean [RW] When true (the default), mousing over an entity will select it.
struct TileProperties
tier_from_start :: double [RW]
roughness :: double [RW]
elevation :: double [RW]
available_water :: double [RW]
temperature :: double [RW]
type MapSettings
type Ingredient
type Product
type Loot
type Modifier
type AutoplaceSpecification
type Resistances
type MapGenFrequency
type MapGenSize
type MapGenRichness
type MapGenSettings
type SignalID
type CircuitCondition
type Filter
type SimpleItemStack
type Command
type SurfaceSpecification
type TrainSchedule
type GuiArrowSpecification

Position

Positions may be specified either as a dictionary with x, y as keys, or simply as an array with two elements.

Example
{10, 20}
Example
{x = 50, y = 20}
{y = 20, x = 50}

Vector

A vector is a two-element array containing the x and y components. Unlike Positions, vectors don't use the x, y keys.

Example
right = {1.0, 0.0}

BoundingBox

Two positions, specifying the top-left and bottom-right corner of the box, respectively. Like with Position, the names of the members may be omitted. Members:

Example
Explicit specification:
{left_top = {-2, -3}, right_bottom = {5, 8}}
Shorthand:
{{-2, -3}, {5, 8}}

Color

Red, green, blue and alpha values, all in range [0, 1]. All values here are optional; colour channels default to 0, the alpha channel defaults to 1. Unlike Position, Color does not allow the short-hand notation of passing an array. Members:

Example
red1 = {r = 1, g = 0, b = 0, a = 0.5}  -- Half-opacity red
red2 = {r = 1, a = 0.5}                -- Same colour as red1
black = {}                             -- All channels omitted: black
not_a_color = {1, 0, 0, 0.5}           -- Actually also black: None of r, g, b have been specified

GameViewSettings

Parameters that affect the look and control of the game. Updating any of the member attributes here will immediatelly take effect in the game engine.

showcontrollergui :: boolean [Read-Write]

Show the controller GUI elements. This includes the toolbar, the selected tool slot, the armour slot, and the gun and ammunition slots.

showminimap :: boolean [Read-Write]

Show the chart in the upper right-hand corner of the screen.

showresearchinfo :: boolean [Read-Write]

Show research progress and name in the upper right-hand corner of the screen.

showentityinfo :: boolean [Read-Write]

Show overlay icons on entities. Also known as "alt-mode".

showalertgui :: boolean [Read-Write]

Show the flashing alert icons next to the player's toolbar.

updateentityselection :: boolean [Read-Write]

When true (the default), mousing over an entity will select it. Otherwise, moving the mouse won't update entity selection.

TileProperties

Properties of a tile. Updating any of the member attributes here will immediatelly take effect in the game engine.

tier_from_start :: double [Read-Write]

roughness :: double [Read-Write]

elevation :: double [Read-Write]

available_water :: double [Read-Write]

temperature :: double [Read-Write]

MapSettings

Various game-related settings. See data/base/prototypes/map-settings.lua for a description of all attributes. Updating any of the attributes will immediately take effect in the game engine.

Example
Increase the number of short paths the pathfinder can cache.
game.map_settings.path_finder.short_cache_size = 15

Ingredient

An ingredient is a table

Product

Table with the following fields:

Example
Products of the "steel-chest" recipe (an array of Product)
{{type="item",name="steel-chest",amount=1}}
Example
Products of the "advanced-oil-processing" recipe
{{type="fluid", name="heavy-oil", amount=1},
 {type="fluid", name="light-oil", amount=4.5},
 {type="fluid", name="petroleum-gas", amount=5.5}}
Example
What a custom recipe would look like that had a probability of 0.5 to return a minimum amount of 1 and a maximum amount of 5
{{type="item",name="custom-item", probability=0.5, amount_min=1, amount_max=5}}
See also

Loot

Loot is an array of loot items. Each loot item is a table:

Modifier

The effect that is applied when a technology is researched. It is a table that contains at least the field type. A modifier may also have other fields depending on the type.

AutoplaceSpecification

Table with the following fields:

Resistances

Dictionary of resistances toward each damage type. It is a dictionary indexed by damage type names (see data/base/prototypes/damage-type.lua). Each resistance is a table:

MapGenFrequency

It is a string specifying frequency. Possible values are

MapGenSize

It is a string specifying size. Possible values are

MapGenRichness

A string specifying richness. Possible values are

MapGenSettings

Table with the following fields:

SignalID

Table with the following fields:

CircuitCondition

Table with the following fields:

Filter

Table with the following fields:

SimpleItemStack

An item stack may be specified either as a string (in which case it represents a stack containing just 1 of the specified item), or as the following table:

Example
All of these lines specify an item stack of one iron plate:
"iron-plate"
{name="iron-plate"}
{name="iron-plate", count=1}
Example
This is a stack of 47 copper plates:
{name="copper-plate", count=47}

Command

Commands can be given to enemies and unit groups. It is a table:

SurfaceSpecification

A surface may be specified in one of three ways.

TrainSchedule

Table with the following fields:

GuiArrowSpecification

Used for specifying where a GUI arrow should point to. It is a table: