Factorio Runtime Docs


In general, the Factorio API consists of 3 phases:

  • The settings stage is used to set up mod configuration options. The mod settings are documented on the wiki: Tutorial:Mod settings
  • The data stage is used to set up the prototypes of everything in the game. The prototypes are documented on the wiki: Prototype definitions
  • The third stage is runtime scripting. The classes and events used in this phase are documented here on this website.

For more information about how mods are loaded, initialized, and the different phases, see Data Lifecycle.

All of the scripting API functionality is implemented via class members. To make any use of the API, therefore, you need to have access to instances of these classes. To facilitate that, some are provided as global classes.

Global classes:

  • game :: LuaGameScript:

    This is the main object, through which most of the API is accessed. It is, however, not available inside handlers registered with LuaBootstrap::on_load.

  • script :: LuaBootstrap:

    Provides an interface for registering event handlers.

  • remote :: LuaRemote:

    Allows inter-mod communication by way of providing a repository of interfaces that is shared by all mods.

  • commands :: LuaCommandProcessor:

    Allows registering custom commands for the in-game console accessible via the grave key.

  • settings :: LuaSettings:

    Allows reading the current mod settings.

  • rcon :: LuaRCON:

    Allows printing messages to the calling RCON instance if any.

  • rendering :: LuaRendering:

    Allows rendering of geometric shapes, text and sprites in the game world.

Other global objects:

  • global: The global dictionary, useful for storing data persistent across a save-load cycle.
  • Defines: Contents of the defines table, which contains symbolic constants used throughout the API.
  • Libraries and functions: General libraries and functions that Factorio provides or changes.

The following data types are used across the API:

The API documentation is also available in a machine-readable format that developer tools can use.





Builtin types