<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.factorio.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xorimuth</id>
	<title>Official Factorio Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.factorio.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xorimuth"/>
	<link rel="alternate" type="text/html" href="https://wiki.factorio.com/Special:Contributions/Xorimuth"/>
	<updated>2026-08-20T20:01:05Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Tutorial:Modding_tutorial/Gangsir&amp;diff=211916</id>
		<title>Tutorial:Modding tutorial/Gangsir</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Tutorial:Modding_tutorial/Gangsir&amp;diff=211916"/>
		<updated>2025-02-27T16:18:42Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: Remove obsolete migration text, clarify surrounding text.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
This is a modding tutorial for Factorio version 2.0. In this tutorial, the author will explain how Factorio works behind the scenes, how to modify Factorio, where to find documentation, and explain concepts.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
Before we start the tutorial, a few things to note:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#AAFFAA!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
Code tinted green like this should be included into the mod this tutorial is going to create; If the reader follows along with it. The best way to do this is to copy and paste, to ensure faithful reproduction.&lt;br /&gt;
Whenever code is added to the mod, a Lua comment with the file name will be at the beginning of the green box. Place the code in the box into that file. Eg:&lt;br /&gt;
--control.lua&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
Code tinted purple like this should not be included into the mod, it&#039;s just for educational/example purposes, and to boost understanding.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This tutorial was updated to version 2.0, so any &#039;&#039;viewers in the future should take note that some minor changes may have been made&#039;&#039;, and should look at the changelogs up to the current version.&lt;br /&gt;
&lt;br /&gt;
== Terminology used in modding ==&lt;br /&gt;
&lt;br /&gt;
Before we start the tutorial, a few terms and definitions should be laid out, to ensure the reader understands.&lt;br /&gt;
&lt;br /&gt;
; Mod : A script or series of scripts that allow modifications to the game through the API.&lt;br /&gt;
; Entity : An entity in Factorio is anything in the game that is not a concept, event, or tile. Examples of entities include the character, an assembling machine, a biter, etc. This can be &#039;machines&#039; or free-moving objects like the character.&lt;br /&gt;
; Character : The actual entity that the player manipulates the world through.&lt;br /&gt;
; Player : All the data that defines a player, such as username, online time or the current zoom level.&lt;br /&gt;
; Prototype : A prototype describes an instance of an entity, item or recipe etc, a bit like a template. It defines stats, like what an entity actually is, an item&#039;s stack size, a recipe&#039;s ingredients etc. A prototype is used to create an instance of an entity/item/etc, and many functionally identical entities/items/etc will use the same prototype.&lt;br /&gt;
; Surface : A surface is a bit like a dimension. It is composed of terrain, such as grass, sand, and water, and all the entities on the surface. By default, there is only one surface in Factorio, referred to internally as &amp;quot;nauvis&amp;quot;, or &amp;lt;code style=&amp;quot;background-color:#DDA0DD; color:black&amp;quot;&amp;gt;game.surfaces[1]&amp;lt;/code&amp;gt;, but mods may create additional surfaces through the API.&lt;br /&gt;
; Event : An event is a recurring...event, that is triggered internally by the game. There are several events that mods may connect functions to, such as &amp;lt;code style=&amp;quot;background-color:#DDA0DD; color:black&amp;quot;&amp;gt;on_entity_died&amp;lt;/code&amp;gt;, etc. More on this in the control scripting section.&lt;br /&gt;
; Item : Items are what is moved around in inventories, by inserters and on belts, etc. Each item in-game is an instance of the respective item prototype.&lt;br /&gt;
&lt;br /&gt;
More terminology may be declared and defined later in this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Before beginning to mod ==&lt;br /&gt;
&lt;br /&gt;
Before we can start modding Factorio, we must understand what Factorio is. You may be tempted to answer in lieu of the [[Factorio:About|about page]], but that is what a player would say. Since we are trying to become a modder, we need a more detailed explanation. Factorio is a game that is coded in the language C++, with an API provided by Wube (the developers of Factorio) to mod Factorio in the programming language Lua (version 5.2.1). This API allows adding scripts to the Factorio init process, to modify it without the source code of the base game being exposed, or modifying memory. This may be different than other games that offer modding, but this is a more professional and proper way of supporting modding.&lt;br /&gt;
&lt;br /&gt;
To aid in the use of this API, the devs have kindly provided fairly comprehensive documentation of mods on at their [https://lua-api.factorio.com/latest/ API doc site]. Get used to using this site, as you will be frequently visiting it while you develop mods. The scripting API site contains information on [https://lua-api.factorio.com/latest/classes.html Factorio&#039;s classes] and information on [https://lua-api.factorio.com/latest/events.html events] that you can hook into. The [https://lua-api.factorio.com/latest/index-prototype.html prototype documentation] contains and links to information all around prototypes, listing their inheritance structure and their properties. You will need to check this site often, so the author recommends bookmarking it. In addition to this site, there are also many resources to be found created by the community, such as this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Setup ===&lt;br /&gt;
&lt;br /&gt;
The best way to develop a mod is to develop it in a place where it can be easily tested. When the tutorial gets to making the mod, this will be explained further. Additionally, using an editor that allows ease of typing and Lua language support is recommended. Emacs, Vim, Sublime Text, VSCode, and Notepad++ are all viable candidates.&lt;br /&gt;
&lt;br /&gt;
== How Factorio loads mods ==&lt;br /&gt;
&lt;br /&gt;
=== Load order ===&lt;br /&gt;
Within stages, mods are loaded by dependency, then by alphabetical order. This is &#039;&#039;very important&#039;&#039; to understand, as it can cause you problems if you neglect it and try to add inter-mod support to your mod.&lt;br /&gt;
&lt;br /&gt;
Factorio has three kinds of dependencies. There are required dependencies, and optional dependencies. The third kind, restrictive dependencies, does not affect mod order and instead prevents the game from loading if the other mod is found. Required dependencies are loaded first, always. The game will fail to initialize if one of these is not present. Optional dependencies are loaded first if present, but do not have to be present. This is useful for enabling bonus features if mods are used together. Required dependencies should be used for mod libraries, and similar infrastructure.&lt;br /&gt;
&lt;br /&gt;
=== The settings stage ===&lt;br /&gt;
The very first mod stage that is loaded when Factorio initializes is the settings stage. This stage is used to define all mod settings that are later shown in the in-game mod settings GUI, and has no other functions or possibilities. When running through this stage, the game looks through all mods for a file called &amp;lt;code&amp;gt;settings.lua&amp;lt;/code&amp;gt;. After settings.lua has been executed for all mods, each mod&#039;s &amp;lt;code&amp;gt;settings-updates.lua&amp;lt;/code&amp;gt; is executed, and finally each mod&#039;s &amp;lt;code&amp;gt;settings-final-fixes.lua&amp;lt;/code&amp;gt; is called. These 3 different phases of the settings stage allow to change settings of other mods without needing to rely on dependencies to load last. All other files to be loaded will need to be required. All the files run here should contain nothing but setting definitions and code to produce setting definitions.&lt;br /&gt;
&lt;br /&gt;
The settings stage does not have access to prototype or runtime data because it is loaded before those stages. The settings are expected to have a certain format, and all additional code will be discarded once the stage is over.&lt;br /&gt;
&lt;br /&gt;
Mod settings are not covered in this tutorial, see [[Tutorial:Mod settings]] for further info on them.&lt;br /&gt;
&lt;br /&gt;
=== The data stage ===&lt;br /&gt;
&lt;br /&gt;
This is the most restricted part of the Factorio init, there&#039;s not much you can do here other than declare prototypes for technologies, entities, items and more. Things like manipulating files, affecting the world, etc, are blocked/unavailable. In fact, any functions or changes made will be discarded, as the lua session is terminated. You also cannot mess with the data table, it will error or be ignored. When using &amp;lt;code&amp;gt;data:extend({})&amp;lt;/code&amp;gt;, it expects a specific format, more on this later.&lt;br /&gt;
&lt;br /&gt;
When running through this stage, the game looks through all mods for a file called &amp;lt;code&amp;gt;data.lua&amp;lt;/code&amp;gt;. After data.lua has been executed for all mods, each mod&#039;s &amp;lt;code&amp;gt;data-updates.lua&amp;lt;/code&amp;gt; is executed, and finally each mod&#039;s &amp;lt;code&amp;gt;data-final-fixes.lua&amp;lt;/code&amp;gt; is called. These 3 different phases of the data stage allow to change data of other mods without needing to rely on dependencies to load last. For example, the base mod creates barrelling recipes for all (then present) fluids in data-updates.lua. This means that if you add a fluid in data.lua, the base mod&#039;s data-updates.lua will add barreling recipes for it, regardless of whether your mod depends on base. Of course this also means that if you add a fluid in data-final-fixes.lua, it is created after the barrelling code runs in data-updates.lua, so no barrelling recipe gets created, even when desired. Because of this and similar mod interactions, it is recommended to create prototypes as early as possible. So, don&#039;t use data-final-fixes.lua to exclude a fluid from barreling, instead create it in data.lua and utilize &amp;quot;auto_barrel = false&amp;quot; on the fluid.&lt;br /&gt;
&lt;br /&gt;
All other files to be loaded will need to be required. All the files run here should contain nothing but prototype definitions and code to produce prototype definitions. More on requiring files later.&lt;br /&gt;
&lt;br /&gt;
All prototypes are documented on the modding API documentation website: [https://lua-api.factorio.com/latest/index-prototype.html Prototype documentation].&lt;br /&gt;
&lt;br /&gt;
=== Migrations ===&lt;br /&gt;
&lt;br /&gt;
[https://lua-api.factorio.com/latest/auxiliary/migrations.html Migrations] are scripts that are used to &amp;quot;fix&amp;quot; a save after a mod updates. Whenever prototype names change within a mod, migrations must be setup to replace all the old instances of the prototyped entity in the world. This must be done for all updated entities, or the old entities will be removed from the world, which is an unprofessional fallback that makes users dislike you. While this tutorial will not discuss migrations, there are many resources on migrations to be found around the community, and the API site.&lt;br /&gt;
&lt;br /&gt;
To avoid having to write migrations, avoid changing prototype names and technology unlocks after shipping the mod out to the public. Additionally, prototype names cannot be dynamically migrated because migrations are just a static list of names. Try to come up with a finalized version of prototype names that you can base the mod around. Of course, migrations are unnecessary if the user simply starts a new world with each mod update, but do not expect the community to do this.&lt;br /&gt;
&lt;br /&gt;
=== Runtime stage ===&lt;br /&gt;
&lt;br /&gt;
Within most mods is a file called &amp;lt;code&amp;gt;control.lua&amp;lt;/code&amp;gt;. This file contains scripting that makes the mod do things during the game, rather than just adding entities to the game. During this stage, each mod&#039;s control.lua is run, in it&#039;s own lua instance (this means no inter-communication without special setup) which it will own for the rest of the play session. During the play session, access to all tables provided by the game can be done inside of event handlers. (More on those below.) Because the control.lua is run every time a save file is created or loaded you don&#039;t need to restart the game to see changes made to the control.lua file. Simply restarting or reloading a save will re-run this stage. &#039;&#039;&#039;There are a few other caveats to this stage, reading the [https://lua-api.factorio.com/latest/auxiliary/data-lifecycle.html data life cycle] page on the API site provides the best overview.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The control stage documented is documented on [https://lua-api.factorio.com/latest/index-runtime.html lua-api.factorio.com].&lt;br /&gt;
&lt;br /&gt;
== The major components to any Factorio mod ==&lt;br /&gt;
&lt;br /&gt;
Within the average mod, there are several components that make the mod function.&lt;br /&gt;
&lt;br /&gt;
Mods that define new entities will need to declare these entities in &amp;lt;code&amp;gt;data.lua&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;data-updates.lua&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;data-final-fixes.lua&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Mods with in-game effects will also need a &amp;lt;code&amp;gt;control.lua&amp;lt;/code&amp;gt; file, to add scripting.&lt;br /&gt;
&lt;br /&gt;
Mods with configurable user settings will use &amp;lt;code&amp;gt;settings.lua&amp;lt;/code&amp;gt; to describe those settings.&lt;br /&gt;
&lt;br /&gt;
Mods that define any game element with a readable name may also provide a &amp;lt;code&amp;gt;locale&amp;lt;/code&amp;gt; directory and subdirectories with names/descriptions in one or more languages.&lt;br /&gt;
&lt;br /&gt;
The mod that we&#039;ll make in this tutorial will include both data.lua prototypes and control.lua scripting, to give you a feel for both.&lt;br /&gt;
&lt;br /&gt;
== The tutorial mod ==&lt;br /&gt;
&lt;br /&gt;
And now for the moment you&#039;ve been waiting for. Let&#039;s start making your first mod. You&#039;ll need:&lt;br /&gt;
&lt;br /&gt;
* A recent install of Factorio&lt;br /&gt;
* A text editor, such as Emacs, Vim, Sublime Text, VSCode, or Notepad++.&lt;br /&gt;
* An understanding of the tutorial above&lt;br /&gt;
* An understanding of Lua as a programming language. Enough to know the syntax and how it works. If you have prior programming experience, it should not be difficult to pick up.&lt;br /&gt;
&lt;br /&gt;
Once you have all of these things, we can begin.&lt;br /&gt;
&lt;br /&gt;
For this mod, we&#039;re going to make a set of armor that leaves behind damaging fire behind you as you walk. It will be fully resistant to fire, but weaker towards physical damage than heavy armor, making it an armor for hit and run attacks.&lt;br /&gt;
&lt;br /&gt;
=== Creation of the directory structure ===&lt;br /&gt;
&lt;br /&gt;
The game expects mod to be laid out [[Tutorial:Mod structure|in a certain way]]. To start out, create a folder in your [[Application directory|user data directory]]/mods folder. This folder must have a specific name, &amp;lt;code&amp;gt;fire-armor&amp;lt;/code&amp;gt;. You don&#039;t need to zip anything for now, that will come later when you&#039;re done working on the mod. When you&#039;re finished, the mod directory should look like this:&lt;br /&gt;
&lt;br /&gt;
* (user data directory, sometimes called .factorio)&lt;br /&gt;
** mods&lt;br /&gt;
*** fire-armor&lt;br /&gt;
&lt;br /&gt;
Then, inside fire-armor, create two files, &amp;lt;code&amp;gt;info.json&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;data.lua&amp;lt;/code&amp;gt;. The directory should now look like:&lt;br /&gt;
&lt;br /&gt;
* (user data directory, sometimes called .factorio)&lt;br /&gt;
** mods&lt;br /&gt;
*** fire-armor&lt;br /&gt;
**** data.lua&lt;br /&gt;
**** info.json&lt;br /&gt;
&lt;br /&gt;
=== The info.json file ===&lt;br /&gt;
&lt;br /&gt;
Then, inside [[Tutorial:Mod_structure#info.json|info.json]], copy and paste the following into it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#AAFFAA!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;fire-armor&amp;quot;,&lt;br /&gt;
  &amp;quot;version&amp;quot;: &amp;quot;0.1.0&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Fire Armor&amp;quot;,&lt;br /&gt;
  &amp;quot;author&amp;quot;: &amp;quot;You&amp;quot;,&lt;br /&gt;
  &amp;quot;factorio_version&amp;quot;: &amp;quot;2.0&amp;quot;,&lt;br /&gt;
  &amp;quot;dependencies&amp;quot;: [&amp;quot;base &amp;gt;= 2.0&amp;quot;],&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;This mod adds in fire armor that leaves behind damaging fire as you walk around.&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To explain each field:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Item&lt;br /&gt;
! Explanation&lt;br /&gt;
|-&lt;br /&gt;
| name&lt;br /&gt;
| This is the internal name of your mod, it is used to identify your mod in code.&lt;br /&gt;
|-&lt;br /&gt;
| version&lt;br /&gt;
| This is the version of your mod. This can be anything you want, provided it&#039;s a of the format &amp;quot;number.number.number&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| title&lt;br /&gt;
| The pretty title of your mod, this will be displayed on the mods screen and when you submit it to the mod portal.&lt;br /&gt;
|-&lt;br /&gt;
| author&lt;br /&gt;
| Your name! You can change this in the example above.&lt;br /&gt;
|-&lt;br /&gt;
| factorio_version&lt;br /&gt;
| This tells the game what version the mod is for, this must match the version you&#039;re developing the mod for, 2.0 in this case.&lt;br /&gt;
|-&lt;br /&gt;
| dependencies&lt;br /&gt;
| Any dependencies of your mod.&lt;br /&gt;
|-&lt;br /&gt;
| description&lt;br /&gt;
| A short description of your mod, which appears in game. The mod portal is better for a long description.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And that&#039;s all for info.json! &lt;br /&gt;
&lt;br /&gt;
=== Prototype creation ===&lt;br /&gt;
&lt;br /&gt;
Now, there are two ways to create prototypes in Factorio. There&#039;s the short way, and the long way. One way requires to create a complete prototype definition based on [https://lua-api.factorio.com/latest/index-prototype.html the documentation]. Another way uses a Lua function to copy and modify an already existing definition. For the sake of this tutorial, we&#039;ll do it both ways.&lt;br /&gt;
&lt;br /&gt;
In the data.lua file, copy and paste the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#AAFFAA!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
--data.lua&lt;br /&gt;
&lt;br /&gt;
local fireArmor = table.deepcopy(data.raw[&amp;quot;armor&amp;quot;][&amp;quot;heavy-armor&amp;quot;]) -- copy the table that defines the heavy armor item into the fireArmor variable&lt;br /&gt;
&lt;br /&gt;
fireArmor.name = &amp;quot;fire-armor&amp;quot;&lt;br /&gt;
fireArmor.icons = {&lt;br /&gt;
  {&lt;br /&gt;
    icon = fireArmor.icon,&lt;br /&gt;
    icon_size = fireArmor.icon_size,&lt;br /&gt;
    tint = {r=1,g=0,b=0,a=0.3}&lt;br /&gt;
  },&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
fireArmor.resistances = {&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;physical&amp;quot;,&lt;br /&gt;
    decrease = 6,&lt;br /&gt;
    percent = 10&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;explosion&amp;quot;,&lt;br /&gt;
    decrease = 10,&lt;br /&gt;
    percent = 30&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;acid&amp;quot;,&lt;br /&gt;
    decrease = 5,&lt;br /&gt;
    percent = 30&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;fire&amp;quot;,&lt;br /&gt;
    decrease = 0,&lt;br /&gt;
    percent = 100&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- create the recipe prototype from scratch&lt;br /&gt;
local recipe = {&lt;br /&gt;
  type = &amp;quot;recipe&amp;quot;,&lt;br /&gt;
  name = &amp;quot;fire-armor&amp;quot;,&lt;br /&gt;
  enabled = true,&lt;br /&gt;
  energy_required = 8, -- time to craft in seconds (at crafting speed 1)&lt;br /&gt;
  ingredients = {&lt;br /&gt;
    {type = &amp;quot;item&amp;quot;, name = &amp;quot;copper-plate&amp;quot;, amount = 200},&lt;br /&gt;
    {type = &amp;quot;item&amp;quot;, name = &amp;quot;steel-plate&amp;quot;, amount = 50}&lt;br /&gt;
  },&lt;br /&gt;
  results = {{type = &amp;quot;item&amp;quot;, name = &amp;quot;fire-armor&amp;quot;, amount = 1}}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
data:extend{fireArmor, recipe}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What we&#039;ve just done here is we&#039;ve copied the definition of the heavy armor item, then changed its properties, and injected it into the Factorio init with data:extend. The first line of code is probably the most interesting. &amp;lt;code&amp;gt;table.deepcopy&amp;lt;/code&amp;gt; copies a table fully into another table. We do this from data.raw. The &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; part is a table, which will be used by the game to setup the Factorio universe. In fact, it contains the function &amp;lt;code&amp;gt;extend(self, prototypes)&amp;lt;/code&amp;gt; and a table called &amp;lt;code&amp;gt;raw&amp;lt;/code&amp;gt;. The former is a customary way to add new stuff to the latter. It is actually data.raw that holds the prototypes for the game. (You can view the implementation in the file [https://github.com/wube/factorio-data/blob/master/core/lualib/dataloader.lua /factorio/data/core/lualib/dataloader.lua]). It is important to note that data.raw only exists during the data loading stage of the game. During the control stage, when the game is running and being played, you cannot read this data; instead you read processed values through the API from the various types like LuaEntityPrototype.&lt;br /&gt;
&lt;br /&gt;
In addition to defining the item prototype, we also define a recipe for it. This is necessary if you want to be able to craft the thing. We also set it to enabled so it doesn&#039;t need a technology to unlock.&lt;br /&gt;
&lt;br /&gt;
=== More on data.raw ===&lt;br /&gt;
&lt;br /&gt;
When Factorio initializes, all prototypes are put into a table called data.raw. This table holds all prototype types, and within those types, individual prototypes identified by name: &amp;lt;code&amp;gt;local prototype = data.raw[&amp;quot;prototype-type&amp;quot;][&amp;quot;internal-name&amp;quot;]&amp;lt;/code&amp;gt;. You saw earlier how we deepcopied from the definition of heavy armor, and modified some fields. In fact, let&#039;s go over each part of the deepcopy line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
local fireArmor = table.deepcopy(data.raw[&amp;quot;armor&amp;quot;][&amp;quot;heavy-armor&amp;quot;])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We assign a variable called fireArmor that holds our copy of the heavy armor definition. Notice how in data.raw, there is a type table that holds all armors, and the specific armor we&#039;re looking for is called heavy-armor. We can find [[heavy armor]]&#039;s prototype type and internal name in the infobox of its page on this wiki and just copy it from there.&amp;lt;br&amp;gt;&lt;br /&gt;
Alternatively, we can find the items prototype type and internal name by opening the game, inserting the item into our inventory and then pressing {{Keybinding|shift|ctrl|F}} while hovering over the item. This will open the prototype explorer GUI, which has rows showing the name and type of the item.&lt;br /&gt;
&lt;br /&gt;
As another example, the [[player|character]]&#039;s prototype would be, according to the infobox on the page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
data.raw[&amp;quot;character&amp;quot;][&amp;quot;character&amp;quot;]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because the character is &#039;&#039;the&#039;&#039; character, his type matches his name. You could define a new character with a mod. You can see all the available prototype fields of the character in the documentation: [https://lua-api.factorio.com/latest/prototypes/CharacterPrototype.html CharacterPrototype].&lt;br /&gt;
&lt;br /&gt;
You may be thinking at this point, &amp;quot;Can I modify Factorio&#039;s existing prototypes without making new ones?&amp;quot; Well, the answer is yes! You would simply access the data.raw table during init, in data-final-fixes.lua if you want to run after all other mods, and change a property. For example, make the iron chest instead have 1000 health:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
data.raw[&amp;quot;container&amp;quot;][&amp;quot;iron-chest&amp;quot;].max_health = 1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reason why this code is in data-final-fixes.lua is because that is the last file run, after all mod files have been run. This prevents (to a degree) your changes from being messed with by other mods. Of course, it is still possible to have incompatibilities. You should note any that you know of in your mod&#039;s description. Again, the [https://lua-api.factorio.com/latest/auxiliary/data-lifecycle.html dev&#039;s documentation] on this should be looked at.&lt;br /&gt;
&lt;br /&gt;
This can also be applied to other mods, not just Factorio&#039;s base. You could mod a mod, as long as you add the mod (that you modified with your mod) to your dependencies so it gets loaded first.&lt;br /&gt;
&lt;br /&gt;
=== The control scripting ===&lt;br /&gt;
&lt;br /&gt;
And now, to finalize the mod, we have to make it be more than just simple armor. Let&#039;s think about what we want the armor to do. We want the armor to create fire on the ground as we walk with the armor on. The event we&#039;re going to use is called [https://lua-api.factorio.com/latest/events.html#on_player_changed_position on_player_changed_position], since we want the fire to be created when the player moves.&lt;br /&gt;
&lt;br /&gt;
In our mod folder, create a file called &amp;lt;code&amp;gt;control.lua&amp;lt;/code&amp;gt;. The game will automatically execute this file, so requiring it is not necessary.&lt;br /&gt;
&lt;br /&gt;
Inside control.lua, copy and paste the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#AAFFAA!important; color:black;&amp;quot;&amp;gt;&lt;br /&gt;
--control.lua&lt;br /&gt;
&lt;br /&gt;
script.on_event(defines.events.on_player_changed_position,&lt;br /&gt;
  function(event)&lt;br /&gt;
    local player = game.get_player(event.player_index) -- get the player that moved            &lt;br /&gt;
    -- if they&#039;re currently controlling the character&lt;br /&gt;
    if player.controller_type == defines.controllers.character then&lt;br /&gt;
      -- and wearing our armor&lt;br /&gt;
      if player.get_inventory(defines.inventory.character_armor).get_item_count(&amp;quot;fire-armor&amp;quot;) &amp;gt;= 1 then&lt;br /&gt;
        -- create the fire where they&#039;re standing&lt;br /&gt;
        player.surface.create_entity{name=&amp;quot;fire-flame&amp;quot;, position=player.position, force=&amp;quot;neutral&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I&#039;ve used lua comments in the code above to explain each step. It&#039;s fairly easy to understand, and it shows how you would get the current armor that the player character is wearing, with defines.inventory.character_armor, which is an inventory constant. You can read the list of defines [https://lua-api.factorio.com/latest/defines.html#defines.inventory here].&lt;br /&gt;
&lt;br /&gt;
=== Locale ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve already tried loading up Factorio and trying the mod so far (which you can at this point without it crashing), you may have noticed that the item name of the armor says &amp;quot;Unknown key&amp;quot;. This means that Factorio has the internal name, but it doesn&#039;t know what it should look like to the user. So, we need to create a locale for our mod.&lt;br /&gt;
&lt;br /&gt;
In the mod folder, create a folder called &amp;lt;code&amp;gt;locale&amp;lt;/code&amp;gt;, then create another folder inside that called &amp;lt;code&amp;gt;en&amp;lt;/code&amp;gt;, then a file called &amp;lt;code&amp;gt;any_name_can_be_here.cfg&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you know another language, you can also translate your mod by making other language code files inside locale, such as de for German.&lt;br /&gt;
&lt;br /&gt;
Inside the .cfg file, paste the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#AAFFAA!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[item-name]&lt;br /&gt;
fire-armor=Fire armor&lt;br /&gt;
&lt;br /&gt;
[item-description]&lt;br /&gt;
fire-armor=An armor that seems to catch the ground itself on fire when you take a step. It&#039;s warm to the touch.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice how this is not a lua file. Locale is handled with C config files, so the format is different.&lt;br /&gt;
&lt;br /&gt;
== The finished tutorial mod ==&lt;br /&gt;
&lt;br /&gt;
Well, the mod is finished. Since this mod is only a tutorial, there isn&#039;t much balance to it.&lt;br /&gt;
&lt;br /&gt;
If you want to share a mod with other users, it needs to be a zip file. For that, simply zip the &amp;lt;code&amp;gt;fire-armor&amp;lt;/code&amp;gt; folder and then rename the archive to &amp;lt;code&amp;gt;fire-armor_0.1.0&amp;lt;/code&amp;gt; so that it follows the expected mod zip name pattern of &amp;lt;code&amp;gt;mod-name_version&amp;lt;/code&amp;gt;. Keep in mind to not submit this tutorial mod to the mod portal as your own, since it&#039;s from the Wiki.&lt;br /&gt;
&lt;br /&gt;
However, you&#039;re free to take this mod and modify it for your own use, changing recipes, adding technologies, whatever.&lt;br /&gt;
&lt;br /&gt;
== Extended learning ==&lt;br /&gt;
One of the best ways to learn how to mod beyond this is to look at other mods. The [[Tutorial:Inspecting a live mod]] is a good starting point for touring a particularly well-commented mod. As all mods can be opened and inspected, looking at the mods of experienced modders can help significantly when making your own mod.&lt;br /&gt;
&lt;br /&gt;
Something you&#039;ll see a lot in other mods or the base game are &amp;lt;code&amp;gt;require&amp;lt;/code&amp;gt; statements. These load other files, so you can split up long code files and organize your mod however you like.&lt;br /&gt;
&lt;br /&gt;
For example, if you wanted to put some of your data stage code into a file called &amp;quot;foo.lua&amp;quot; in a folder called &amp;quot;bar&amp;quot;, your mod folder would look like this:&lt;br /&gt;
&lt;br /&gt;
* fire-armor&lt;br /&gt;
** bar&lt;br /&gt;
*** foo.lua&lt;br /&gt;
** data.lua&lt;br /&gt;
** control.lua&lt;br /&gt;
** info.json&lt;br /&gt;
&lt;br /&gt;
And you would need to add this to data.lua:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
require(&amp;quot;bar.foo&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Keeping your mod working ===&lt;br /&gt;
As Factorio evolves, things will change. Previously, you probably ignored the modding part of the changelog, you now need to read it and see if any changes affect your mod(s). If so, you&#039;ll need to fix them. If there&#039;s something wrong with your mod, the game will fail to init and explain why.&lt;br /&gt;
&lt;br /&gt;
== Resolving common errors in modding ==&lt;br /&gt;
&lt;br /&gt;
As you continue to write mods from scratch instead of from a tutorial, you may encounter the infamous error. There are several types of errors that you can encounter in modding Factorio, and knowing how to deal with these errors will allow you to continue working.&lt;br /&gt;
&lt;br /&gt;
=== Syntax errors ===&lt;br /&gt;
&lt;br /&gt;
The Lua programming language expects things to be laid out a certain way. If you miss a bracket, = sign, or dot, you will encounter a syntax error. As an example, see the error below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
Failed to load mod &amp;quot;fire-armor&amp;quot;: __fire-armor__/data.lua:39: unfinished string near &#039;&amp;quot;fire-armor,&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You&#039;ll see an error like the one above whenever you make a syntax error within the prototype definitions. The game will offer to restart, disable the troubling mod, disable all mods, or exit. Let&#039;s dissect the error, shall we?&lt;br /&gt;
&lt;br /&gt;
Right away, we see the reason why Factorio didn&#039;t start normally. &amp;quot;Failed to load mod &amp;quot;fire-armor&amp;quot;:&amp;quot;. So, we know that it&#039;s our mod that messed up. Whenever the Lua engine of Factorio has a syntax error, it will print a mini stack-trace that follows through all requires, listing the call order. First, we see that the problem was caused by line 39 of data.lua. After stating where it is line-wise, it will attempt to give you an estimate of where in the line the problem is. Don&#039;t trust this estimate, only roughly trust the line number, plus or minus a few lines.&lt;br /&gt;
&lt;br /&gt;
Going to line 39 of data.lua, we find:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
  name = &amp;quot;fire-armor,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hmm, that doesn&#039;t look right. Can you see what&#039;s missing? We left off an &amp;quot; after armor before the comma. Thus, syntax error. Fixing these can be difficult for new programmers, who don&#039;t know what to look for.&lt;br /&gt;
&lt;br /&gt;
=== Illogical actions, indexing nil ===&lt;br /&gt;
&lt;br /&gt;
In lua, &amp;quot;nothing&amp;quot; is defined as the keyword nil. This is similar to null in other programming languages. Whenever the programmer tries to access something in a table that is nil, they will get an error like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
Error while running event fire-armor::on_player_changed_position (ID 82)&lt;br /&gt;
__fire-armor__/control.lua:3: attempt to index field &#039;?&#039; (a nil value)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;attempt to index field ...&amp;quot; error is often caused by the modder making an assumption that didn&#039;t work out. These types of errors will always be identifiable by their signature line, &amp;quot;attempt to index field&amp;quot;. If we look at line 3 of control.lua (where the error is), we see:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
game.print(game.players[23])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What assumption has the modder made here? Well, there&#039;s actually two problems with this line. The first thing is that the modder has assumed that &amp;lt;code&amp;gt;game.players[23]&amp;lt;/code&amp;gt; is a valid player, which isn&#039;t the case; this is why we get the &amp;quot;index field &#039;?&#039;&amp;quot; bit. The game doesn&#039;t know what the field is that we tried to index, because it hasn&#039;t been created yet. These errors are difficult to debug unless you know the ins and outs of the modding API well.&lt;br /&gt;
&lt;br /&gt;
The second issue is a lot more subtle, and won&#039;t work. The modder is attempting to print a userdata table. [https://lua-api.factorio.com/latest/LuaPlayer.html A player] is a table of several values. Trying to print it simply print &amp;quot;LuaPlayer&amp;quot; instead of providing useful data.&lt;br /&gt;
&lt;br /&gt;
=== Error while running event ===&lt;br /&gt;
&lt;br /&gt;
Another common type of error in Factorio is the &amp;quot;Error while running event&amp;quot; error. This type of error only happens in control.lua scripting, and it happens when something goes wrong in an event function, such as a syntax error. &#039;&#039;&#039;Note that syntax errors in control.lua do not stop the game from starting, but may trigger after a save is loaded&#039;&#039;&#039;. There are a great deal of errors under this broad category, here&#039;s an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
Error while running event fire-armor::on_player_changed_position (ID 82)&lt;br /&gt;
Unknown entity name: fire-flam&lt;br /&gt;
stack traceback:&lt;br /&gt;
__fire-armor__/control.lua:7: in function &amp;lt;__fire-armor__/control.lua:2&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you saw with the prototypes syntax error, Factorio gives a small traceback and the error name itself. In this case, we&#039;ve attempted to spawn an entity called &amp;quot;fire-flam&amp;quot; on line 7 of control.lua, inside of an on_player_changed_position event hook. Fire-flam isn&#039;t a real entity type, so we crashed.&lt;br /&gt;
&lt;br /&gt;
These types of errors can range from being a simple fix (like the one above, add the missing e), or can be very difficult.&lt;br /&gt;
&lt;br /&gt;
=== Internal errors ===&lt;br /&gt;
&lt;br /&gt;
The most rare form of error and the worst form is the internal error. This is an error with the C++ code of the game, and there&#039;s nothing you can do but report it to the devs. Mods occasionally cause these, and almost all of them are considered bugs, as mods &#039;&#039;should not&#039;&#039; be able to cause these, if that makes sense. They often get thrown into the logs.&lt;br /&gt;
&lt;br /&gt;
An example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
696.148 Error FlowStatistics.cpp:236: FlowStatistics attempted to save value larger than uint16 as uint16. Exiting to prevent save corruption.&lt;br /&gt;
Logger::writeStacktrace skipped.&lt;br /&gt;
696.148 Error CrashHandler.cpp:190: Map tick at moment of crash: 432029&lt;br /&gt;
696.148 Error Util.cpp:97: Unexpected error occurred. If you&#039;re running the latest version of the game you can help us solve the problem by posting the contents of the log file on the Factorio forums.&lt;br /&gt;
Please also include the save file(s), any mods you may be using, and any steps you know of to reproduce the crash.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Multiplayer and desyncs ==&lt;br /&gt;
&lt;br /&gt;
The reader may be wondering at this point how Factorio handles multiplayer with mods. It&#039;s fairly simple, but is still worth considering.&lt;br /&gt;
&lt;br /&gt;
Factorio is [https://en.wikipedia.org/wiki/Deterministic_algorithm deterministic], which means that when you provide a constant input, you get a constant output, with no variance. Every client and the server all reach the same points at the same time in simulation, so they all agree on what happened. When this differs, the players experience a &#039;&#039;desync&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
; Desync : Misalignment with server and clients. Client 1 expected A, but got B. All other clients got A. Thus, Client 1 will desync. Desync can also happen when all clients have information (for example a variable) but a client that recently joined the game doesn&#039;t. That client will be desynced.&lt;br /&gt;
: &#039;&#039;See also: [[Desynchronization]]&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Desyncs happen a lot to new devs of Factorio mods, because they are unaware that a particular piece of code they used causes desyncs. As a general rule, there are a few things that should never be done.&lt;br /&gt;
&lt;br /&gt;
=== Use local variables that are not final outside of event hooks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
local globalLocal = 1&lt;br /&gt;
script.on_event(defines.events.on_player_built_item, function()&lt;br /&gt;
    globalLocal = math.random()&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the modder places a local variable outside of an event hook that gets changed during runtime, desyncs will happen when that variable is utilised to modify the game state (i.e. manipulate an entity, print text to players). If making a &amp;quot;global&amp;quot; variable is necessary, place the variable in the [https://lua-api.factorio.com/latest/auxiliary/storage.html storage] table instead. The game syncs this table between all clients, so they can all be aware of and reach the same conclusion as each other.&lt;br /&gt;
&lt;br /&gt;
=== Conditional event subscribing ===&lt;br /&gt;
&lt;br /&gt;
Mods in factorio may subscribe to events in order to be notified when they happen. This allows mods to react to events when they occur. Typically, event subscription is done at the top level of a lua file. &lt;br /&gt;
&lt;br /&gt;
Doing event subscription inside of a conditional, function, or other event is dangerous, as doing it incorrectly will lead to desyncs. Basically, since both the server and client need to reach the same conclusion after running code, conditional subscription can lead to certain clients or the server being subscribed to an event when the others are not, causing desyncs. &lt;br /&gt;
&lt;br /&gt;
=== Improper use of on_load ===&lt;br /&gt;
&lt;br /&gt;
Another way to cause desyncs is to make improper actions inside of an on_load call, which some players new to modding might try to do. According to the [https://lua-api.factorio.com/latest/LuaBootstrap.html#LuaBootstrap.on_load documentation], the on_load functionality is meant for 3 purposes &#039;&#039;&#039;only&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* Re-register conditional event handlers&lt;br /&gt;
* Re-setup meta tables&lt;br /&gt;
* Create local references to tables stored in the storage table&lt;br /&gt;
&lt;br /&gt;
Doing anything else will cause desyncs. The game will catch most attempts, crashing instead and terminating the mod.&lt;br /&gt;
&lt;br /&gt;
=== Comparison by reference ===&lt;br /&gt;
&lt;br /&gt;
Be cautious of comparing tables by reference. In multiplayer syncing, tables deserialized from the server state will be new objects, not equal by reference to any table initialized by client code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
if a == b then&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
if a ~= b then&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; are tables in the above conditionals, there will for example be different results between server and client if &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; is created locally and &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; is downloaded from the server.&lt;br /&gt;
&lt;br /&gt;
Note that LuaObjects provided by the game have their equality operator overwritten to prevent this behaviour, so code such as &amp;lt;code&amp;gt;LuaEntityA ~= LuaEntityB&amp;lt;/code&amp;gt; will not desync.&lt;br /&gt;
However, this does not apply when LuaObjects are used as keys in tables:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
if table[LuaObject] then&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will desync in the same way as described for the plain tables &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; above. For entities it is recommended to use [https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.unit_number LuaEntity.unit_number] as the table key instead of the whole entity.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Modding]]&lt;br /&gt;
* [[Tutorial:Modding tutorial|Modding tutorial overview]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Modding]]&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Tutorial:Modding_tutorial&amp;diff=211915</id>
		<title>Tutorial:Modding tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Tutorial:Modding_tutorial&amp;diff=211915"/>
		<updated>2025-02-27T14:03:44Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: Warn that &amp;quot;Inspecting a live mod&amp;quot; tutorial is 1.1-based.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These tutorials range from teaching the first steps of modding to in-depth explanations of individual mechanics:&lt;br /&gt;
&lt;br /&gt;
* [[Tutorial:Modding tutorial/Gangsir|Modding tutorial/Gangsir]] — A simple modding tutorial that suits beginners well.&lt;br /&gt;
* [[Tutorial:Mod structure|Mod structure]] — More details on how mods need to be structured in order to be loaded by the game.&lt;br /&gt;
* [[Tutorial:Scripting|Scripting]] — A small tutorial that focuses on run-time scripting and provides some info on how to use the story script.&lt;br /&gt;
* [[Tutorial:Mod settings|Mod settings]] — A comprehensive tutorial about how to create and use mod settings.&lt;br /&gt;
* [[Tutorial:Localisation|Localisation]] — A tutorial about how to format and use localisation, which is how mods are translated.&lt;br /&gt;
* &amp;lt;s&amp;gt;[[Tutorial:Inspecting a live mod|Inspecting a live mod]] — An annotated tour of a mod that is live on the mod portal right now.&amp;lt;/s&amp;gt; (Beware that this uses the 1.1 API, so many examples will not work in 2.0+ without modifications)&lt;br /&gt;
* [[Tutorial:Mod changelog format|Mod changelog format]] — The formatting requirements for the mod changelog.txt file.&lt;br /&gt;
* [[Tutorial:Script interfaces|Script interfaces]] — A small tutorial about script interfaces ([https://lua-api.factorio.com/latest/classes/LuaRemote.html LuaRemote]) and custom keyboard shortcuts.&lt;br /&gt;
* &amp;lt;s&amp;gt;[https://togos.github.io/togos-example-noise-programs/ Noise Expressions] — A tutorial about generating terrain, complete with [https://mods.factorio.com/mod/togos-example-noise-programs example mod].&amp;lt;/s&amp;gt; (Shows the 1.1 format which has significantly changed for 2.0)&lt;br /&gt;
* [https://github.com/ClaudeMetz/UntitledGuiGuide/wiki Untitled GUI Guide] — A tutorial about building custom interfaces that also expands into more advanced parts of GUI modding.&lt;br /&gt;
* [https://forums.factorio.com/106661 Controller modding guide / FAQ] — A guide about building your mod to support controllers (game pads).&lt;br /&gt;
&lt;br /&gt;
=== Additional info ===&lt;br /&gt;
* [https://lua-api.factorio.com/latest Modding API docs] - Overview page of the modding API documentation website&lt;br /&gt;
** [https://lua-api.factorio.com/latest/index-prototype.html Prototype documentation]&lt;br /&gt;
** [https://lua-api.factorio.com/latest/index-runtime.html Documentation of the runtime API]&lt;br /&gt;
* [[Scenario system]] — Save-based mods (&amp;quot;soft mods&amp;quot;) and their limitations&lt;br /&gt;
* [https://lua-api.factorio.com/latest/auxiliary/migrations.html Migrations guide] — All information about mod migrations&lt;br /&gt;
* [https://github.com/wube/factorio-data Factorio data github repository] — Tracks changes of the lua prototype definitions in Factorio in between releases&lt;br /&gt;
* [[Tutorial:Modding FAQ|Modding FAQ]]&lt;br /&gt;
&lt;br /&gt;
=== Third-Party Tools ===&lt;br /&gt;
There is a wide variety of tools contributed by community members to help in mod development, such as plugins for IDEs to provide auto-completion, debuggers, as well as scripts to automate common tasks regarding translations or packaging.&lt;br /&gt;
&lt;br /&gt;
* [https://forums.factorio.com/viewforum.php?f=135 Factorio sub-forum for mod development tools]&lt;br /&gt;
&amp;lt;noinclude&amp;gt;{{Languages}}&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Tutorials]]&lt;br /&gt;
* [[Modding]]&lt;br /&gt;
* [[:Category:Technical]] — Documentation of technical formats and API&#039;s not related to modding&lt;br /&gt;
&lt;br /&gt;
[[Category:Modding]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Tutorial:Modding_FAQ&amp;diff=211914</id>
		<title>Tutorial:Modding FAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Tutorial:Modding_FAQ&amp;diff=211914"/>
		<updated>2025-02-27T14:00:53Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: Fix broken links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
This is a list of common questions asked by new mod makers. Feel free to edit and update with new questions and answers.&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
General note: Errors give you either a line info or at least a reference as to where the error occurred. If a line is specified, then the odds are high that the mistake actually happened on one of the previous lines. Try to check for common errors like missing a comma while defining an array or writing data.extend instead of data:extend beforehand.&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;C:\Factorio\mod doesn&#039;t match the expected mod_version# (case sensitive!)&amp;quot; ===&lt;br /&gt;
The folder name of your mod must include the version number, and name of the mod separated by an underscore. So if your mod is titled &amp;quot;myMod&amp;quot; version 0.0.1, in order for Factorio to read it, the folder must be titled &amp;quot;myMod_0.0.1&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;attempt to index a nil value&amp;quot; ===&lt;br /&gt;
This is a Lua error that means the mod is trying to access a value that doesn&#039;t exist. Similar to a Null Pointer in other programming languages, you&#039;re trying to access something that doesn&#039;t exist. This happens most often with accessing Factorios custom Lua tables, and trying to access a var that doesn&#039;t exist within that table.&lt;br /&gt;
This also happens with developers experienced in other programming languages that forget that Lua tables are indexed from &#039;&#039;&#039;1&#039;&#039;&#039;, not 0. Table[0] doesn&#039;t exist by default in Lua.&lt;br /&gt;
&lt;br /&gt;
=== Failed to load mods: Error while loading prototype &amp;quot;prototype-name&amp;quot; (prototype-type): Key &amp;quot;property-name&amp;quot; not found in property tree at ROOT.prototype-type.prototype-name ===&lt;br /&gt;
Your prototype with the name &amp;lt;code&amp;gt;prototype-name&amp;lt;/code&amp;gt; and type &amp;lt;code&amp;gt;prototype-type&amp;lt;/code&amp;gt; is missing the &amp;lt;code&amp;gt;property-name&amp;lt;/code&amp;gt; property. You need to add it to make it possible for the game to load.&lt;br /&gt;
&lt;br /&gt;
== Problems ==&lt;br /&gt;
=== My item / entity wont load the sprite I made. ===&lt;br /&gt;
Make sure your path is right : __mod-name__/folder-name/2nd-folder-name/sprite.png. Pay attention to case, the following file is not the same as previous: __Mod-name__/Folder-name/2nd-folder-name/sprite.PNG. Also note that Factorio is only capable of loading png files for icons and entity textures.&lt;br /&gt;
&lt;br /&gt;
=== The name of my item is displayed as &amp;quot;Unknown key: item-name.yourname&amp;quot; ===&lt;br /&gt;
Make sure you have valid locale mappings. Create a &amp;quot;locale&amp;quot; directory with an &amp;quot;en&amp;quot; sub-directory and create a &amp;quot;item-name.cfg&amp;quot; file. It should contains something like:&lt;br /&gt;
  [item-name]&lt;br /&gt;
  itemx=Item X&lt;br /&gt;
  itemy=Item Y&lt;br /&gt;
&lt;br /&gt;
Make sure there are no spaces before or after the &amp;lt;code&amp;gt;=&amp;lt;/code&amp;gt;. Do the same for your entities, but put them in an &#039;&#039;[entity-name]&#039;&#039; section/file.&lt;br /&gt;
For each &#039;&#039;[xxx-name]&#039;&#039; section you should preferably also add a section &#039;&#039;[xxx-description]&#039;&#039;, which will then display as description when you hover over the corresponding item/entity/technology/mod-setting&lt;br /&gt;
&lt;br /&gt;
=== I&#039;m trying to change the attributes of a vanilla entity, but it&#039;s not working! ===&lt;br /&gt;
If there are other mods installed in your dev environment, it&#039;s possible that their changes are overwriting yours. (A good find if this is true, because this is an incompatibility!) To fix, you need to add the mod that&#039;s doing it (up to you to find) as an &#039;&#039;optional&#039;&#039; dependency, so it gets loaded first. This ensures that your changes overwrite theirs.&lt;br /&gt;
&lt;br /&gt;
Be careful though, if the mod in question is expecting it&#039;s changes to stick, you could break the mod. If so, this means that your mod is permanently incompatible with that mod, so you should declare that fact in your mod&#039;s description and in the dependencies by listing the mod with a &amp;lt;code&amp;gt;!&amp;lt;/code&amp;gt; in front:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;dependencies&amp;quot;: [&amp;quot;base&amp;quot;, &amp;quot;? optional-dependency &amp;gt;=0.13.1&amp;quot;, &amp;quot;! incompatible-mod&amp;quot;]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== My mod does not show up in game ===&lt;br /&gt;
Your info.json has a problem/doesn&#039;t exist. Make sure you have a info.json file in the root folder of your mod, that it has the right file extension (.json), and the right factorio_version. The json also does not allow trailing commas in lists, the game will print that error to the [[log file]] and refuse to load the mod until you fix it. Other errors such as wrong format for dependenciescan also be found in the log file.&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
=== How do I store information with an entity, like integers or booleans? ===&lt;br /&gt;
Factorio&#039;s API ensures that modders use the proper way to do things, to reduce the possible instability arising from modders doing strange workarounds. The proper way to store data with an entity is to use a table in the [https://lua-api.factorio.com/latest/auxiliary/storage.html storage table] that contains the entity and information. If you then need to access it, you can write code to get the value out of the table that corresponds to the entity. It isn&#039;t possible to store data on an entity in any other way, either in the control stage or data stage. Some entity types do have space for variables, as of 0.15.&lt;br /&gt;
&lt;br /&gt;
=== How do I make an entity store/consume energy even if it wasn&#039;t made to? ===&lt;br /&gt;
Use of the &amp;lt;code&amp;gt;electric energy interface&amp;lt;/code&amp;gt; allows for arbitrary electricity handling. You will need to spawn this entity on top of yours, and clean it up when your entity is destroyed. Scripting is also necessary to gate the entity&#039;s functions behind energy requirements.&lt;br /&gt;
&lt;br /&gt;
=== How can I disable a recipe with scripting? ===&lt;br /&gt;
Simple, just set it&#039;s &amp;lt;code&amp;gt;enabled&amp;lt;/code&amp;gt; tag to false. An item&#039;s recipe can be obtained through its prototype.&lt;br /&gt;
&lt;br /&gt;
=== How do I declare a dependency of my mod? ===&lt;br /&gt;
This is done in the info.json file of your mod. Under the dependency field, simply place the &#039;&#039;internal name&#039;&#039; (Not the pretty title!) of the mod you want to declare as a dependency. It is a json table, so multiple can be defined. If you want to declare it as an optional dependency, then put a question mark and space before the name. To define a minimum version, simply put a logic operator, such as &amp;gt;=, and a version. As an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;dependencies&amp;quot;: [&amp;quot;? MAIN-DyTech-Machine&amp;quot;, &amp;quot;? CORE-DyTech-Core&amp;quot;, &amp;quot;bobenemies&amp;gt;=0.13.1&amp;quot;, &amp;quot;bobores&amp;quot;, &amp;quot;? 5dim_ores&amp;quot;],&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Be careful with required dependencies, as they will cause your mod to be disabled if they are unmet or ill-defined. Dependencies also cannot be circular, if another mod requires yours, you &#039;&#039;cannot&#039;&#039; require it; Somebody has to load first.&lt;br /&gt;
&lt;br /&gt;
=== How are mods loaded in Factorio? ===&lt;br /&gt;
See [https://lua-api.factorio.com/latest/auxiliary/data-lifecycle.html this page by the developers], it sums up the process very well.&lt;br /&gt;
&lt;br /&gt;
=== How do I submit my mod to the mod portal? ===&lt;br /&gt;
Login with your Factorio.com account, and click the &amp;quot;Submit mod&amp;quot; button under &amp;quot;My Mods&amp;quot; in the top right corner. Provide the mod as a zip file, and write a description/upload some pics. The title, version, etc is all pulled from the zip. The mod name may not contain spaces.&lt;br /&gt;
&lt;br /&gt;
[[Category:Modding]]&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Tutorial:Script_interfaces&amp;diff=211913</id>
		<title>Tutorial:Script interfaces</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Tutorial:Script_interfaces&amp;diff=211913"/>
		<updated>2025-02-27T13:56:32Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: building -&amp;gt; entity&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
== Script interfaces (LuaRemote) ==&lt;br /&gt;
&lt;br /&gt;
Script interfaces allow direct communication between simultaneously running scripts. This is done in form of defining a public interface with given functions. All the code regarding the interfaces communication is in the &amp;lt;code&amp;gt;remote&amp;lt;/code&amp;gt; namespace. More info can be found in the offical api documentation, in this case [https://lua-api.factorio.com/latest/classes/LuaRemote.html LuaRemote].&lt;br /&gt;
&lt;br /&gt;
=== Defining interfaces ===&lt;br /&gt;
&lt;br /&gt;
The interface is defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- assuming interface_name and table_of_functions are defined elsewhere&lt;br /&gt;
remote.add_interface(interface_name, table_of_functions)&lt;br /&gt;
&lt;br /&gt;
-- It is possible to define the name and table inside the call&lt;br /&gt;
remote.add_interface(&amp;quot;my_interface&amp;quot;, {&lt;br /&gt;
    my_getter = function()&lt;br /&gt;
        -- you can return 1 or more variables from the script&lt;br /&gt;
        return &amp;quot;foo&amp;quot;&lt;br /&gt;
    end,&lt;br /&gt;
  &lt;br /&gt;
    -- the values can be only primitive type or (nested) tables&lt;br /&gt;
    my_setter = function(foo, bar)&lt;br /&gt;
        global.foo = foo&lt;br /&gt;
        global.bar = bar&lt;br /&gt;
    end&lt;br /&gt;
})&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface functions cannot take function pointers or function closures. Primitive types, LuaObjects and tables work just fine.&lt;br /&gt;
&lt;br /&gt;
=== Calling interface functions ===&lt;br /&gt;
&lt;br /&gt;
The interface can be used for calling functions from a different script. &#039;&#039;&#039;Limitations&#039;&#039;&#039;: A table with a metatable will not retain that metatable when received by the remote mod (however, game objects passed will remain intact). A received table is a &#039;&#039;&#039;copy&#039;&#039;&#039; of the original. It is &#039;&#039;&#039;not possible&#039;&#039;&#039; for two mods to &amp;quot;share&amp;quot; the same table across a remote call.&lt;br /&gt;
&lt;br /&gt;
Example (in the different script than the one above):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- calls the my_interface.my_getter from the script above and prints the returning value&lt;br /&gt;
print(remote.call(&amp;quot;my_interface&amp;quot;, &amp;quot;my_getter&amp;quot;))&lt;br /&gt;
-- remote call takes the name of the interface, name of the function and then variable amount of parameters&lt;br /&gt;
remote.call(&amp;quot;my_interface&amp;quot;, &amp;quot;my_setter&amp;quot;, 5, {bar=baz})&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Discovering interfaces ===&lt;br /&gt;
&lt;br /&gt;
The script can check for expected interfaces and its functions via the &amp;lt;code&amp;gt;remote.interfaces&amp;lt;/code&amp;gt; table. This is a table indexed by interface names where the values are set of functions for particular interfaces.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- check whether there is the &amp;quot;my_interface&amp;quot; interface and whether it contains the &amp;quot;my_getter&amp;quot; function&lt;br /&gt;
if remote.interfaces.my_interface and remote.interfaces.my_interface.my_getter then&lt;br /&gt;
    -- the remote call for the function is safe to use&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Custom input ==&lt;br /&gt;
&lt;br /&gt;
Keybindings can also be created. First the keybinding has to be defined in the data stage, see [https://lua-api.factorio.com/latest/prototypes/CustomInputPrototype.html CustomInputPrototype]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local button={&lt;br /&gt;
    type = &amp;quot;custom-input&amp;quot;,&lt;br /&gt;
    name = &amp;quot;my-custom-input&amp;quot;,&lt;br /&gt;
    key_sequence = &amp;quot;SHIFT + G&amp;quot;,&lt;br /&gt;
    consuming = &amp;quot;none&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
data:extend{button}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Available options for &amp;quot;consuming&amp;quot; are:&lt;br /&gt;
* none: default if not defined&lt;br /&gt;
* game-only: Blocks game inputs using the same key sequence but lets other custom inputs using the same key sequence fire.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;See also [https://lua-api.factorio.com/latest/types/ConsumingType.html ConsumingType]&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Locale definition:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;[controls] --Text for &amp;quot;game menu -&amp;gt; controls -&amp;gt; mods&amp;quot;&lt;br /&gt;
my-custom-input=Potato controls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;__CONTROL__my-custom-input__&amp;lt;/code&amp;gt; to get the bound key in other locale, for example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;this-is-some-locale=Potato controls are bound to &amp;quot;__CONTROL__my-custom-input__&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
shows &amp;lt;code&amp;gt;Potato controls are bound to &amp;quot;SHIFT + G&amp;quot;&amp;lt;/code&amp;gt; in-game.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And then it can be used runtime by subscribing to the event of the name of the custom input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(&amp;quot;my-custom-input&amp;quot;, function(event)&lt;br /&gt;
    game.print(&amp;quot;Ran on tick: &amp;quot; .. tostring(event.tick))&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [https://lua-api.factorio.com/latest/events.html#CustomInputEvent event ] contains the following:&lt;br /&gt;
&lt;br /&gt;
* player_index :: [https://lua-api.factorio.com/latest/concepts/uint.html uint]&lt;br /&gt;
* tick :: [https://lua-api.factorio.com/latest/concepts/uint.html uint]&lt;br /&gt;
* input_name :: [https://lua-api.factorio.com/latest/types/string.html string]: The name of the custom input.&lt;br /&gt;
* cursor_position :: [https://lua-api.factorio.com/latest/concepts/MapPosition.html MapPosition]:  The mouse cursor position when the input was activated.&lt;br /&gt;
* cursor_direction :: [https://lua-api.factorio.com/latest/defines.html#defines.direction defines.direction] (optional): The mouse cursor direction, for when the cursor contains a rotatable entity.&lt;br /&gt;
* cursor_display_location :: [https://lua-api.factorio.com/latest/concepts/GuiLocation.html GuiLocation]: The mouse cursor display location when the custom input was activated.&lt;br /&gt;
* selected_prototype :: [https://lua-api.factorio.com/latest/concepts/SelectedPrototypeData.html SelectedPrototypeData] (optional): Provided if [https://lua-api.factorio.com/latest/prototypes/CustomInputPrototype.html#include_selected_prototype include_selected_prototype] is true.&lt;br /&gt;
&lt;br /&gt;
[[Category:Modding]]&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Tutorial:Script_interfaces&amp;diff=211912</id>
		<title>Tutorial:Script interfaces</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Tutorial:Script_interfaces&amp;diff=211912"/>
		<updated>2025-02-27T13:56:05Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: Fix broken link, add new CustomInputEvent value&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
== Script interfaces (LuaRemote) ==&lt;br /&gt;
&lt;br /&gt;
Script interfaces allow direct communication between simultaneously running scripts. This is done in form of defining a public interface with given functions. All the code regarding the interfaces communication is in the &amp;lt;code&amp;gt;remote&amp;lt;/code&amp;gt; namespace. More info can be found in the offical api documentation, in this case [https://lua-api.factorio.com/latest/classes/LuaRemote.html LuaRemote].&lt;br /&gt;
&lt;br /&gt;
=== Defining interfaces ===&lt;br /&gt;
&lt;br /&gt;
The interface is defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- assuming interface_name and table_of_functions are defined elsewhere&lt;br /&gt;
remote.add_interface(interface_name, table_of_functions)&lt;br /&gt;
&lt;br /&gt;
-- It is possible to define the name and table inside the call&lt;br /&gt;
remote.add_interface(&amp;quot;my_interface&amp;quot;, {&lt;br /&gt;
    my_getter = function()&lt;br /&gt;
        -- you can return 1 or more variables from the script&lt;br /&gt;
        return &amp;quot;foo&amp;quot;&lt;br /&gt;
    end,&lt;br /&gt;
  &lt;br /&gt;
    -- the values can be only primitive type or (nested) tables&lt;br /&gt;
    my_setter = function(foo, bar)&lt;br /&gt;
        global.foo = foo&lt;br /&gt;
        global.bar = bar&lt;br /&gt;
    end&lt;br /&gt;
})&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The interface functions cannot take function pointers or function closures. Primitive types, LuaObjects and tables work just fine.&lt;br /&gt;
&lt;br /&gt;
=== Calling interface functions ===&lt;br /&gt;
&lt;br /&gt;
The interface can be used for calling functions from a different script. &#039;&#039;&#039;Limitations&#039;&#039;&#039;: A table with a metatable will not retain that metatable when received by the remote mod (however, game objects passed will remain intact). A received table is a &#039;&#039;&#039;copy&#039;&#039;&#039; of the original. It is &#039;&#039;&#039;not possible&#039;&#039;&#039; for two mods to &amp;quot;share&amp;quot; the same table across a remote call.&lt;br /&gt;
&lt;br /&gt;
Example (in the different script than the one above):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- calls the my_interface.my_getter from the script above and prints the returning value&lt;br /&gt;
print(remote.call(&amp;quot;my_interface&amp;quot;, &amp;quot;my_getter&amp;quot;))&lt;br /&gt;
-- remote call takes the name of the interface, name of the function and then variable amount of parameters&lt;br /&gt;
remote.call(&amp;quot;my_interface&amp;quot;, &amp;quot;my_setter&amp;quot;, 5, {bar=baz})&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Discovering interfaces ===&lt;br /&gt;
&lt;br /&gt;
The script can check for expected interfaces and its functions via the &amp;lt;code&amp;gt;remote.interfaces&amp;lt;/code&amp;gt; table. This is a table indexed by interface names where the values are set of functions for particular interfaces.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- check whether there is the &amp;quot;my_interface&amp;quot; interface and whether it contains the &amp;quot;my_getter&amp;quot; function&lt;br /&gt;
if remote.interfaces.my_interface and remote.interfaces.my_interface.my_getter then&lt;br /&gt;
    -- the remote call for the function is safe to use&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Custom input ==&lt;br /&gt;
&lt;br /&gt;
Keybindings can also be created. First the keybinding has to be defined in the data stage, see [https://lua-api.factorio.com/latest/prototypes/CustomInputPrototype.html CustomInputPrototype]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local button={&lt;br /&gt;
    type = &amp;quot;custom-input&amp;quot;,&lt;br /&gt;
    name = &amp;quot;my-custom-input&amp;quot;,&lt;br /&gt;
    key_sequence = &amp;quot;SHIFT + G&amp;quot;,&lt;br /&gt;
    consuming = &amp;quot;none&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
data:extend{button}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Available options for &amp;quot;consuming&amp;quot; are:&lt;br /&gt;
* none: default if not defined&lt;br /&gt;
* game-only: Blocks game inputs using the same key sequence but lets other custom inputs using the same key sequence fire.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;See also [https://lua-api.factorio.com/latest/types/ConsumingType.html ConsumingType]&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Locale definition:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;[controls] --Text for &amp;quot;game menu -&amp;gt; controls -&amp;gt; mods&amp;quot;&lt;br /&gt;
my-custom-input=Potato controls&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;__CONTROL__my-custom-input__&amp;lt;/code&amp;gt; to get the bound key in other locale, for example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;this-is-some-locale=Potato controls are bound to &amp;quot;__CONTROL__my-custom-input__&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
shows &amp;lt;code&amp;gt;Potato controls are bound to &amp;quot;SHIFT + G&amp;quot;&amp;lt;/code&amp;gt; in-game.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And then it can be used runtime by subscribing to the event of the name of the custom input:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(&amp;quot;my-custom-input&amp;quot;, function(event)&lt;br /&gt;
    game.print(&amp;quot;Ran on tick: &amp;quot; .. tostring(event.tick))&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [https://lua-api.factorio.com/latest/events.html#CustomInputEvent event ] contains the following:&lt;br /&gt;
&lt;br /&gt;
* player_index :: [https://lua-api.factorio.com/latest/concepts/uint.html uint]&lt;br /&gt;
* tick :: [https://lua-api.factorio.com/latest/concepts/uint.html uint]&lt;br /&gt;
* input_name :: [https://lua-api.factorio.com/latest/types/string.html string]: The name of the custom input.&lt;br /&gt;
* cursor_position :: [https://lua-api.factorio.com/latest/concepts/MapPosition.html MapPosition]:  The mouse cursor position when the input was activated.&lt;br /&gt;
* cursor_direction :: [https://lua-api.factorio.com/latest/defines.html#defines.direction defines.direction] (optional): The mouse cursor direction, for when the cursor contains a rotatable building.&lt;br /&gt;
* cursor_display_location :: [https://lua-api.factorio.com/latest/concepts/GuiLocation.html GuiLocation]: The mouse cursor display location when the custom input was activated.&lt;br /&gt;
* selected_prototype :: [https://lua-api.factorio.com/latest/concepts/SelectedPrototypeData.html SelectedPrototypeData] (optional): Provided if [https://lua-api.factorio.com/latest/prototypes/CustomInputPrototype.html#include_selected_prototype include_selected_prototype] is true.&lt;br /&gt;
&lt;br /&gt;
[[Category:Modding]]&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Tutorial:Scripting&amp;diff=211911</id>
		<title>Tutorial:Scripting</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Tutorial:Scripting&amp;diff=211911"/>
		<updated>2025-02-27T13:15:06Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: Fix broken links, add links, tweak wording.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
== What is a script? ==&lt;br /&gt;
In general, you can learn the definition of a script [https://en.wikipedia.org/wiki/Scripting_language here]. Within the context of Factorio, a script refers to a Lua script, packaged with a mod or scenario.&lt;br /&gt;
&lt;br /&gt;
There are 2 usages of scripts, loading of [https://lua-api.factorio.com/latest/index-prototype.html prototype data], and runtime scripting of the game and its entities.&lt;br /&gt;
&lt;br /&gt;
This guide only covers usages of runtime scripts. To be more specific, we call these runtime scripts &#039;control scripts&#039;, as they assert direct control on the game as it runs.&lt;br /&gt;
&lt;br /&gt;
== Loading a script ==&lt;br /&gt;
When you load a game, scenario and mod scripts are loaded. The game looks for a file called &#039;control.lua&#039;, in the mod directory or the scenario directory. If found, the game will then load that script, and any other scripts required in the control script.&lt;br /&gt;
&lt;br /&gt;
== [https://lua-api.factorio.com/latest/Libraries.html Factorio specifics] ==&lt;br /&gt;
Factorio uses Lua version 5.2.1.&lt;br /&gt;
&lt;br /&gt;
Factorio uses Serpent for serialization - This comes with some big drawbacks:&lt;br /&gt;
&lt;br /&gt;
* Serpent is relatively slow and inefficient&lt;br /&gt;
* Serpent cannot serialize a lot of Lua objects, such as functions, metatables and coroutines.&lt;br /&gt;
&lt;br /&gt;
The full scripting API is generated and updated each release, and is available [https://lua-api.factorio.com/latest/index-runtime.html here]. This is the number 1 resource for scripting in the game.&lt;br /&gt;
&lt;br /&gt;
== [http://lua-api.factorio.com/latest/LuaBootstrap.html Script events] ==&lt;br /&gt;
The Lua script has some special functions it runs outside of events: &lt;br /&gt;
* &amp;lt;code&amp;gt;script.on_init()&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;script.on_configuration_changed()&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;script.on_load()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://lua-api.factorio.com/latest/classes/LuaBootstrap.html#on_init &amp;lt;code&amp;gt;on_init()&amp;lt;/code&amp;gt;] will run when the game starts (or in mod cases, when you add it to an existing save). It is used to initialize storage variables you will need, changing game parameters, for instance:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_init(function()&lt;br /&gt;
  storage.ticker = 0&lt;br /&gt;
  storage.level = 1&lt;br /&gt;
  storage.teams = {default_team = &amp;quot;johns-lads&amp;quot;}&lt;br /&gt;
  game.create_surface(&amp;quot;Scenario Surface&amp;quot;)&lt;br /&gt;
  game.map_settings.pollution.enabled = false&lt;br /&gt;
  --etc.&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[https://lua-api.factorio.com/latest/classes/LuaGameScript.html &amp;lt;code&amp;gt;game&amp;lt;/code&amp;gt;] namespace is available during on_init.&lt;br /&gt;
&lt;br /&gt;
[https://lua-api.factorio.com/latest/classes/LuaBootstrap.html#on_configuration_changed &amp;lt;code&amp;gt;on_configuration_changed(data)&amp;lt;/code&amp;gt;] will run when some configuration about this save game changes, such as a mod being added, changed or removed. This function is used to account for changes to game or prototype changes. &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; will contain information on what has changed.&lt;br /&gt;
&lt;br /&gt;
So if you are dependent on some prototype for your script to work, you should check here that it still exists:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_configuration_changed(function(data)&lt;br /&gt;
  local turret_name = &amp;quot;gun-turret&amp;quot;&lt;br /&gt;
  if not prototypes.entity[turret_name] then&lt;br /&gt;
    log(&amp;quot;Gun turret isn&#039;t here, some mod or something has changed it&amp;quot;)&lt;br /&gt;
    storage.do_turret_logic = false&lt;br /&gt;
  end&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The contents of the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; parameter is defined [https://lua-api.factorio.com/latest/concepts/ConfigurationChangedData.html here].&lt;br /&gt;
&lt;br /&gt;
[https://lua-api.factorio.com/latest/classes/LuaBootstrap.html#on_load &amp;lt;code&amp;gt;on_load()&amp;lt;/code&amp;gt;] will run every time the script loads. &amp;lt;code&amp;gt;game&amp;lt;/code&amp;gt; will not be available during &amp;lt;code&amp;gt;on_load&amp;lt;/code&amp;gt;. This should only be used to handle resetting up metatables, making local references to variables in &amp;lt;code&amp;gt;storage&amp;lt;/code&amp;gt;, and setting up conditional event handlers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local variable&lt;br /&gt;
script.on_load(function()&lt;br /&gt;
  --Resetting metatables&lt;br /&gt;
  for k, v in (storage.objects_with_metatable) do&lt;br /&gt;
    setmetatable(v, object_metatable)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  --Setting local reference to variable in storage&lt;br /&gt;
  variable = storage.variable&lt;br /&gt;
&lt;br /&gt;
  --Conditional event handler&lt;br /&gt;
  if storage.trees then&lt;br /&gt;
    script.on_event(defines.events.on_tick, handle_tree_function)&lt;br /&gt;
  end&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It is quite easy to generate desyncs doing overly complex things with on_load, so we recommend only doing things with it if absolutely nescessary.&lt;br /&gt;
&lt;br /&gt;
== [http://lua-api.factorio.com/latest/events.html Game events] ==&lt;br /&gt;
&lt;br /&gt;
The scripts all run based off events. These events are sent by the game after certain actions are performed. For instance &amp;lt;code&amp;gt;on_player_crafted_item&amp;lt;/code&amp;gt;. To &#039;&#039;do&#039;&#039; something with an event, you will need to assign an event handler:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(defines.events.on_player_crafted_item, player_crafted_function)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
When the event is triggered, it will then call the function with &amp;lt;code&amp;gt;event&amp;lt;/code&amp;gt; as its parameter. &amp;lt;code&amp;gt;event&amp;lt;/code&amp;gt; is a table that contains varying information about the event. More specific info on them [http://lua-api.factorio.com/latest/events.html here]. You then process the event using your own function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function player_crafted_function(event)&lt;br /&gt;
  game.print(&amp;quot;A player crafted an item on tick &amp;quot;..event.tick)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This also works with anonymous functions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(defines.events.on_tick, function(event)&lt;br /&gt;
  game.print(&amp;quot;tick&amp;quot;)&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that only one event handler can be assigned for each event, such that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(defines.events.on_tick, function(event)&lt;br /&gt;
  game.print(&amp;quot;tick&amp;quot;)&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
script.on_event(defines.events.on_tick, function(event)&lt;br /&gt;
  game.print(&amp;quot;tock&amp;quot;)&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The second handler will overwrite the first.&lt;br /&gt;
&lt;br /&gt;
If you want to do multiple things on the same event, a simple way is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(defines.events.on_tick, function(event)&lt;br /&gt;
  this_on_tick(event)&lt;br /&gt;
  that_on_tick(event)&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
== Saving data &amp;amp;amp; the &amp;lt;code&amp;gt;storage&amp;lt;/code&amp;gt; table ==&lt;br /&gt;
&lt;br /&gt;
Save/Load stability is very important to preserve the determinism of the game. In Lua, all values are global by default. This isn’t good news in Factorio, as it can make it seem as though things are working correctly, but will lead to desyncs in multiplayer.&lt;br /&gt;
&lt;br /&gt;
To preserve data between load and save, we have the &amp;lt;code&amp;gt;storage&amp;lt;/code&amp;gt; table. If there is some variable that you need to use between events, this is where it should live.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(defines.events.on_tick, function(event)&lt;br /&gt;
  storage.ticker = (storage.ticker or 0) + 1&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now when the player saves the game, the value of &amp;lt;code&amp;gt;storage.ticker&amp;lt;/code&amp;gt; will be saved. When it is loaded again, its value will be restored. This is important, because in multiplayer, players joining the game will load the value from the save.&lt;br /&gt;
&lt;br /&gt;
The way this can cause desyncs is quite clear: if one player has their Lua state, with a ticker value of 100, and another has a value of 50, and you then create ticker number of biters, it would create 100 for player 1, and 50 for player 2.&lt;br /&gt;
&lt;br /&gt;
However it is not often this easy. The case is often as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;tick_to_print = 10 --So lets say this is a static variable. Just some config for how your script works.&lt;br /&gt;
&lt;br /&gt;
function on_tick()&lt;br /&gt;
  if game.tick == tick_to_print then&lt;br /&gt;
    game.print(&amp;quot;hello&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
script.on_event(defines.event.on_tick, on_tick)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will be fine, we are using the variable, but not changing it. When a new player loads the game, &amp;lt;code&amp;gt;tick_to_print&amp;lt;/code&amp;gt; will be &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt;, same as the other players.&lt;br /&gt;
&lt;br /&gt;
Problem comes if we adjust &amp;lt;code&amp;gt;tick_to_print&amp;lt;/code&amp;gt;, either by purpose or intentionally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;tick_to_print = 10 --So lets say this is a static variable. Just some config for how your script works.&lt;br /&gt;
&lt;br /&gt;
function on_tick()&lt;br /&gt;
  if game.tick == tick_to_print then&lt;br /&gt;
    game.print(&amp;quot;hello&amp;quot;)&lt;br /&gt;
    tick_to_print = tick_to_print + 100 --Say we want it to print again in 100 ticks&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
script.on_event(defines.event.on_tick, on_tick)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now when you test the script, it will work perfectly. Every 100 ticks it will print “hello”. The problem occurs when you save and then load the game. When you save, the value of &amp;lt;code&amp;gt;tick_to_print&amp;lt;/code&amp;gt; is not saved anywhere, and so when you load, it just uses the value it is told to at the top of the script: &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Now it is clear that the value of &amp;lt;code&amp;gt;tick_to_print&amp;lt;/code&amp;gt; has changed by saving and loading, so we say it is not save/load stable. If a players joins a multiplayer game with this script, they would desync as soon as one of the scripts prints as the result of a comparison against &amp;lt;code&amp;gt;tick_to_print&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
So TL;DR - If you want to use something between ticks then store it in &amp;lt;code&amp;gt;storage&amp;lt;/code&amp;gt;. This will prevent 99% of possible desyncs.&lt;br /&gt;
&lt;br /&gt;
== Story script ==&lt;br /&gt;
&lt;br /&gt;
Story script is a Lua library designed to facilitate the scripting and flow of a story. It has some simple structure and supporting function to help things move along.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;--Initialize the story info&lt;br /&gt;
script.on_init(function()&lt;br /&gt;
  storage.story = story_init()&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
--Register to update the story on events&lt;br /&gt;
script.on_event(defines.events, function(event)&lt;br /&gt;
  story_update(storage.story, event)&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
--Story table is where the &#039;story&#039; is all defined.&lt;br /&gt;
story_table =&lt;br /&gt;
{&lt;br /&gt;
  {&lt;br /&gt;
    --branch 1&lt;br /&gt;
    {&lt;br /&gt;
      --First story event&lt;br /&gt;
&lt;br /&gt;
      --Initialise this event&lt;br /&gt;
      init = function(event, story)&lt;br /&gt;
        game.print(&amp;quot;First init of first story event&amp;quot;)&lt;br /&gt;
      end,&lt;br /&gt;
&lt;br /&gt;
      --Update function that will run on all events&lt;br /&gt;
      update = function(event, story)&lt;br /&gt;
        log(&amp;quot;updating&amp;quot;)&lt;br /&gt;
      end,&lt;br /&gt;
&lt;br /&gt;
      --Condition to move on. If the return value is &#039;true&#039;, the story will continue.&lt;br /&gt;
      condition = function(event, story)&lt;br /&gt;
        if event.tick &amp;gt; 100 then&lt;br /&gt;
          return true&lt;br /&gt;
        end&lt;br /&gt;
      end,&lt;br /&gt;
&lt;br /&gt;
      --Action to perform after condition is met&lt;br /&gt;
      action = function(event, story)&lt;br /&gt;
        game.print(&amp;quot;You completed the objective!&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
      --Second story event - example.&lt;br /&gt;
      init = function(event, story)&lt;br /&gt;
        game.print(&amp;quot;Collect 100 iron plate&amp;quot;)&lt;br /&gt;
      end,&lt;br /&gt;
      condition = function(event, story)&lt;br /&gt;
        return game.players[1].get_item_count(&amp;quot;iron-plate&amp;quot;) &amp;gt;= 100&lt;br /&gt;
      end,&lt;br /&gt;
      action = function(event, story)&lt;br /&gt;
        game.print(&amp;quot;Well done&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    }&lt;br /&gt;
    --Once the end of a branch is reached, the story is finished.&lt;br /&gt;
    --The game will now display the mission complete screen.&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    --branch 2&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
--Init the helpers and story table. Must be done all times script is loaded.&lt;br /&gt;
story_init_helpers(story_table)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Branches are an optional system of the story system, and you can jump to another branch using &amp;lt;code&amp;gt;story_jump_to(story, name)&amp;lt;/code&amp;gt;. The story progresses from the top down, and when it reaches the last story event, the mission concludes.&lt;br /&gt;
&lt;br /&gt;
It is possible to leverage any number of clever Lua tricks and API calls in the story table. It is good form to try and keep each story part independant from its neighbors, as it makes maintanance and reworkings more manageable.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;  {&lt;br /&gt;
    action = function()&lt;br /&gt;
      player().insert(&amp;quot;iron-plate&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    init = function()&lt;br /&gt;
      player().print(&amp;quot;Use your iron plate to craft some belts&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Good:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;  {&lt;br /&gt;
    init = function()&lt;br /&gt;
      player().insert(&amp;quot;iron-plate&amp;quot;)&lt;br /&gt;
      player().print(&amp;quot;Use your iron plate...&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are some utility functions to make things simpler on the scripting side:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;--Return true only after this many seconds has elasped&lt;br /&gt;
story_elapsed_check(5)&lt;br /&gt;
&lt;br /&gt;
--Update the objective for all players&lt;br /&gt;
set_goal({&amp;quot;objective-1&amp;quot;})&lt;br /&gt;
&lt;br /&gt;
--Flash the goal GUI for players (updating info doesn&#039;t flash it)&lt;br /&gt;
flash_goal()&lt;br /&gt;
&lt;br /&gt;
--Update the &#039;info gui&#039; for all players. This is quite powerful and can use custom function to build complex GUI&#039;s&lt;br /&gt;
set_info(&lt;br /&gt;
{&lt;br /&gt;
  text = {&amp;quot;info-1&amp;quot;},&lt;br /&gt;
  picture = &amp;quot;item/iron-plate&amp;quot;&lt;br /&gt;
})&lt;br /&gt;
&lt;br /&gt;
--Exports entities in a Lua table format&lt;br /&gt;
export_entities(parameters)&lt;br /&gt;
&lt;br /&gt;
--Recreates entities saved using a Lua format&lt;br /&gt;
recreate_entities(entities, parameters)&lt;br /&gt;
&lt;br /&gt;
--Shorthand syntax for game.players[i], defaults i to 1&lt;br /&gt;
player(i)&lt;br /&gt;
&lt;br /&gt;
--Shorthand syntax for game.surfaces[i], defaults i to 1&lt;br /&gt;
surface(i)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Modding]]&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Tutorial:Scripting&amp;diff=206145</id>
		<title>Tutorial:Scripting</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Tutorial:Scripting&amp;diff=206145"/>
		<updated>2024-11-13T16:59:56Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: 2.0 update (global -&amp;gt; storage)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
== What is a script? ==&lt;br /&gt;
In general, you can learn the definition of a script [https://en.wikipedia.org/wiki/Scripting_language here]. Within the context of Factorio, a script refers to a Lua script, packaged with a mod or scenario.&lt;br /&gt;
&lt;br /&gt;
There are 2 usages of scripts, loading of [https://lua-api.factorio.com/latest/index-prototype.html prototype data], and runtime scripting of the game and its entities.&lt;br /&gt;
&lt;br /&gt;
This guide only covers usages of runtime scripts. To be more specific, we call these runtime scripts &#039;control scripts&#039;, as they assert direct control on the game as it runs.&lt;br /&gt;
&lt;br /&gt;
== Loading a script ==&lt;br /&gt;
When you load a game, scenario and mod scripts are loaded. The game looks for a file called &#039;control.lua&#039;, in the mod directory or the scenario directory. If found, the game will then load that script, and any other scripts required in the control script.&lt;br /&gt;
&lt;br /&gt;
== [https://lua-api.factorio.com/latest/Libraries.html Factorio specifics] ==&lt;br /&gt;
Factorio uses Lua version 5.2.1.&lt;br /&gt;
&lt;br /&gt;
Factorio uses Serpent for serialization - This comes with some big drawbacks:&lt;br /&gt;
&lt;br /&gt;
* Serpent is relatively slow and inefficient&lt;br /&gt;
* Serpent cannot serialize a lot of Lua objects, such as functions, metatables and coroutines.&lt;br /&gt;
&lt;br /&gt;
The full scripting API is generated and updated each release, and is available [https://lua-api.factorio.com/latest/index-runtime.html here]. This is the number 1 resource for scripting in the game.&lt;br /&gt;
&lt;br /&gt;
== [http://lua-api.factorio.com/latest/LuaBootstrap.html Script events] ==&lt;br /&gt;
The Lua script has some special functions it runs outside of events: &lt;br /&gt;
* &amp;lt;code&amp;gt;script.on_init()&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;script.on_configuration_changed()&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;script.on_load()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;on_init()&amp;lt;/code&amp;gt; will run when the game starts (or in mod cases, when you add it to an existing save). It is used to initialize storage variables you will need, changing game parameters, for instance:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_init(function()&lt;br /&gt;
  storage.ticker = 0&lt;br /&gt;
  storage.level = 1&lt;br /&gt;
  storage.teams = {default_team = &amp;quot;johns-lads&amp;quot;}&lt;br /&gt;
  game.create_surface(&amp;quot;Scenario Surface&amp;quot;)&lt;br /&gt;
  game.map_settings.pollution.enabled = false&lt;br /&gt;
  --etc.&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://lua-api.factorio.com/latest/LuaGameScript.html &amp;lt;code&amp;gt;game&amp;lt;/code&amp;gt;] namespace is available during on_init&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;on_configuration_changed(data)&amp;lt;/code&amp;gt; will run when some configuration about this save game changes, such as a mod being added, changed or removed. This function is used to account for changes to game or prototype changes. &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; will contain information on what has changed.&lt;br /&gt;
&lt;br /&gt;
So if you are dependent on some prototype for your script to work, you should check here that it still exists:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_configuration_changed(function(data)&lt;br /&gt;
  local turret_name = &amp;quot;gun-turret&amp;quot;&lt;br /&gt;
  if not game.entity_prototypes[turret_name] then&lt;br /&gt;
    log(&amp;quot;Gun turret isn&#039;t here, some mod or something has changed it&amp;quot;)&lt;br /&gt;
    storage.do_turret_logic = false&lt;br /&gt;
  end&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The contents of the &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; parameter is defined [http://lua-api.factorio.com/latest/Concepts.html#ConfigurationChangedData here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;on_load()&amp;lt;/code&amp;gt; will run every time the script loads. &amp;lt;code&amp;gt;game&amp;lt;/code&amp;gt; will not be available during &amp;lt;code&amp;gt;on_load&amp;lt;/code&amp;gt;. This should only be used to handle resetting up metatables, making local references to variables in &amp;lt;code&amp;gt;storage&amp;lt;/code&amp;gt;, and setting up conditional event handlers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;local variable&lt;br /&gt;
script.on_load(function()&lt;br /&gt;
  --Resetting metatables&lt;br /&gt;
  for k, v in (storage.objects_with_metatable) do&lt;br /&gt;
    setmetatable(v, object_metatable)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  --Setting local reference to variable in storage&lt;br /&gt;
  variable = storage.variable&lt;br /&gt;
&lt;br /&gt;
  --Conditional event handler&lt;br /&gt;
  if storage.trees then&lt;br /&gt;
    script.on_event(defines.events.on_tick, handle_tree_function)&lt;br /&gt;
  end&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It is quite easy to generate desyncs doing overly complex things with on_load, so we recommend only doing things with it if absolutely nescessary.&lt;br /&gt;
&lt;br /&gt;
== [http://lua-api.factorio.com/latest/events.html Game events] ==&lt;br /&gt;
&lt;br /&gt;
The scripts all run based off events. These events are sent by the game after certain actions are performed. For instance &amp;lt;code&amp;gt;on_player_crafted_item&amp;lt;/code&amp;gt;. To &#039;&#039;do&#039;&#039; something with an event, you will need to assign an event handler:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(defines.events.on_player_crafted_item, player_crafted_function)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
When the event is triggered, it will then call the function with &amp;lt;code&amp;gt;event&amp;lt;/code&amp;gt; as its parameter. &amp;lt;code&amp;gt;event&amp;lt;/code&amp;gt; is a table that contains varying information about the event. More specific info on them [http://lua-api.factorio.com/latest/events.html here]. You then process the event using your own function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;function player_crafted_function(event)&lt;br /&gt;
  game.print(&amp;quot;A player crafted an item on tick &amp;quot;..event.tick)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This also works with anonymous functions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(defines.events.on_tick, function(event)&lt;br /&gt;
  game.print(&amp;quot;tick&amp;quot;)&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that only one event handler can be assigned for each event, such that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(defines.events.on_tick, function(event)&lt;br /&gt;
  game.print(&amp;quot;tick&amp;quot;)&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
script.on_event(defines.events.on_tick, function(event)&lt;br /&gt;
  game.print(&amp;quot;tock&amp;quot;)&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The second handler will overwrite the first.&lt;br /&gt;
&lt;br /&gt;
If you want to do multiple things on the same event, a simple way is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(defines.events.on_tick, function(event)&lt;br /&gt;
  this_on_tick(event)&lt;br /&gt;
  that_on_tick(event)&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
== Saving data &amp;amp;amp; the &amp;lt;code&amp;gt;storage&amp;lt;/code&amp;gt; table ==&lt;br /&gt;
&lt;br /&gt;
Save/Load stability is very important to preserve the determinism of the game. In Lua, all values are global by default. This isn’t good news in Factorio, as it can make it seem as though things are working correctly, but will lead to desyncs in MP.&lt;br /&gt;
&lt;br /&gt;
To preserve data between load and save, we have the &amp;lt;code&amp;gt;storage&amp;lt;/code&amp;gt; table. If there is some variable that you need to use between events, this is where it should live.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;script.on_event(defines.events.on_tick, function(event)&lt;br /&gt;
  storage.ticker = (storage.ticker or 0) + 1&lt;br /&gt;
end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now when the player saves the game, the value of &amp;lt;code&amp;gt;storage.ticker&amp;lt;/code&amp;gt; will be saved. When it is loaded again, its value will be restored. This is important, because in MP, players joining the game will load the value from the save.&lt;br /&gt;
&lt;br /&gt;
The way this can cause desyncs is quite clear, if one player has their Lua state, with a ticker value of 100, and another has a value of 50, and you then create ticker number of biters, it would create 100 for player 1, and 50 for player 2.&lt;br /&gt;
&lt;br /&gt;
However it is not often this easy. The case is often as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;tick_to_print = 10 --So lets say this is a static variable. Just some config for how your script works.&lt;br /&gt;
&lt;br /&gt;
function on_tick()&lt;br /&gt;
  if game.tick == tick_to_print then&lt;br /&gt;
    game.print(&amp;quot;hello&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
script.on_event(defines.event.on_tick, on_tick)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This will be fine, we are using the variable, but not changing it. When a new player loads the game, &amp;lt;code&amp;gt;tick_to_print&amp;lt;/code&amp;gt; will be &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt;, same as the other players.&lt;br /&gt;
&lt;br /&gt;
Problem comes if we adjust &amp;lt;code&amp;gt;tick_to_print&amp;lt;/code&amp;gt;, either by purpose or intentionally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;tick_to_print = 10 --So lets say this is a static variable. Just some config for how your script works.&lt;br /&gt;
&lt;br /&gt;
function on_tick()&lt;br /&gt;
  if game.tick == tick_to_print then&lt;br /&gt;
    game.print(&amp;quot;hello&amp;quot;)&lt;br /&gt;
    tick_to_print = tick_to_print + 100 --Say we want it to print again in 100 ticks&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
script.on_event(defines.event.on_tick, on_tick)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Now when you test the script, it will work perfectly. Every 100 ticks it will print “hello”. The problem occurs when you save, and load the game. When you save, the value of &amp;lt;code&amp;gt;tick_to_print&amp;lt;/code&amp;gt; is not saved anywhere, And thus, when you load, it just uses the value its told to at the top of the script: &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Now it is clear that the value of &amp;lt;code&amp;gt;tick_to_print&amp;lt;/code&amp;gt; has changed by saving and loading, thus we say it is not save/load stable. If a players joins a MP game with this script, they would desync as soon as one of the scripts prints as the result of a comparison against &amp;lt;code&amp;gt;tick_to_print&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
So TL;DR - If you want to use something between ticks, then store it in &amp;lt;code&amp;gt;storage&amp;lt;/code&amp;gt;. This will prevent 99% of possible desyncs.&lt;br /&gt;
&lt;br /&gt;
== Story script ==&lt;br /&gt;
&lt;br /&gt;
Story script is a Lua library designed to facilitate the scripting and flow of a story. It has some simple structure and supporting function to help things move along.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;--Initialize the story info&lt;br /&gt;
script.on_init(function()&lt;br /&gt;
  storage.story = story_init()&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
--Register to update the story on events&lt;br /&gt;
script.on_event(defines.events, function(event)&lt;br /&gt;
  story_update(storage.story, event)&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
--Story table is where the &#039;story&#039; is all defined.&lt;br /&gt;
story_table =&lt;br /&gt;
{&lt;br /&gt;
  {&lt;br /&gt;
    --branch 1&lt;br /&gt;
    {&lt;br /&gt;
      --First story event&lt;br /&gt;
&lt;br /&gt;
      --Initialise this event&lt;br /&gt;
      init = function(event, story)&lt;br /&gt;
        game.print(&amp;quot;First init of first story event&amp;quot;)&lt;br /&gt;
      end,&lt;br /&gt;
&lt;br /&gt;
      --Update function that will run on all events&lt;br /&gt;
      update = function(event, story)&lt;br /&gt;
        log(&amp;quot;updating&amp;quot;)&lt;br /&gt;
      end,&lt;br /&gt;
&lt;br /&gt;
      --Condition to move on. If the return value is &#039;true&#039;, the story will continue.&lt;br /&gt;
      condition = function(event, story)&lt;br /&gt;
        if event.tick &amp;gt; 100 then&lt;br /&gt;
          return true&lt;br /&gt;
        end&lt;br /&gt;
      end,&lt;br /&gt;
&lt;br /&gt;
      --Action to perform after condition is met&lt;br /&gt;
      action = function(event, story)&lt;br /&gt;
        game.print(&amp;quot;You completed the objective!&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
      --Second story event - example.&lt;br /&gt;
      init = function(event, story)&lt;br /&gt;
        game.print(&amp;quot;Collect 100 iron plate&amp;quot;)&lt;br /&gt;
      end,&lt;br /&gt;
      condition = function(event, story)&lt;br /&gt;
        return game.players[1].get_item_count(&amp;quot;iron-plate&amp;quot;) &amp;gt;= 100&lt;br /&gt;
      end,&lt;br /&gt;
      action = function(event, story)&lt;br /&gt;
        game.print(&amp;quot;Well done&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    }&lt;br /&gt;
    --Once the end of a branch is reached, the story is finished.&lt;br /&gt;
    --The game will now display the mission complete screen.&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    --branch 2&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
--Init the helpers and story table. Must be done all times script is loaded.&lt;br /&gt;
story_init_helpers(story_table)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Branches are an optional system of the story system, and you can jump to another branch using &amp;lt;code&amp;gt;story_jump_to(story, name)&amp;lt;/code&amp;gt;. The story progresses from the top down, and when it reaches the last story event, the mission concludes.&lt;br /&gt;
&lt;br /&gt;
It is possible to leverage any number of clever Lua tricks and API calls in the story table. It is good form to try and keep each story part independant from its neighbors, as it makes maintanance and reworkings more manageable.&lt;br /&gt;
&lt;br /&gt;
Bad:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;  {&lt;br /&gt;
    action = function()&lt;br /&gt;
      player().insert(&amp;quot;iron-plate&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    init = function()&lt;br /&gt;
      player().print(&amp;quot;Use your iron plate to craft some belts&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Good:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;  {&lt;br /&gt;
    init = function()&lt;br /&gt;
      player().insert(&amp;quot;iron-plate&amp;quot;)&lt;br /&gt;
      player().print(&amp;quot;Use your iron plate...&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  }&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are some utility functions to make things simpler on the scripting side:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;--Return true only after this many seconds has elasped&lt;br /&gt;
story_elapsed_check(5)&lt;br /&gt;
&lt;br /&gt;
--Update the objective for all players&lt;br /&gt;
set_goal({&amp;quot;objective-1&amp;quot;})&lt;br /&gt;
&lt;br /&gt;
--Flash the goal GUI for players (updating info doesn&#039;t flash it)&lt;br /&gt;
flash_goal()&lt;br /&gt;
&lt;br /&gt;
--Update the &#039;info gui&#039; for all players. This is quite powerful and can use custom function to build complex GUI&#039;s&lt;br /&gt;
set_info(&lt;br /&gt;
{&lt;br /&gt;
  text = {&amp;quot;info-1&amp;quot;},&lt;br /&gt;
  picture = &amp;quot;item/iron-plate&amp;quot;&lt;br /&gt;
})&lt;br /&gt;
&lt;br /&gt;
--Exports entities in a Lua table format&lt;br /&gt;
export_entities(parameters)&lt;br /&gt;
&lt;br /&gt;
--Recreates entities saved using a Lua format&lt;br /&gt;
recreate_entities(entities, parameters)&lt;br /&gt;
&lt;br /&gt;
--Shorthand syntax for game.players[i], defaults i to 1&lt;br /&gt;
player(i)&lt;br /&gt;
&lt;br /&gt;
--Shorthand syntax for game.surfaces[i], defaults i to 1&lt;br /&gt;
surface(i)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Modding]]&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Upcoming_features&amp;diff=193050</id>
		<title>Upcoming features</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Upcoming_features&amp;diff=193050"/>
		<updated>2023-08-18T17:33:43Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: /* Known changes for 1.2 */ Added several upcoming changes mentioned by developers.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
This is a list of known information about Factorio&#039;s &amp;quot;one big expansion pack&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Plans ==&lt;br /&gt;
* Q: What?&lt;br /&gt;
** A: It is way too early to show any of the plans, and since we want to keep the iterative process of expanding things that prove to be the most fun, the plan is quite loose anyway. [https://www.factorio.com/blog/post/fff-365]&lt;br /&gt;
* Multiple people, including the modder [https://mods.factorio.com/user/Earendel Earendel] were hired to work on the expansion pack. [https://www.factorio.com/blog/post/fff-365]&lt;br /&gt;
* As of February 2022, development is on step 4 &amp;quot;Connecting systems into a prototype&amp;quot; out of 7 total steps until release. [https://factorio.com/blog/post/fff-367]&lt;br /&gt;
* [https://factorio.com/blog/post/fff-367 Friday Facts #367] shows some concept art for the expansion.&lt;br /&gt;
* [https://factorio.com/blog/post/fff-372 Friday Facts #372] shows some item icons from the expansion.&lt;br /&gt;
* It is planned to be &amp;quot;as big an addition as the whole vanilla game.&amp;quot; [https://factorio.com/blog/post/fff-367]&lt;br /&gt;
* The planned price is $30.00. [https://factorio.com/blog/post/fff-367]&lt;br /&gt;
* Will not be ready before September 2023. [https://factorio.com/blog/post/fff-370]&lt;br /&gt;
&lt;br /&gt;
== Known changes for 1.2 ==&lt;br /&gt;
&lt;br /&gt;
* [[Crafting#Recipe_difficulties|Expensive mode]] gets turned into a mod. [https://forums.factorio.com/viewtopic.php?p=577191#p577191]&lt;br /&gt;
* [[Train_stop#Circuit_Network|Train stop disabling]] will be removed. [https://forums.factorio.com/viewtopic.php?p=574563#p574563]&lt;br /&gt;
* Improvements to controlling [[Spidertron|spidertrons]]. [https://www.reddit.com/r/factorio/comments/6e6tkw/im_the_founder_of_factorio_kovarex_ama/jnncw10/]&lt;br /&gt;
* Added the ability to use the pipette anywhere, including the crafting menu. [https://forums.factorio.com/viewtopic.php?p=567550#p567550]&lt;br /&gt;
* Added the ability to automatically remove fuel from [[Locomotive|locomotives]]. [https://forums.factorio.com/viewtopic.php?p=577389#p577389]&lt;br /&gt;
* [[Ghost]] [[Pipe|pipes]] will visually connect to each other. [https://forums.factorio.com/viewtopic.php?p=578549#p578549]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [https://factorio.com/blog/post/fff-365 Friday Facts #365 - Future plans]&lt;br /&gt;
* [https://factorio.com/blog/post/fff-367 Friday Facts #367]&lt;br /&gt;
* [https://factorio.com/blog/post/fff-370 Friday Facts #370]&lt;br /&gt;
* [[Roadmap|Planned releases]]&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/EnergySource&amp;diff=191209</id>
		<title>Types/EnergySource</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/EnergySource&amp;diff=191209"/>
		<updated>2023-04-04T10:45:30Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: Typo fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
Specifies the way the entity gets its energy.&lt;br /&gt;
=== type ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Mandatory. Only valid values are &amp;quot;electric&amp;quot;, &amp;quot;burner&amp;quot;, &amp;quot;heat&amp;quot;, &amp;quot;fluid&amp;quot; or &amp;quot;void&amp;quot;, it specifies the type of the energy source to be used.&lt;br /&gt;
&lt;br /&gt;
=== emissions_per_minute ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Optional. The pollution an entity emits per minute at full energy consumption. &amp;lt;code&amp;gt;emissions_per_minute&amp;lt;/code&amp;gt; is exactly the value that is shown in the entity tooltip.&lt;br /&gt;
&lt;br /&gt;
=== render_no_power_icon ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/bool]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: true&lt;br /&gt;
&lt;br /&gt;
Optional. Whether to render the [[File:Electricity-icon-red.png|50px]] icon on the entity if it is low on power. Also applies to [[File:Fuel-icon-red.png|50px]] when using a burner energy source.&lt;br /&gt;
&lt;br /&gt;
=== render_no_network_icon ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/bool]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: true&lt;br /&gt;
&lt;br /&gt;
Optional. Whether to render the [[File:Electricity-icon-unplugged.png|50px]] icon on the entity if it is not connected to a electric network.&lt;br /&gt;
&lt;br /&gt;
== Electric energy source ==&lt;br /&gt;
=== buffer_capacity ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Energy]]&lt;br /&gt;
&lt;br /&gt;
Optional. How much energy the entity holds.&lt;br /&gt;
&lt;br /&gt;
=== usage_priority ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/ElectricUsagePriority]]&lt;br /&gt;
&lt;br /&gt;
Mandatory.&lt;br /&gt;
=== input_flow_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Energy]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Optional. The rate at which energy can be taken, from the network, to refill the energy buffer. 0 means no transfer.&lt;br /&gt;
&lt;br /&gt;
=== output_flow_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Energy]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Optional. The rate at which energy can be provided, to the network, from the energy buffer. 0 means no transfer.&lt;br /&gt;
&lt;br /&gt;
=== drain ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Energy]]&lt;br /&gt;
&lt;br /&gt;
Optional. How much energy (per second) will be continuously removed from the energy buffer. In game, this is shown in the tooltip as &amp;quot;Min. &#039;&#039;[Minimum]&#039;&#039; Consumption&amp;quot;. Applied as a constant consumption-per-tick, even when the entity has the property &amp;lt;code&amp;gt;active&amp;lt;/code&amp;gt; false.&lt;br /&gt;
&lt;br /&gt;
== Burner ==&lt;br /&gt;
=== fuel_inventory_size ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/ItemStackIndex]]&lt;br /&gt;
&lt;br /&gt;
Mandatory.&lt;br /&gt;
&lt;br /&gt;
=== burnt_inventory_size ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/ItemStackIndex]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Optional.&lt;br /&gt;
&lt;br /&gt;
=== smoke ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/table]] of [[Types/SmokeSource]]&lt;br /&gt;
&lt;br /&gt;
Optional. Array of 1 or more smoke sources.&lt;br /&gt;
&lt;br /&gt;
=== light_flicker ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/LightFlickeringDefinition]]&lt;br /&gt;
&lt;br /&gt;
Optional.&lt;br /&gt;
&lt;br /&gt;
=== effectivity ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Optional. 1 means 100% effectivity. Must be greater than 0. Multiplier of the energy output.&lt;br /&gt;
&lt;br /&gt;
=== fuel_category ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;chemical&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Optional. The energy source can be used with fuel from this [[Prototype/FuelCategory|fuel category]]. For a list of built-in categories, see [[Data.raw#fuel-category]].&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;fuel_categories&amp;lt;/code&amp;gt; is defined, fuel_category is ignored.&lt;br /&gt;
&lt;br /&gt;
=== fuel_categories ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/table]] of [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Optional. Same as above, only one of them can exist. For a list of built-in categories, see [[Data.raw#fuel-category]].&lt;br /&gt;
&lt;br /&gt;
Takes precedence over &amp;lt;code&amp;gt;fuel_category&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Heat energy source ==&lt;br /&gt;
=== max_temperature ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Mandatory. max_temperature must be &amp;gt;= default_temperature.&lt;br /&gt;
&lt;br /&gt;
=== default_temperature ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 15&lt;br /&gt;
&lt;br /&gt;
Optional.&lt;br /&gt;
&lt;br /&gt;
=== specific_heat ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Energy]]&lt;br /&gt;
&lt;br /&gt;
Mandatory.&lt;br /&gt;
&lt;br /&gt;
=== max_transfer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Energy]]&lt;br /&gt;
&lt;br /&gt;
Mandatory.&lt;br /&gt;
&lt;br /&gt;
=== min_temperature_gradient ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Optional.&lt;br /&gt;
&lt;br /&gt;
=== min_working_temperature ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 15&lt;br /&gt;
&lt;br /&gt;
Optional. min_working_temperature must be &amp;gt;= default_temperature. min_working_temperature must be &amp;lt;= max_temperature.&lt;br /&gt;
&lt;br /&gt;
=== minimum_glow_temperature ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/float]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
=== pipe_covers ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Sprite4Way]]&lt;br /&gt;
&lt;br /&gt;
Optional.&lt;br /&gt;
&lt;br /&gt;
=== heat_pipe_covers ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Sprite4Way]]&lt;br /&gt;
&lt;br /&gt;
Optional.&lt;br /&gt;
&lt;br /&gt;
=== heat_picture ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Sprite4Way]]&lt;br /&gt;
&lt;br /&gt;
Optional.&lt;br /&gt;
&lt;br /&gt;
=== heat_glow ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Sprite4Way]]&lt;br /&gt;
&lt;br /&gt;
Optional.&lt;br /&gt;
&lt;br /&gt;
=== connections ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/table]] of [[Types/HeatConnection]]&lt;br /&gt;
&lt;br /&gt;
Optional. The table may only contain up to 32 connections.&lt;br /&gt;
&lt;br /&gt;
== Void energy source ==&lt;br /&gt;
Void is free energy, there are no additional entries required.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
  energy_source = {type = &amp;quot;void&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fluid energy source ==&lt;br /&gt;
=== fluid_box ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/FluidBox]]&lt;br /&gt;
&lt;br /&gt;
Mandatory.&lt;br /&gt;
All standard fluid box configurations are acceptable, but the type must be &amp;quot;input&amp;quot; or &amp;quot;input-output&amp;quot; to function correctly.&lt;br /&gt;
Scale_fluid_usage, fluid_usage_per_tick or a filter on the fluidbox must be set to be able to calculate the fluid usage of the energy source.&lt;br /&gt;
&lt;br /&gt;
=== smoke ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/table]] of [[Types/SmokeSource]]&lt;br /&gt;
&lt;br /&gt;
Optional. Array of 1 or more smoke sources.&lt;br /&gt;
&lt;br /&gt;
=== light_flicker ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/LightFlickeringDefinition]]&lt;br /&gt;
&lt;br /&gt;
Optional.&lt;br /&gt;
&lt;br /&gt;
=== effectivity ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Optional. 1 means 100% effectivity. Must be greater than 0. Multiplier of the energy output.&lt;br /&gt;
&lt;br /&gt;
=== burns_fluid ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/bool]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: false&lt;br /&gt;
&lt;br /&gt;
Optional. If set to true, the energy source will calculate power based on the fluid&#039;s fuel_value entry, else it will calculate based on fluid temperature.&lt;br /&gt;
&lt;br /&gt;
=== scale_fluid_usage ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/bool]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: false&lt;br /&gt;
&lt;br /&gt;
Optional. If set to true, the energy source will consume as much fluid as required to produce the desired power, if set to false it will consume as much as it is allowed to, wasting any excess.&lt;br /&gt;
&lt;br /&gt;
=== destroy_non_fuel_fluid ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/bool]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: true&lt;br /&gt;
&lt;br /&gt;
Optional. This property is used when:&lt;br /&gt;
* &amp;lt;code&amp;gt;burns_fluid&amp;lt;/code&amp;gt; is true and the fluid has a [[Prototype/Fluid#fuel_value|fuel_value]] of 0&lt;br /&gt;
* or &amp;lt;code&amp;gt;burns_fluid&amp;lt;/code&amp;gt; is false and the fluid is at default temperature&lt;br /&gt;
In these cases, this property determines whether the fluid should be destroyed, meaning that the fluid is consumed at the rate of &amp;lt;code&amp;gt;fluid_usage_per_tick&amp;lt;/code&amp;gt;, without producing any power.&lt;br /&gt;
&lt;br /&gt;
=== fluid_usage_per_tick ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Optional. The number of fluid units the energy source uses per tick.&lt;br /&gt;
If used with scale_fluid_usage, this specifies the maximum. If this value is not set, scale_energy_usage = false and a fluid box filter is set, the game will attempt to calculate this value from the fluid box filter&#039;s fluid&#039;s fuel_value or heat_capacity and the entity&#039;s energy_usage. If burns_fluid is false, maximum_temperature will also be used. If the attempt of the game to calculate this value fails ( scale_energy_usage = false and a fluid box filter is set), then scale_energy_usage will be forced to true, to prevent the energy source from being an infinite fluid sink.[https://forums.factorio.com/90613]&lt;br /&gt;
&lt;br /&gt;
=== maximum_temperature ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0, meaning unlimited&lt;br /&gt;
&lt;br /&gt;
If it is specified while scale_fluid_usage = false and fluid_usage_per_tick is not specified, the game will use this value to calculate fluid_usage_per_tick.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property type usage|{{FULLPAGENAME}}}}&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/CustomInput&amp;diff=190720</id>
		<title>Prototype/CustomInput</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/CustomInput&amp;diff=190720"/>
		<updated>2023-01-31T11:32:22Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: Fix CustomInputEvent links to runtime docs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Prototype parent|PrototypeBase}}&lt;br /&gt;
Used for custom keyboard shortcuts/keybindings in mods. The key associated with the custom input can be changed in the options. This means that &amp;lt;code&amp;gt;key_sequence&amp;lt;/code&amp;gt; is simply the default keybinding.&lt;br /&gt;
&lt;br /&gt;
{{Prototype TOC|custom-input}}&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
Inherits all properties from [[PrototypeBase]].&lt;br /&gt;
&lt;br /&gt;
=== name ===&lt;br /&gt;
:&#039;&#039;See [[PrototypeBase#name]]&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Inherited from [[PrototypeBase]]. It is also the name for the event that is raised when they key (combination) is pressed and action is &amp;quot;lua&amp;quot;, see [[Tutorial:Script interfaces]].&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|key_sequence|[[Types/string|string]]}}&lt;br /&gt;
The default key sequence for this custom input.&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;&amp;quot; (empty string) for unassigned&lt;br /&gt;
* &amp;quot;mouse-button-2&amp;quot; etc for mouse buttons, mouse-button-3 for middle mouse button&lt;br /&gt;
* &amp;quot;mouse-wheel-up&amp;quot;, &amp;quot;mouse-wheel-down&amp;quot;, &amp;quot;mouse-wheel-left&amp;quot;, &amp;quot;mouse-wheel-right&amp;quot; for mouse wheel&lt;br /&gt;
* &amp;quot; + &amp;quot; is used to separate modifier keys from normal keys: &amp;lt;code&amp;gt;&amp;quot;ALT + G&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* For modifier keys, the following names are used: &amp;quot;CONTROL&amp;quot;, &amp;quot;SHIFT&amp;quot;, &amp;quot;ALT&amp;quot;, &amp;quot;COMMAND&amp;quot;&lt;br /&gt;
* A keybinding can contain an unlimited amount of modifier keys (listed above) but only one normal key (listed below).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width: 40em;&amp;quot;&amp;gt;&lt;br /&gt;
These names are available for the normal keys&lt;br /&gt;
&amp;lt;pre class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
A&lt;br /&gt;
B&lt;br /&gt;
C&lt;br /&gt;
D&lt;br /&gt;
E&lt;br /&gt;
F&lt;br /&gt;
G&lt;br /&gt;
H&lt;br /&gt;
I&lt;br /&gt;
J&lt;br /&gt;
K&lt;br /&gt;
L&lt;br /&gt;
M&lt;br /&gt;
N&lt;br /&gt;
O&lt;br /&gt;
P&lt;br /&gt;
Q&lt;br /&gt;
R&lt;br /&gt;
S&lt;br /&gt;
T&lt;br /&gt;
U&lt;br /&gt;
V&lt;br /&gt;
W&lt;br /&gt;
X&lt;br /&gt;
Y&lt;br /&gt;
Z&lt;br /&gt;
1&lt;br /&gt;
2&lt;br /&gt;
3&lt;br /&gt;
4&lt;br /&gt;
5&lt;br /&gt;
6&lt;br /&gt;
7&lt;br /&gt;
8&lt;br /&gt;
9&lt;br /&gt;
0&lt;br /&gt;
RETURN&lt;br /&gt;
ESCAPE&lt;br /&gt;
BACKSPACE&lt;br /&gt;
TAB&lt;br /&gt;
SPACE&lt;br /&gt;
MINUS&lt;br /&gt;
EQUALS&lt;br /&gt;
LEFTBRACKET&lt;br /&gt;
RIGHTBRACKET&lt;br /&gt;
BACKSLASH&lt;br /&gt;
NONUSHASH&lt;br /&gt;
SEMICOLON&lt;br /&gt;
APOSTROPHE&lt;br /&gt;
GRAVE&lt;br /&gt;
COMMA&lt;br /&gt;
PERIOD&lt;br /&gt;
SLASH&lt;br /&gt;
CAPSLOCK&lt;br /&gt;
F1&lt;br /&gt;
F2&lt;br /&gt;
F3&lt;br /&gt;
F4&lt;br /&gt;
F5&lt;br /&gt;
F6&lt;br /&gt;
F7&lt;br /&gt;
F8&lt;br /&gt;
F9&lt;br /&gt;
F10&lt;br /&gt;
F11&lt;br /&gt;
F12&lt;br /&gt;
PRINTSCREEN&lt;br /&gt;
SCROLLLOCK&lt;br /&gt;
PAUSE&lt;br /&gt;
INSERT&lt;br /&gt;
HOME&lt;br /&gt;
PAGEUP&lt;br /&gt;
DELETE&lt;br /&gt;
END&lt;br /&gt;
PAGEDOWN&lt;br /&gt;
RIGHT&lt;br /&gt;
LEFT&lt;br /&gt;
DOWN&lt;br /&gt;
UP&lt;br /&gt;
NUMLOCKCLEAR&lt;br /&gt;
KP_DIVIDE&lt;br /&gt;
KP_MULTIPLY&lt;br /&gt;
KP_MINUS&lt;br /&gt;
KP_PLUS&lt;br /&gt;
KP_ENTER&lt;br /&gt;
KP_1&lt;br /&gt;
KP_2&lt;br /&gt;
KP_3&lt;br /&gt;
KP_4&lt;br /&gt;
KP_5&lt;br /&gt;
KP_6&lt;br /&gt;
KP_7&lt;br /&gt;
KP_8&lt;br /&gt;
KP_9&lt;br /&gt;
KP_0&lt;br /&gt;
KP_PERIOD&lt;br /&gt;
NONUSBACKSLASH&lt;br /&gt;
APPLICATION&lt;br /&gt;
POWER&lt;br /&gt;
KP_EQUALS&lt;br /&gt;
F13&lt;br /&gt;
F14&lt;br /&gt;
F15&lt;br /&gt;
F16&lt;br /&gt;
F17&lt;br /&gt;
F18&lt;br /&gt;
F19&lt;br /&gt;
F20&lt;br /&gt;
F21&lt;br /&gt;
F22&lt;br /&gt;
F23&lt;br /&gt;
F24&lt;br /&gt;
EXECUTE&lt;br /&gt;
HELP&lt;br /&gt;
MENU&lt;br /&gt;
SELECT&lt;br /&gt;
STOP&lt;br /&gt;
AGAIN&lt;br /&gt;
UNDO&lt;br /&gt;
CUT&lt;br /&gt;
COPY&lt;br /&gt;
PASTE&lt;br /&gt;
FIND&lt;br /&gt;
MUTE&lt;br /&gt;
VOLUMEUP&lt;br /&gt;
VOLUMEDOWN&lt;br /&gt;
KP_COMMA&lt;br /&gt;
KP_EQUALSAS400&lt;br /&gt;
INTERNATIONAL1&lt;br /&gt;
INTERNATIONAL2&lt;br /&gt;
INTERNATIONAL3&lt;br /&gt;
INTERNATIONAL4&lt;br /&gt;
INTERNATIONAL5&lt;br /&gt;
INTERNATIONAL6&lt;br /&gt;
INTERNATIONAL7&lt;br /&gt;
INTERNATIONAL8&lt;br /&gt;
INTERNATIONAL9&lt;br /&gt;
LANG1&lt;br /&gt;
LANG2&lt;br /&gt;
LANG3&lt;br /&gt;
LANG4&lt;br /&gt;
LANG5&lt;br /&gt;
LANG6&lt;br /&gt;
LANG7&lt;br /&gt;
LANG8&lt;br /&gt;
LANG9&lt;br /&gt;
ALTERASE&lt;br /&gt;
SYSREQ&lt;br /&gt;
CANCEL&lt;br /&gt;
CLEAR&lt;br /&gt;
PRIOR&lt;br /&gt;
RETURN2&lt;br /&gt;
SEPARATOR&lt;br /&gt;
OUT&lt;br /&gt;
OPER&lt;br /&gt;
CLEARAGAIN&lt;br /&gt;
CRSEL&lt;br /&gt;
EXSEL&lt;br /&gt;
KP_00&lt;br /&gt;
KP_000&lt;br /&gt;
THOUSANDSSEPARATOR&lt;br /&gt;
DECIMALSEPARATOR&lt;br /&gt;
CURRENCYUNIT&lt;br /&gt;
CURRENCYSUBUNIT&lt;br /&gt;
KP_LEFTPAREN&lt;br /&gt;
KP_RIGHTPAREN&lt;br /&gt;
KP_LEFTBRACE&lt;br /&gt;
KP_RIGHTBRACE&lt;br /&gt;
KP_TAB&lt;br /&gt;
KP_BACKSPACE&lt;br /&gt;
KP_A&lt;br /&gt;
KP_B&lt;br /&gt;
KP_C&lt;br /&gt;
KP_D&lt;br /&gt;
KP_E&lt;br /&gt;
KP_F&lt;br /&gt;
KP_XOR&lt;br /&gt;
KP_POWER&lt;br /&gt;
KP_PERCENT&lt;br /&gt;
KP_LESS&lt;br /&gt;
KP_GREATER&lt;br /&gt;
KP_AMPERSAND&lt;br /&gt;
KP_DBLAMPERSAND&lt;br /&gt;
KP_VERTICALBAR&lt;br /&gt;
KP_DBLVERTICALBAR&lt;br /&gt;
KP_COLON&lt;br /&gt;
KP_HASH&lt;br /&gt;
KP_SPACE&lt;br /&gt;
KP_AT&lt;br /&gt;
KP_EXCLAM&lt;br /&gt;
KP_MEMSTORE&lt;br /&gt;
KP_MEMRECALL&lt;br /&gt;
KP_MEMCLEAR&lt;br /&gt;
KP_MEMADD&lt;br /&gt;
KP_MEMSUBTRACT&lt;br /&gt;
KP_MEMMULTIPLY&lt;br /&gt;
KP_MEMDIVIDE&lt;br /&gt;
KP_PLUSMINUS&lt;br /&gt;
KP_CLEAR&lt;br /&gt;
KP_CLEARENTRY&lt;br /&gt;
KP_BINARY&lt;br /&gt;
KP_OCTAL&lt;br /&gt;
KP_DECIMAL&lt;br /&gt;
KP_HEXADECIMAL&lt;br /&gt;
LCTRL&lt;br /&gt;
LSHIFT&lt;br /&gt;
LALT&lt;br /&gt;
LGUI&lt;br /&gt;
RCTRL&lt;br /&gt;
RSHIFT&lt;br /&gt;
RALT&lt;br /&gt;
RGUI&lt;br /&gt;
MODE&lt;br /&gt;
AUDIONEXT&lt;br /&gt;
AUDIOPREV&lt;br /&gt;
AUDIOSTOP&lt;br /&gt;
AUDIOPLAY&lt;br /&gt;
AUDIOMUTE&lt;br /&gt;
MEDIASELECT&lt;br /&gt;
WWW&lt;br /&gt;
MAIL&lt;br /&gt;
CALCULATOR&lt;br /&gt;
COMPUTER&lt;br /&gt;
AC_SEARCH&lt;br /&gt;
AC_HOME&lt;br /&gt;
AC_BACK&lt;br /&gt;
AC_FORWARD&lt;br /&gt;
AC_STOP&lt;br /&gt;
AC_REFRESH&lt;br /&gt;
AC_BOOKMARKS&lt;br /&gt;
BRIGHTNESSDOWN&lt;br /&gt;
BRIGHTNESSUP&lt;br /&gt;
DISPLAYSWITCH&lt;br /&gt;
KBDILLUMTOGGLE&lt;br /&gt;
KBDILLUMDOWN&lt;br /&gt;
KBDILLUMUP&lt;br /&gt;
EJECT&lt;br /&gt;
SLEEP&lt;br /&gt;
APP1&lt;br /&gt;
APP2&lt;br /&gt;
AUDIOREWIND&lt;br /&gt;
AUDIOFASTFORWARD&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|alternative_key_sequence|[[Types/string|string]]|optional=true}}&lt;br /&gt;
The alternative keybinding for this control. See [[#key_sequence]].&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|linked_game_control|[[Types/string|string]]|&amp;quot;&amp;quot;|optional=true}}&lt;br /&gt;
When a custom-input is linked to a game control it won&#039;t show up in the control-settings GUI and will fire when the linked control is pressed. [https://forums.factorio.com/53591]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot; style=&amp;quot;width: 40em;&amp;quot;&amp;gt;&lt;br /&gt;
List of internal names of game controls&lt;br /&gt;
&amp;lt;pre class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
action-bar-select-page-1&lt;br /&gt;
action-bar-select-page-10&lt;br /&gt;
action-bar-select-page-2&lt;br /&gt;
action-bar-select-page-3&lt;br /&gt;
action-bar-select-page-4&lt;br /&gt;
action-bar-select-page-5&lt;br /&gt;
action-bar-select-page-6&lt;br /&gt;
action-bar-select-page-7&lt;br /&gt;
action-bar-select-page-8&lt;br /&gt;
action-bar-select-page-9&lt;br /&gt;
activate-tooltip&lt;br /&gt;
add-station&lt;br /&gt;
add-temporary-station&lt;br /&gt;
alt-zoom-in&lt;br /&gt;
alt-zoom-out&lt;br /&gt;
build&lt;br /&gt;
build-ghost&lt;br /&gt;
build-with-obstacle-avoidance&lt;br /&gt;
cancel-craft&lt;br /&gt;
cancel-craft-5&lt;br /&gt;
cancel-craft-all&lt;br /&gt;
clear-cursor&lt;br /&gt;
confirm-gui&lt;br /&gt;
confirm-message&lt;br /&gt;
connect-train&lt;br /&gt;
controller-gui-crafting-tab&lt;br /&gt;
controller-gui-logistics-tab&lt;br /&gt;
copy&lt;br /&gt;
copy-entity-settings&lt;br /&gt;
craft&lt;br /&gt;
craft-5&lt;br /&gt;
craft-all&lt;br /&gt;
cursor-split&lt;br /&gt;
cut&lt;br /&gt;
cycle-blueprint-backwards&lt;br /&gt;
cycle-blueprint-forwards&lt;br /&gt;
cycle-clipboard-backwards&lt;br /&gt;
cycle-clipboard-forwards&lt;br /&gt;
debug-reset-zoom&lt;br /&gt;
debug-reset-zoom-2x&lt;br /&gt;
debug-toggle-atlas-gui&lt;br /&gt;
debug-toggle-basic&lt;br /&gt;
debug-toggle-debug-settings&lt;br /&gt;
decrease-ui-scale&lt;br /&gt;
disconnect-train&lt;br /&gt;
drag-map&lt;br /&gt;
drop-cursor&lt;br /&gt;
editor-clone-item&lt;br /&gt;
editor-delete-item&lt;br /&gt;
editor-next-variation&lt;br /&gt;
editor-previous-variation&lt;br /&gt;
editor-remove-scripting-object&lt;br /&gt;
editor-reset-speed&lt;br /&gt;
editor-set-clone-brush-destination&lt;br /&gt;
editor-set-clone-brush-source&lt;br /&gt;
editor-speed-down&lt;br /&gt;
editor-speed-up&lt;br /&gt;
editor-switch-to-surface&lt;br /&gt;
editor-tick-once&lt;br /&gt;
editor-toggle-pause&lt;br /&gt;
fast-entity-split&lt;br /&gt;
fast-entity-transfer&lt;br /&gt;
flip-blueprint-horizontal&lt;br /&gt;
flip-blueprint-vertical&lt;br /&gt;
focus-search&lt;br /&gt;
increase-ui-scale&lt;br /&gt;
inventory-split&lt;br /&gt;
inventory-transfer&lt;br /&gt;
larger-terrain-building-area&lt;br /&gt;
logistic-networks&lt;br /&gt;
mine&lt;br /&gt;
move-down&lt;br /&gt;
move-left&lt;br /&gt;
move-right&lt;br /&gt;
move-up&lt;br /&gt;
next-active-quick-bar&lt;br /&gt;
next-player-in-replay&lt;br /&gt;
next-weapon&lt;br /&gt;
open-character-gui&lt;br /&gt;
open-gui&lt;br /&gt;
open-item&lt;br /&gt;
open-prototype-explorer-gui&lt;br /&gt;
open-prototypes-gui&lt;br /&gt;
open-technology-gui&lt;br /&gt;
open-trains-gui&lt;br /&gt;
order-to-follow&lt;br /&gt;
paste&lt;br /&gt;
paste-entity-settings&lt;br /&gt;
pause-game&lt;br /&gt;
pick-item&lt;br /&gt;
pick-items&lt;br /&gt;
place-in-chat&lt;br /&gt;
place-ping&lt;br /&gt;
previous-active-quick-bar&lt;br /&gt;
previous-mod&lt;br /&gt;
previous-technology&lt;br /&gt;
production-statistics&lt;br /&gt;
quick-bar-button-1&lt;br /&gt;
quick-bar-button-1-secondary&lt;br /&gt;
quick-bar-button-10&lt;br /&gt;
quick-bar-button-10-secondary&lt;br /&gt;
quick-bar-button-2&lt;br /&gt;
quick-bar-button-2-secondary&lt;br /&gt;
quick-bar-button-3&lt;br /&gt;
quick-bar-button-3-secondary&lt;br /&gt;
quick-bar-button-4&lt;br /&gt;
quick-bar-button-4-secondary&lt;br /&gt;
quick-bar-button-5&lt;br /&gt;
quick-bar-button-5-secondary&lt;br /&gt;
quick-bar-button-6&lt;br /&gt;
quick-bar-button-6-secondary&lt;br /&gt;
quick-bar-button-7&lt;br /&gt;
quick-bar-button-7-secondary&lt;br /&gt;
quick-bar-button-8&lt;br /&gt;
quick-bar-button-8-secondary&lt;br /&gt;
quick-bar-button-9&lt;br /&gt;
quick-bar-button-9-secondary&lt;br /&gt;
remove-pole-cables&lt;br /&gt;
reset-ui-scale&lt;br /&gt;
reverse-rotate&lt;br /&gt;
reverse-select&lt;br /&gt;
rotate&lt;br /&gt;
rotate-active-quick-bars&lt;br /&gt;
select-for-blueprint&lt;br /&gt;
select-for-cancel-deconstruct&lt;br /&gt;
shoot-enemy&lt;br /&gt;
shoot-selected&lt;br /&gt;
show-info&lt;br /&gt;
smaller-terrain-building-area&lt;br /&gt;
smart-pipette&lt;br /&gt;
stack-split&lt;br /&gt;
stack-transfer&lt;br /&gt;
toggle-blueprint-library&lt;br /&gt;
toggle-console&lt;br /&gt;
toggle-driving&lt;br /&gt;
toggle-filter&lt;br /&gt;
toggle-gui-debug&lt;br /&gt;
toggle-gui-glows&lt;br /&gt;
toggle-gui-shadows&lt;br /&gt;
toggle-gui-style-view&lt;br /&gt;
toggle-map&lt;br /&gt;
toggle-menu&lt;br /&gt;
undo&lt;br /&gt;
zoom-in&lt;br /&gt;
zoom-out&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example to use the same key sequence as the clear-cursor hotkey:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;key_sequence = &amp;quot;&amp;quot;&lt;br /&gt;
linked_game_control = &amp;quot;clear-cursor&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|consuming|[[Types/ConsumingType|ConsumingType]]|&amp;quot;none&amp;quot;|optional=true}}&lt;br /&gt;
Sets whether internal game events associated with the same key sequence should be fired or blocked. If they are fired (&amp;quot;none&amp;quot;), then the custom input event will happen before the internal game event.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|enabled|[[Types/bool|bool]]|true|optional=true}}&lt;br /&gt;
If this custom input is enabled. Disabled custom inputs exist but are not used by the game. If disabled, no event is raised when the input is used.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|enabled_while_spectating|[[Types/bool|bool]]|false|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|enabled_while_in_cutscene|[[Types/bool|bool]]|false|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|include_selected_prototype|[[Types/bool|bool]]|false|optional=true}}&lt;br /&gt;
If true, the type and name of the currently selected prototype will be provided as &amp;quot;selected_prototype&amp;quot; in the raised [https://lua-api.factorio.com/latest/events.html#CustomInputEvent lua event]. This also works in GUI&#039;s, not just the game world.[https://forums.factorio.com/96125]&lt;br /&gt;
&lt;br /&gt;
This will also return an item in the cursor such as copper-wire or rail-planner, if nothing is beneath the cursor.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|item_to_spawn|[[Types/string|string]]|optional=true}}&lt;br /&gt;
Name of a [[Prototype/Item]]. It will be created when this input is pressed and action is set to &amp;quot;spawn-item&amp;quot;. The item must have the [[Types/ItemPrototypeFlags#.22spawnable.22|&amp;quot;spawnable&amp;quot;]] flag set.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|action|[[Types/string|string]]|&amp;quot;lua&amp;quot;|optional=true}}&lt;br /&gt;
One of &amp;quot;lua&amp;quot;, &amp;quot;spawn-item&amp;quot;, &amp;quot;toggle-personal-roboport&amp;quot;, &amp;quot;toggle-personal-logistic-requests&amp;quot; and &amp;quot;toggle-equipment-movement-bonus&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A [https://lua-api.factorio.com/latest/events.html#CustomInputEvent lua event] is only raised if the action is &amp;quot;lua&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/SpiderVehicleGraphicsSet&amp;diff=190633</id>
		<title>Types/SpiderVehicleGraphicsSet</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/SpiderVehicleGraphicsSet&amp;diff=190633"/>
		<updated>2023-01-07T01:24:00Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: /* light_positions */ eyelight -&amp;gt; eye_light&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Used to specify the graphics for [[Prototype/SpiderVehicle]].&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
=== base_animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== shadow_base_animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== shadow_animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== base_render_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RenderLayer|RenderLayer]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;higher-object-under&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== render_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RenderLayer|RenderLayer]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;wires-above&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_visualisation_render_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RenderLayer|RenderLayer]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;object&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== light ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/LightDefinition|LightDefinition]]&lt;br /&gt;
&lt;br /&gt;
=== eye_light ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/LightDefinition|LightDefinition]]&lt;br /&gt;
&lt;br /&gt;
Placed in multiple positions, as determined by [[#light_positions]].&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_on_map_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_queue_on_map_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_queue_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_path_visualisation_line_width ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/float|float]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.125&lt;br /&gt;
&lt;br /&gt;
=== autopilot_path_visualisation_on_map_line_width ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/float|float]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 2.0&lt;br /&gt;
&lt;br /&gt;
=== light_positions ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/table|array]] of [[Types/table|array]] of [[Types/vector|vector]]&lt;br /&gt;
&lt;br /&gt;
Defines where each [[#eye_light]] is placed. One array per eye and each of those arrays should contain one position per body direction.&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/SpiderVehicle&amp;diff=190461</id>
		<title>Prototype/SpiderVehicle</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/SpiderVehicle&amp;diff=190461"/>
		<updated>2022-11-27T23:32:46Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: /* Optional properties */ Add note about disabling spidertron logistics to trash_inventory_size&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Prototype parent|Prototype/Vehicle}}&lt;br /&gt;
The [[spidertron]].&lt;br /&gt;
&lt;br /&gt;
{{Prototype TOC|spider-vehicle}}&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
This prototype inherits all the properties from [[Prototype/Vehicle]].&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|burner or energy_source|[[Types/EnergySource|EnergySource]]}}&lt;br /&gt;
Must be a burner energy source when using &amp;quot;burner&amp;quot;, otherwise it can also be a void energy source.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|inventory_size|[[Types/ItemStackIndex|ItemStackIndex]]}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|graphics_set|[[Types/SpiderVehicleGraphicsSet|SpiderVehicleGraphicsSet]]}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|spider_engine|[[Types/SpiderEnginePrototype|SpiderEnginePrototype]]}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|height|[[Types/float|float]]}}&lt;br /&gt;
The height of the spider affects the shooting height and the drawing of the graphics and lights.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|chunk_exploration_radius|[[Types/uint32|uint32]]}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|movement_energy_consumption|[[Types/Energy|Energy]]}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|automatic_weapon_cycling|[[Types/bool|bool]]}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|chain_shooting_cooldown_modifier|[[Types/float|float]]}}&lt;br /&gt;
This is applied whenever the spider shoots (manual and automatic targeting), &amp;lt;code&amp;gt;automatic_weapon_cycling&amp;lt;/code&amp;gt; is true and the next gun in line (which is then selected) has ammo.&amp;lt;br&amp;gt;&lt;br /&gt;
When all of the above is the case, the chain_shooting_cooldown_modifier is a multiplier on the remaining shooting cooldown: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cooldown = (remaining_cooldown × chain_shooting_cooldown_modifier)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. chain_shooting_cooldown_modifier is intended to be in the range of 0 to 1. This means that setting chain_shooting_cooldown_modifier to 0 reduces the remaining shooting cooldown to 0 while a chain_shooting_cooldown_modifier of 1 does not affect the remaining shooting cooldown at all.&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|torso_rotation_speed|[[Types/float|float]]|1|optional=true}}&lt;br /&gt;
The orientation of the torso of the spider affects the shooting direction and the drawing of the graphics and lights.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|torso_bob_speed|[[Types/float|float]]|1|optional=true}}&lt;br /&gt;
Cannot be negative.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|trash_inventory_size|[[Types/ItemStackIndex|ItemStackIndex]]|0|optional=true}}&lt;br /&gt;
If set to 0 then the spider will not have a &#039;&#039;&#039;Logistics&#039;&#039;&#039; tab.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|guns|[[Types/table|table]] of [[Types/string|string]]s of prototype names|optional=true}}&lt;br /&gt;
The guns this spider vehicle uses.&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/FluidBox&amp;diff=189800</id>
		<title>Types/FluidBox</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/FluidBox&amp;diff=189800"/>
		<updated>2022-09-01T12:32:31Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: /* Optional properties */ Document new hide_connection_info option&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
[[File:Fluidboxes.png|thumb|550px|Visual representation of base_area, base_level and height. When all the fluidboxes are connected, the water leaves fluidbox A and flows into the other 3 boxes through fluidbox B until the water level is equal in all boxes. For more info about fluids, see [[Fluid system#See also]].]]&lt;br /&gt;
Used to set the fluid amount an entity can hold, as well as the connection points for pipes leading into and out of the entity.&lt;br /&gt;
&lt;br /&gt;
Entities can have multiple fluidboxes. These can be part of a [[Types/EnergySource#Fluid_energy_source]] or be specified directly in the entity prototype. &lt;br /&gt;
&lt;br /&gt;
A fluidbox can store only one type of fluid at a time. However, a fluid system (multiple connected fluid boxes) can contain multiple different fluids, see [[Fluid_system#Fluid_mixing]]. &lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== pipe_connections ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/table]] of [[Types/PipeConnectionDefinition]]&lt;br /&gt;
&lt;br /&gt;
Max number of members is 255.&lt;br /&gt;
&lt;br /&gt;
Connection points to connect to other fluidboxes. This is also marked as blue arrows in alt mode.&lt;br /&gt;
Fluid may flow in or out depending on the `type` field of each connection.&lt;br /&gt;
Connection points may depend on the direction the entity is facing.&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
&lt;br /&gt;
=== base_area ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Must be greater than 0. The total fluid capacity of the fluid box is &amp;lt;code&amp;gt;base_area × height × 100&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== base_level ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
=== height ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Must be greater than 0. The total fluid capacity of the fluid box is &amp;lt;code&amp;gt;base_area × height × 100&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== filter ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of a [[Prototype/Fluid]]. Can be used to specify which fluid is allowed to enter this fluid box. [https://forums.factorio.com/viewtopic.php?f=28&amp;amp;t=46302]&lt;br /&gt;
&lt;br /&gt;
=== render_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RenderLayer]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;object&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== hide_connection_info ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/bool]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: false&lt;br /&gt;
&lt;br /&gt;
Hides the blue input/output arrows and icons at each connection point.&lt;br /&gt;
&lt;br /&gt;
=== pipe_covers ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Sprite4Way]]&lt;br /&gt;
&lt;br /&gt;
The pictures to show when another fluid box connects to this one.&lt;br /&gt;
&lt;br /&gt;
=== pipe_picture ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Sprite4Way]]&lt;br /&gt;
&lt;br /&gt;
=== minimum_temperature ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
The minimum temperature allowed into the fluidbox. Only applied if a &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; is specified [https://forums.factorio.com/viewtopic.php?p=496738#p496738].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;minimum_temperature = 100.0&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== maximum_temperature ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
The maximum temperature allowed into the fluidbox. Only applied if a &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; is specified [https://forums.factorio.com/viewtopic.php?p=496738#p496738].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;maximum_temperature = 1000.0&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== production_type ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;None&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
* &amp;quot;None&amp;quot; or &amp;quot;none&amp;quot;&lt;br /&gt;
* &amp;quot;input&amp;quot;&lt;br /&gt;
* &amp;quot;input-output&amp;quot;&lt;br /&gt;
* &amp;quot;output&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== secondary_draw_order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/int8]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Set the secondary draw order for all orientations. Used to determine render order for sprites with the same &amp;lt;code&amp;gt;render_layer&amp;lt;/code&amp;gt; in the same position. Sprites with a higher &amp;lt;code&amp;gt;secondary_draw_order&amp;lt;/code&amp;gt; are drawn on top.&lt;br /&gt;
&lt;br /&gt;
=== secondary_draw_orders ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/table]] of [[Types/int8]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: {north = 1, east = 1, south = 1, west = 1}&lt;br /&gt;
&lt;br /&gt;
Set the secondary draw order for each orientation. Used to determine render order for sprites with the same &amp;lt;code&amp;gt;render_layer&amp;lt;/code&amp;gt; in the same position. Sprites with a higher &amp;lt;code&amp;gt;secondary_draw_order&amp;lt;/code&amp;gt; are drawn on top.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;fluid_box =&lt;br /&gt;
    {&lt;br /&gt;
      base_area = 1,&lt;br /&gt;
      height = 2,&lt;br /&gt;
      base_level = -1,&lt;br /&gt;
      pipe_covers = pipecoverspictures(),&lt;br /&gt;
      pipe_connections =&lt;br /&gt;
      {&lt;br /&gt;
        {type = &amp;quot;input-output&amp;quot;, position = {-2, 0.5}},&lt;br /&gt;
        {type = &amp;quot;input-output&amp;quot;, position = {2, 0.5}}&lt;br /&gt;
      },&lt;br /&gt;
      production_type = &amp;quot;input-output&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/SpiderVehicleGraphicsSet&amp;diff=187902</id>
		<title>Types/SpiderVehicleGraphicsSet</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/SpiderVehicleGraphicsSet&amp;diff=187902"/>
		<updated>2022-01-21T00:56:28Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: /* light_positions */ Fix missing plural&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Used to specify the graphics for [[Prototype/SpiderVehicle]].&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
=== base_animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== shadow_base_animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== shadow_animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== base_render_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RenderLayer|RenderLayer]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;higher-object-under&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== render_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RenderLayer|RenderLayer]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;wires-above&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_visualisation_render_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RenderLayer|RenderLayer]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;object&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== light ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/LightDefinition|LightDefinition]]&lt;br /&gt;
&lt;br /&gt;
=== eye_light ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/LightDefinition|LightDefinition]]&lt;br /&gt;
&lt;br /&gt;
Placed in multiple positions, as determined by [[#light_positions]].&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_on_map_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_queue_on_map_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_queue_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_path_visualisation_line_width ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/float|float]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.125&lt;br /&gt;
&lt;br /&gt;
=== autopilot_path_visualisation_on_map_line_width ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/float|float]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 2.0&lt;br /&gt;
&lt;br /&gt;
=== light_positions ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/table|array]] of [[Types/table|array]] of [[Types/vector|vector]]&lt;br /&gt;
&lt;br /&gt;
Defines where each [[#eyelight]] is placed. One array per eye and each of those arrays should contain one position per body direction.&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/SpiderVehicleGraphicsSet&amp;diff=187800</id>
		<title>Types/SpiderVehicleGraphicsSet</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/SpiderVehicleGraphicsSet&amp;diff=187800"/>
		<updated>2022-01-06T19:56:04Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: Add eye_light and light_positions explanations.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Used to specify the graphics for [[Prototype/SpiderVehicle]].&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
=== base_animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== shadow_base_animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== shadow_animation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RotatedAnimation|RotatedAnimation]]&lt;br /&gt;
&lt;br /&gt;
=== base_render_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RenderLayer|RenderLayer]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;higher-object-under&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== render_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RenderLayer|RenderLayer]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;wires-above&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_visualisation_render_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/RenderLayer|RenderLayer]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;object&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== light ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/LightDefinition|LightDefinition]]&lt;br /&gt;
&lt;br /&gt;
=== eye_light ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/LightDefinition|LightDefinition]]&lt;br /&gt;
&lt;br /&gt;
Placed in multiple positions, as determined by [[#light_positions]].&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_on_map_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_queue_on_map_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_destination_queue_visualisation ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Animation|Animation]]&lt;br /&gt;
&lt;br /&gt;
=== autopilot_path_visualisation_line_width ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/float|float]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.125&lt;br /&gt;
&lt;br /&gt;
=== autopilot_path_visualisation_on_map_line_width ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/float|float]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 2.0&lt;br /&gt;
&lt;br /&gt;
=== light_positions ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/table|array]] of [[Types/table|array]] of [[Types/vector|vector]]&lt;br /&gt;
&lt;br /&gt;
Defines where each [[#eyelight]] is placed. One array per eye and each array should contain one position per body direction.&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/Entity&amp;diff=187421</id>
		<title>Prototype/Entity</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/Entity&amp;diff=187421"/>
		<updated>2021-11-05T17:01:02Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: /* Optional properties */ Added selection_priority tie-breaker information&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Prototype parent|PrototypeBase}}&lt;br /&gt;
Abstract base of all entities in the game.&lt;br /&gt;
Entity is basically everything that can be on the map (except tiles).&lt;br /&gt;
For in game script access to entity, take a look at [http://lua-api.factorio.com/latest/LuaEntity.html LuaEntity]&lt;br /&gt;
&lt;br /&gt;
{{Prototype TOC|&#039;&#039;abstract&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Extensions ==&lt;br /&gt;
&amp;lt;div class=&amp;quot;factorio-list&amp;quot;&amp;gt;&lt;br /&gt;
* [[Prototype/Arrow]] &#039;&#039;&#039;arrow&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/ArtilleryFlare]] &#039;&#039;&#039;artillery-flare&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/ArtilleryProjectile]] &#039;&#039;&#039;artillery-projectile&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/Beam]] &#039;&#039;&#039;beam&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/CharacterCorpse]] &#039;&#039;&#039;character-corpse&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/Cliff]] &#039;&#039;&#039;cliff&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/Corpse]] &#039;&#039;&#039;corpse&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/RailRemnants]] &#039;&#039;&#039;rail-remnants&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/DeconstructibleTileProxy]] &#039;&#039;&#039;deconstructible-tile-proxy&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/EntityGhost]] &#039;&#039;&#039;entity-ghost&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/EntityParticle]] &#039;&#039;&#039;particle&#039;&#039;&#039; (for migration, cannot be used)&lt;br /&gt;
** [[Prototype/LeafParticle]] &#039;&#039;&#039;leaf-particle&#039;&#039;&#039; (for migration, cannot be used)&lt;br /&gt;
* [[Prototype/EntityWithHealth]] &amp;lt;abstract&amp;gt;&lt;br /&gt;
** [[Prototype/Accumulator]] &#039;&#039;&#039;accumulator&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/ArtilleryTurret]] &#039;&#039;&#039;artillery-turret&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Beacon]] &#039;&#039;&#039;beacon&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Boiler]] &#039;&#039;&#039;boiler&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/BurnerGenerator]] &#039;&#039;&#039;burner-generator&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Character]] &#039;&#039;&#039;character&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Combinator]] &amp;lt;abstract&amp;gt;&lt;br /&gt;
*** [[Prototype/ArithmeticCombinator]] &#039;&#039;&#039;arithmetic-combinator&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/DeciderCombinator]] &#039;&#039;&#039;decider-combinator&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/ConstantCombinator]] &#039;&#039;&#039;constant-combinator&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Container]] &#039;&#039;&#039;container&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/LogisticContainer]] &#039;&#039;&#039;logistic-container&#039;&#039;&#039;&lt;br /&gt;
**** [[Prototype/InfinityContainer]] &#039;&#039;&#039;infinity-container&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/CraftingMachine]] &amp;lt;abstract&amp;gt;&lt;br /&gt;
*** [[Prototype/AssemblingMachine]] &#039;&#039;&#039;assembling-machine&#039;&#039;&#039;&lt;br /&gt;
**** [[Prototype/RocketSilo]] &#039;&#039;&#039;rocket-silo&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/Furnace]] &#039;&#039;&#039;furnace&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/ElectricEnergyInterface]] &#039;&#039;&#039;electric-energy-interface&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/ElectricPole]] &#039;&#039;&#039;electric-pole&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/EnemySpawner]] &#039;&#039;&#039;unit-spawner&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Fish]] &#039;&#039;&#039;fish&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/FlyingRobot]] &amp;lt;abstract&amp;gt;&lt;br /&gt;
*** [[Prototype/CombatRobot]] &#039;&#039;&#039;combat-robot&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/RobotWithLogisticInterface]] &amp;lt;abstract&amp;gt;&lt;br /&gt;
**** [[Prototype/ConstructionRobot]] &#039;&#039;&#039;construction-robot&#039;&#039;&#039;&lt;br /&gt;
**** [[Prototype/LogisticRobot]] &#039;&#039;&#039;logistic-robot&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Gate]] &#039;&#039;&#039;gate&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Generator]] &#039;&#039;&#039;generator&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/HeatInterface]] &#039;&#039;&#039;heat-interface&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/HeatPipe]] &#039;&#039;&#039;heat-pipe&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Inserter]] &#039;&#039;&#039;inserter&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Lab]] &#039;&#039;&#039;lab&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Lamp]] &#039;&#039;&#039;lamp&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/LandMine]] &#039;&#039;&#039;land-mine&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/LinkedContainer]] &#039;&#039;&#039;linked-container&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Market]] &#039;&#039;&#039;market&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/MiningDrill]] &#039;&#039;&#039;mining-drill&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/OffshorePump]] &#039;&#039;&#039;offshore-pump&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Pipe]] &#039;&#039;&#039;pipe&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/InfinityPipe]] &#039;&#039;&#039;infinity-pipe&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/PipeToGround]] &#039;&#039;&#039;pipe-to-ground&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/PlayerPort]] &#039;&#039;&#039;player-port&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/PowerSwitch]] &#039;&#039;&#039;power-switch&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/ProgrammableSpeaker]] &#039;&#039;&#039;programmable-speaker&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Pump]] &#039;&#039;&#039;pump&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Radar]] &#039;&#039;&#039;radar&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Rail]] &amp;lt;abstract&amp;gt;&lt;br /&gt;
*** [[Prototype/CurvedRail]] &#039;&#039;&#039;curved-rail&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/StraightRail]] &#039;&#039;&#039;straight-rail&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/RailSignalBase]] &amp;lt;abstract&amp;gt;&lt;br /&gt;
*** [[Prototype/RailChainSignal]] &#039;&#039;&#039;rail-chain-signal&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/RailSignal]] &#039;&#039;&#039;rail-signal&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Reactor]] &#039;&#039;&#039;reactor&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Roboport]] &#039;&#039;&#039;roboport&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/SimpleEntity]] &#039;&#039;&#039;simple-entity&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/SimpleEntityWithOwner]] &#039;&#039;&#039;simple-entity-with-owner&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/SimpleEntityWithForce]] &#039;&#039;&#039;simple-entity-with-force&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/SolarPanel]] &#039;&#039;&#039;solar-panel&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/SpiderLeg]] &#039;&#039;&#039;spider-leg&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/StorageTank]] &#039;&#039;&#039;storage-tank&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/TrainStop]] &#039;&#039;&#039;train-stop&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/TransportBeltConnectable]] &amp;lt;abstract&amp;gt;&lt;br /&gt;
*** [[Prototype/LinkedBelt]] &#039;&#039;&#039;linked-belt&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/Loader1x1]] &#039;&#039;&#039;loader-1x1&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/Loader1x2]] &#039;&#039;&#039;loader&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/Splitter]] &#039;&#039;&#039;splitter&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/TransportBelt]] &#039;&#039;&#039;transport-belt&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/UndergroundBelt]] &#039;&#039;&#039;underground-belt&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Tree]] &#039;&#039;&#039;tree&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Turret]] &#039;&#039;&#039;turret&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/AmmoTurret]] &#039;&#039;&#039;ammo-turret&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/ElectricTurret]] &#039;&#039;&#039;electric-turret&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/FluidTurret]] &#039;&#039;&#039;fluid-turret&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Unit]] &#039;&#039;&#039;unit&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Vehicle]] &amp;lt;abstract&amp;gt;&lt;br /&gt;
*** [[Prototype/Car]] &#039;&#039;&#039;car&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/RollingStock]] &amp;lt;abstract&amp;gt;&lt;br /&gt;
**** [[Prototype/ArtilleryWagon]] &#039;&#039;&#039;artillery-wagon&#039;&#039;&#039;&lt;br /&gt;
**** [[Prototype/CargoWagon]] &#039;&#039;&#039;cargo-wagon&#039;&#039;&#039;&lt;br /&gt;
**** [[Prototype/FluidWagon]] &#039;&#039;&#039;fluid-wagon&#039;&#039;&#039;&lt;br /&gt;
**** [[Prototype/Locomotive]] &#039;&#039;&#039;locomotive&#039;&#039;&#039;&lt;br /&gt;
*** [[Prototype/SpiderVehicle]] &#039;&#039;&#039;spider-vehicle&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/Wall]] &#039;&#039;&#039;wall&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/Explosion]] &#039;&#039;&#039;explosion&#039;&#039;&#039;&lt;br /&gt;
** [[Prototype/FlameThrowerExplosion]] &#039;&#039;&#039;flame-thrower-explosion&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/FireFlame]] &#039;&#039;&#039;fire&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/FluidStream]] &#039;&#039;&#039;stream&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/FlyingText]] &#039;&#039;&#039;flying-text&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/HighlightBoxEntity]] &#039;&#039;&#039;highlight-box&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/ItemEntity]] &#039;&#039;&#039;item-entity&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/ItemRequestProxy]] &#039;&#039;&#039;item-request-proxy&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/ParticleSource]] &#039;&#039;&#039;particle-source&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/Projectile]] &#039;&#039;&#039;projectile&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/ResourceEntity]] &#039;&#039;&#039;resource&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/RocketSiloRocket]] &#039;&#039;&#039;rocket-silo-rocket&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/RocketSiloRocketShadow]] &#039;&#039;&#039;rocket-silo-rocket-shadow&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/Smoke]] &amp;lt;abstract&amp;gt;&lt;br /&gt;
** [[Prototype/SimpleSmoke]] &#039;&#039;&#039;smoke&#039;&#039;&#039; (for migration, cannot be used)&lt;br /&gt;
** [[Prototype/SmokeWithTrigger]] &#039;&#039;&#039;smoke-with-trigger&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/SpeechBubble]] &#039;&#039;&#039;speech-bubble&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/Sticker]] &#039;&#039;&#039;sticker&#039;&#039;&#039;&lt;br /&gt;
* [[Prototype/TileGhost]] &#039;&#039;&#039;tile-ghost&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
Inherits all properties from [[PrototypeBase]].&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|icons, icon,  icon_size (IconSpecification)|[[Types/IconSpecification|IconSpecification]]}}&lt;br /&gt;
An icon is mandatory for entities that have at least one of these flags active: placeable-neutral, placeable-player, placeable-enemy.&lt;br /&gt;
&lt;br /&gt;
The icon will be used in the editor building selection and the bonus gui.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;icon = &amp;quot;__base__/graphics/icons/wooden-chest.png&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
:&#039;&#039;See [[PrototypeBase#order]]&#039;&#039;&lt;br /&gt;
Inherited from [[PrototypeBase]].&lt;br /&gt;
&lt;br /&gt;
The order string is taken from the items in &amp;lt;code&amp;gt;placeable_by&amp;lt;/code&amp;gt; if they exist, or from an item that has its [[Prototype/Item#place_result|place_result]] set to this entity if it exists.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|collision_box|[[Types/BoundingBox|BoundingBox]]|Empty=&amp;lt;nowiki&amp;gt;{{0, 0}, {0, 0}} means no collisions.&amp;lt;/nowiki&amp;gt;|optional=true}}&lt;br /&gt;
Specification of the entity collision boundaries.&lt;br /&gt;
&lt;br /&gt;
Empty collision box is used for smoke, projectiles, particles, explosions etc.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;collision_box = {{-0.4, -0.4}, {0.4, 0.4}}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The {0,0} coordinate in the collision box will match the entity position.&lt;br /&gt;
&lt;br /&gt;
It should be near the center of the collision box, to keep correct entity drawing order. It must include the {0,0} coordinate.&lt;br /&gt;
&lt;br /&gt;
Note, that for buildings, it is customary to leave 0.1 wide border between the edge of the tile and the edge of the building, this lets the player move between the building and electric poles/inserters etc.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|collision_mask|[[Types/CollisionMask|CollisionMask]]|&amp;lt;nowiki&amp;gt;{&amp;quot;item-layer&amp;quot;, &amp;quot;object-layer&amp;quot;, &amp;quot;player-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/nowiki&amp;gt;|optional=true}}&lt;br /&gt;
&lt;br /&gt;
Two entities can collide only if they share a layer from the collision mask.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
NOTE: &#039;&#039;&#039;Some entity types have their own default&#039;&#039;&#039; that differs from the above default. They are listed here:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
* [[Prototype/Arrow]] - no masks&lt;br /&gt;
* [[Prototype/ArtilleryFlare]] - no masks&lt;br /&gt;
* [[Prototype/ArtilleryProjectile]] - no masks&lt;br /&gt;
* [[Prototype/Beam]] - no masks&lt;br /&gt;
* [[Prototype/Car]] - &amp;lt;code&amp;gt;{&amp;quot;player-layer&amp;quot;, &amp;quot;train-layer&amp;quot;, &amp;quot;consider-tile-transitions&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/Character]] - &amp;lt;code&amp;gt;{&amp;quot;player-layer&amp;quot;, &amp;quot;train-layer&amp;quot;, &amp;quot;consider-tile-transitions&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/CharacterCorpse]] - no masks&lt;br /&gt;
* [[Prototype/Cliff]] - &amp;lt;code&amp;gt;{ &amp;quot;item-layer&amp;quot;, &amp;quot;object-layer&amp;quot;, &amp;quot;player-layer&amp;quot;, &amp;quot;water-tile&amp;quot;, &amp;quot;not-colliding-with-itself&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/Corpse]] - no masks&lt;br /&gt;
* [[Prototype/DeconstructibleTileProxy]] - &amp;lt;code&amp;gt;{&amp;quot;ground-tile&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/EntityGhost]] - &amp;lt;code&amp;gt;{&amp;quot;ghost-layer&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/EntityParticle]] - no masks&lt;br /&gt;
* [[Prototype/Explosion]] - no masks&lt;br /&gt;
* [[Prototype/FireFlame]] - no masks&lt;br /&gt;
* [[Prototype/Fish]] - &amp;lt;code&amp;gt;{&amp;quot;ground-tile&amp;quot;, &amp;quot;colliding-with-tiles-only&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/FluidStream]] - no masks&lt;br /&gt;
* [[Prototype/FlyingRobot]] - no masks&lt;br /&gt;
* [[Prototype/FlyingText]] - no masks&lt;br /&gt;
* [[Prototype/Gate]] - &amp;lt;code&amp;gt;{&amp;quot;item-layer&amp;quot;, &amp;quot;object-layer&amp;quot;, &amp;quot;player-layer&amp;quot;, &amp;quot;water-tile&amp;quot;, &amp;quot;train-layer&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/HeatPipe]] - &amp;lt;code&amp;gt;{&amp;quot;object-layer&amp;quot;, &amp;quot;floor-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/HighlightBoxEntity]] - no masks&lt;br /&gt;
* [[Prototype/ItemEntity]] - &amp;lt;code&amp;gt;{&amp;quot;item-layer&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/ItemRequestProxy]] - no masks&lt;br /&gt;
* [[Prototype/LandMine]] - &amp;lt;code&amp;gt;{&amp;quot;object-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/LinkedBelt]] - &amp;lt;code&amp;gt;{&amp;quot;object-layer&amp;quot;, &amp;quot;item-layer&amp;quot;, &amp;quot;transport-belt-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/Loader1x1]] - &amp;lt;code&amp;gt;{&amp;quot;object-layer&amp;quot;, &amp;quot;item-layer&amp;quot;, &amp;quot;transport-belt-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/Loader1x2]] - &amp;lt;code&amp;gt;{&amp;quot;object-layer&amp;quot;, &amp;quot;item-layer&amp;quot;, &amp;quot;transport-belt-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/ParticleSource]] - no masks&lt;br /&gt;
* [[Prototype/PlayerPort]] - &amp;lt;code&amp;gt;{&amp;quot;object-layer&amp;quot;, &amp;quot;floor-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/Projectile]] - no masks&lt;br /&gt;
* [[Prototype/Rail]] - &amp;lt;code&amp;gt;{&amp;quot;item-layer&amp;quot;, &amp;quot;object-layer&amp;quot;,  &amp;quot;rail-layer&amp;quot;, &amp;quot;floor-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/RailSignalBase]] - &amp;lt;code&amp;gt;{&amp;quot;floor-layer&amp;quot;, &amp;quot;rail-layer&amp;quot;, &amp;quot;item-layer&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/ResourceEntity]] - &amp;lt;code&amp;gt;{&amp;quot;resource-layer&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/RollingStock]] - &amp;lt;code&amp;gt;{&amp;quot;train-layer&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/Smoke]] - no masks&lt;br /&gt;
* [[Prototype/SpeechBubble]] - no masks&lt;br /&gt;
* [[Prototype/SpiderLeg]] - &amp;lt;code&amp;gt;{&amp;quot;player-layer&amp;quot;, &amp;quot;rail-layer&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/Splitter]] - &amp;lt;code&amp;gt;{&amp;quot;object-layer&amp;quot;, &amp;quot;item-layer&amp;quot;, &amp;quot;transport-belt-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/Sticker]] - no masks&lt;br /&gt;
* [[Prototype/TileGhost]] - &amp;lt;code&amp;gt;{&amp;quot;ghost-layer&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/TransportBelt]] - &amp;lt;code&amp;gt;{&amp;quot;object-layer&amp;quot;, &amp;quot;floor-layer&amp;quot;, &amp;quot;transport-belt-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/UndergroundBelt]] - &amp;lt;code&amp;gt;{&amp;quot;object-layer&amp;quot;, &amp;quot;item-layer&amp;quot;, &amp;quot;transport-belt-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/Unit]] - &amp;lt;code&amp;gt;{&amp;quot;player-layer&amp;quot;, &amp;quot;train-layer&amp;quot;, &amp;quot;not-colliding-with-itself&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Prototype/Vehicle]] - &amp;lt;code&amp;gt;{&amp;quot;player-layer&amp;quot;, &amp;quot;train-layer&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|map_generator_bounding_box|[[Types/BoundingBox|BoundingBox]]|The value of collision box.|optional=true}}&lt;br /&gt;
Used instead of the collision box during map generation. Allows space entities differently during map generation, for example if the box is bigger, the entities will be placed farther apart.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|selection_box|[[Types/BoundingBox|BoundingBox]]|&amp;lt;nowiki&amp;gt;Empty = {{0, 0}, {0, 0}}&amp;lt;/nowiki&amp;gt;|optional=true}}&lt;br /&gt;
Specification of the entity selection area.&lt;br /&gt;
When empty  the entity will have no selection area (and thus is not selectable).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;selection_box = {{-0.5, -0.5}, {0.5, 0.5}}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The selection box is usually a little bit bigger than the collision box, for tilable entities (like buildings) it should match the tile size of the building.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|drawing_box|[[Types/BoundingBox|BoundingBox]]|&amp;lt;nowiki&amp;gt;Empty = {{0, 0}, {0, 0}} (selection_box is used instead)&amp;lt;/nowiki&amp;gt;|optional=true}}&lt;br /&gt;
Specification of space needed to see the whole entity. &lt;br /&gt;
&lt;br /&gt;
This is used to calculate the correct zoom and positioning in the entity info gui.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;drawing_box = {{-0.5, -0.5}, {0.5, 0.5}}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|sticker_box|[[Types/BoundingBox|BoundingBox]]|The value of collision box.|optional=true}}&lt;br /&gt;
Used to set the area of the entity that can have stickers on it, currently only used for units to specify the area where the green slow down stickers can appear.&lt;br /&gt;
It is optional and the collision box is used when not specified.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;sticker_box = {{-0.5, -0.5}, {0.5, 0.5}}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|hit_visualization_box|[[Types/BoundingBox|BoundingBox]]|&amp;lt;nowiki&amp;gt;Empty = {{0, 0}, {0, 0}}&amp;lt;/nowiki&amp;gt;|optional=true}}&lt;br /&gt;
Where beams should hit the entity. Useful if the bounding box only covers part of the entity (e.g. feet of the character) and beams only hitting there would look weird.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|trigger_target_mask|[[Types/TriggerTargetMask|TriggerTargetMask]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|flags|[[Types/EntityPrototypeFlags|EntityPrototypeFlags]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|minable|[[Types/MinableProperties|MinableProperties]]|not minable|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|subgroup|[[Types/string|string]]|optional=true}}&lt;br /&gt;
The name of the subgroup this entity should be sorted into in the map editor building selection.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|allow_copy_paste|[[Types/bool|bool]]|true|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|selectable_in_game|[[Types/bool|bool]]|true|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|selection_priority|[[Types/uint8|uint8]]|50|optional=true}}&lt;br /&gt;
The entity with the higher number is selectable before the entity with the lower number. When two entities have the same selection priority, the one with the highest [[Types/CollisionMask|collision mask]] (as determined by the order on that page) is selected.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|remove_decoratives|[[Types/string|string]]|&amp;quot;automatic&amp;quot;|optional=true}}&lt;br /&gt;
Either &amp;quot;automatic&amp;quot;, &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;. Whether this entity should remove decoratives that collide with it when this entity is built. When set to &amp;quot;automatic&amp;quot;, if the entity type is considered a building (e.g. an assembling machine or a wall) it will remove decoratives.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|emissions_per_second|[[Types/double|double]]|0|optional=true}}&lt;br /&gt;
Amount of emissions created (positive number) or cleaned (negative number) every second by the entity.&lt;br /&gt;
This is passive, and it is independent concept of the emissions of machines, these are created actively depending on the power consumption.&lt;br /&gt;
Currently used just for trees.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;emissions_per_second = -0.001 -- cleaning effect of big tree&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|shooting_cursor_size|[[Types/double|double]]|optional=true}}&lt;br /&gt;
The cursor size used when shooting at this entity.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|created_smoke|[[Types/CreateTrivialSmokeEffectItem|CreateTrivialSmokeEffectItem]]|The &amp;quot;smoke-building&amp;quot;-smoke|optional=true}}&lt;br /&gt;
The smoke that is shown when the entity is placed.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|working_sound|[[Types/WorkingSound|WorkingSound]]|optional=true}}&lt;br /&gt;
Will also work on entities that don&#039;t actually do work.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|created_effect|[[Types/Trigger|Trigger]]|optional=true}}&lt;br /&gt;
The effect/trigger that happens when the entity is placed.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|build_sound|[[Types/Sound|Sound]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|mined_sound|[[Types/Sound|Sound]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|mining_sound|[[Types/Sound|Sound]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|rotated_sound|[[Types/Sound|Sound]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|vehicle_impact_sound|[[Types/Sound|Sound]]|optional=true}}&lt;br /&gt;
When playing this sound, the volume is scaled by the speed of the vehicle when colliding with this entity.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|open_sound|[[Types/Sound|Sound]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|close_sound|[[Types/Sound|Sound]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|radius_visualisation_specification|[[Types/RadiusVisualisationSpecification|RadiusVisualisationSpecification]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|build_base_evolution_requirement|[[Types/double|double]]|0|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|alert_icon_shift|[[Types/vector|vector]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|alert_icon_scale|[[Types/float|float]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|fast_replaceable_group|[[Types/string|string]]|&amp;quot;&amp;quot;|optional=true}}&lt;br /&gt;
This allows you to replace an entity that&#039;s already placed, with a different one in your inventory. For example, replacing a burner inserter with a fast inserter.&lt;br /&gt;
&lt;br /&gt;
This is simply a string, so any string can be used here. The entity that should be replaced simply has to use the same string here.&lt;br /&gt;
&lt;br /&gt;
The ones the game uses are:&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;container&amp;quot;&lt;br /&gt;
    &amp;quot;furnace&amp;quot;&lt;br /&gt;
    &amp;quot;transport-belt&amp;quot;&lt;br /&gt;
    &amp;quot;electric-pole&amp;quot;&lt;br /&gt;
    &amp;quot;steam-engine&amp;quot;&lt;br /&gt;
    &amp;quot;inserter&amp;quot;&lt;br /&gt;
    &amp;quot;long-handed-inserter&amp;quot;&lt;br /&gt;
    &amp;quot;pipe&amp;quot;&lt;br /&gt;
    &amp;quot;assembling-machine&amp;quot;&lt;br /&gt;
    &amp;quot;wall&amp;quot;&lt;br /&gt;
    &amp;quot;loader&amp;quot;&lt;br /&gt;
    &amp;quot;rail-signal&amp;quot;&lt;br /&gt;
    &amp;quot;mining-drill&amp;quot;&lt;br /&gt;
    &amp;quot;pumpjack&amp;quot;&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|next_upgrade|[[Types/string|string]]|optional=true}}&lt;br /&gt;
Name of the entity that will be automatically selected as the upgrade of this entity when using the [[upgrade planner]] without configuration.&lt;br /&gt;
&lt;br /&gt;
This entity may not have &#039;not-upgradable&#039; flag set and must be minable. This entity mining result must not contain item product with &amp;quot;hidden&amp;quot; flag set. Mining results with no item products are allowed. The entity may not be a [[Prototype/RollingStock]].&amp;lt;br&amp;gt;&lt;br /&gt;
The upgrade target entity needs to have the same bounding box, collision mask, and fast replaceable group as this entity. The upgrade target entity must have least 1 item that builds it that isn&#039;t hidden.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|placeable_by|[[Types/ItemToPlace|ItemToPlace]] or [[Types/table|table]] of [[Types/ItemToPlace|ItemToPlace]]|optional=true}}&lt;br /&gt;
Item that when placed creates this entity. Determines which item is picked when &amp;quot;Q&amp;quot; (smart pipette) is used on the entity, determines which item is needed in a blueprint of this entity.&lt;br /&gt;
&lt;br /&gt;
The item count specified here can&#039;t be larger than the stack size of that item.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|remains_when_mined|[[Types/string|string]] or [[Types/table|table]] of [[Types/string|string]]|optional=true}}&lt;br /&gt;
The entity that remains when this one is mined, deconstructed or fast-replaced. The entity wont actually be spawned if it would collide with the entity that is in the process of being mined.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|additional_pastable_entities|[[Types/table|table]] of [[Types/string|string]]|optional=true}}&lt;br /&gt;
Names of the entity prototypes this entity prototype can be pasted on to in addition to the standard supported types.&lt;br /&gt;
This is used to allow copying between types that aren&#039;t compatible on the C++ code side, by allowing mods to receive the [https://lua-api.factorio.com/latest/events.html#on_entity_settings_pasted on_entity_settings_pasted] event for the given entity and do the setting pasting via script.&amp;lt;br&amp;gt;&lt;br /&gt;
 additional_pastable_entities = {&amp;quot;steel-chest&amp;quot;, &amp;quot;iron-chest&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|tile_width|[[Types/uint32|uint32]]|calculated by the collision box width rounded up.|optional=true}}&lt;br /&gt;
Used to determine how the center of the entity should be positioned when building (unless the offgrid [[Types/EntityPrototypeFlags|flag]] is specified).&lt;br /&gt;
When the tile width is odd, the center will be in the center of the tile, when it is even, the center is on the tile transition.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|tile_height|[[Types/uint32|uint32]]|calculated by the collision box height rounded up.|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|autoplace|[[Types/AutoplaceSpecification|AutoplaceSpecification]]|nil (entity is not autoplacable)|optional=true}}&lt;br /&gt;
Used to specify the rules for placing this entity during map generation.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|map_color|[[Types/Color|Color]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|friendly_map_color|[[Types/Color|Color]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|enemy_map_color|[[Types/Color|Color]]|optional=true}}&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|water_reflection|[[Types/WaterReflectionDefinition|WaterReflectionDefinition]]|optional=true}}&lt;br /&gt;
May also be defined inside &amp;lt;code&amp;gt;graphics_set&amp;lt;/code&amp;gt; instead of directly in the entity prototype. This is useful for entities that use the a &amp;lt;code&amp;gt;graphics_set&amp;lt;/code&amp;gt; property to define their graphics, becausen then all graphics can be in defined one place.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;{&lt;br /&gt;
    type = &amp;quot;container&amp;quot;,&lt;br /&gt;
    name = &amp;quot;wooden-chest&amp;quot;,&lt;br /&gt;
    icon = &amp;quot;__base__/graphics/icons/wooden-chest.png&amp;quot;,&lt;br /&gt;
    flags = {&amp;quot;placeable-neutral&amp;quot;, &amp;quot;player-creation&amp;quot;},&lt;br /&gt;
    minable = {mining_time = 1, result = &amp;quot;wooden-chest&amp;quot;},&lt;br /&gt;
    max_health = 100,&lt;br /&gt;
    corpse = &amp;quot;small-remnants&amp;quot;,&lt;br /&gt;
    collision_box = {{-0.35, -0.35}, {0.35, 0.35}},&lt;br /&gt;
    fast_replaceable_group = &amp;quot;container&amp;quot;,&lt;br /&gt;
    selection_box = {{-0.5, -0.5}, {0.5, 0.5}},&lt;br /&gt;
    inventory_size = 16,&lt;br /&gt;
    open_sound = { filename = &amp;quot;__base__/sound/wooden-chest-open.ogg&amp;quot; },&lt;br /&gt;
    close_sound = { filename = &amp;quot;__base__/sound/wooden-chest-close.ogg&amp;quot; },&lt;br /&gt;
    vehicle_impact_sound =  { filename = &amp;quot;__base__/sound/car-wood-impact.ogg&amp;quot;, volume = 1.0 },&lt;br /&gt;
    picture =&lt;br /&gt;
    {&lt;br /&gt;
      filename = &amp;quot;__base__/graphics/entity/wooden-chest/wooden-chest.png&amp;quot;,&lt;br /&gt;
      priority = &amp;quot;extra-high&amp;quot;,&lt;br /&gt;
      width = 46,&lt;br /&gt;
      height = 33,&lt;br /&gt;
      shift = {0.25, 0.015625}&lt;br /&gt;
    },&lt;br /&gt;
    circuit_wire_connection_point =&lt;br /&gt;
    {&lt;br /&gt;
      shadow =&lt;br /&gt;
      {&lt;br /&gt;
        red = {0.734375, 0.453125},&lt;br /&gt;
        green = {0.609375, 0.515625},&lt;br /&gt;
      },&lt;br /&gt;
      wire =&lt;br /&gt;
      {&lt;br /&gt;
        red = {0.40625, 0.21875},&lt;br /&gt;
        green = {0.40625, 0.375},&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    circuit_connector_sprites = get_circuit_connector_sprites({0.1875, 0.15625}, nil, 18),&lt;br /&gt;
    circuit_wire_max_distance = 9&lt;br /&gt;
  }&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/CollisionMask&amp;diff=187420</id>
		<title>Types/CollisionMask</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/CollisionMask&amp;diff=187420"/>
		<updated>2021-11-05T16:06:55Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: /* Layers */ Reorder list based on internal implementation order&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The collision mask is specified as an Array ([[Types/table]]) of strings. Every entry is a specification of one layer the object collides with or a special collision option.&lt;br /&gt;
&lt;br /&gt;
Supplying an empty table means that no layers and no collision options are set.&lt;br /&gt;
&lt;br /&gt;
The base game provides common collision mask functions in a Lua file in the core lualib: [https://github.com/wube/factorio-data/blob/master/core/lualib/collision-mask-util.lua collision-mask-util.lua].&lt;br /&gt;
&lt;br /&gt;
== Layers ==&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;ground-tile&amp;quot;&lt;br /&gt;
* &amp;quot;water-tile&amp;quot;&lt;br /&gt;
* &amp;quot;resource-layer&amp;quot;&lt;br /&gt;
* &amp;quot;doodad-layer&amp;quot;&lt;br /&gt;
* &amp;quot;floor-layer&amp;quot;&lt;br /&gt;
* &amp;quot;rail-layer&amp;quot;&lt;br /&gt;
* &amp;quot;transport-belt-layer&amp;quot;&lt;br /&gt;
* &amp;quot;item-layer&amp;quot;&lt;br /&gt;
* &amp;quot;ghost-layer&amp;quot;&lt;br /&gt;
* &amp;quot;object-layer&amp;quot;&lt;br /&gt;
* &amp;quot;player-layer&amp;quot;&lt;br /&gt;
* &amp;quot;train-layer&amp;quot;&lt;br /&gt;
* &amp;quot;layer-&amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;&amp;quot; where &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; is between 13 and 55, inclusive (layer-13 through layer-55) &lt;br /&gt;
&lt;br /&gt;
Layer-13 through layer-55 are currently unused by the core game. If a mod is going to use one of the unused layers it&#039;s recommended to use the &amp;lt;code&amp;gt;collision_mask_util.get_first_unused_layer()&amp;lt;/code&amp;gt; from the above linked library. If the library is not used, it is recommended start at the higher layers because the base game will take from the lower ones.&lt;br /&gt;
&lt;br /&gt;
== Collision options ==&lt;br /&gt;
These are not collision masks, instead they control other aspects of collision, but they are still specified here.&lt;br /&gt;
=== &amp;quot;not-colliding-with-itself&amp;quot; ===&lt;br /&gt;
Any 2 entities that both have this option enabled on their prototype and have an identical collision mask layers list will not collide. Other collision mask options are not included in the identical layer list check. This does mean that 2 different prototypes with the same collision mask layers and this option enabled will not collide.&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;consider-tile-transitions&amp;quot; ===&lt;br /&gt;
&lt;br /&gt;
Uses the prototypes position rather than its collision box when doing collision checks with tile prototypes. Allows the prototype to overlap colliding tiles up until its center point.&lt;br /&gt;
This is only respected for character movement and cars driven by players. &lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;colliding-with-tiles-only&amp;quot; ===&lt;br /&gt;
Any prototype with this collision option will only be checked for collision with other prototype&#039;s collision masks if they are a tile.&lt;br /&gt;
&lt;br /&gt;
== Default collision masks ==&lt;br /&gt;
The default collision masks of all entity types can be found [[Prototype/Entity#collision_mask|here]].&lt;br /&gt;
&lt;br /&gt;
Example (Most common collision mask of buildings):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;collision_mask = { &amp;quot;item-layer&amp;quot;, &amp;quot;object-layer&amp;quot;, &amp;quot;player-layer&amp;quot;, &amp;quot;water-tile&amp;quot;}&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/Shortcut&amp;diff=186759</id>
		<title>Prototype/Shortcut</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/Shortcut&amp;diff=186759"/>
		<updated>2021-08-09T21:12:59Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: disabled_small_icon&amp;#039;s default behaviour changed in 1.1.37 to inherit from disabled_icon instead of icon. Added internal links (`icon` -&amp;gt; `#icon`)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Prototype parent|PrototypeBase}}&lt;br /&gt;
Definition for a shortcut button in the [[shortcut bar]].&amp;lt;br&amp;gt;&lt;br /&gt;
This is &#039;&#039;not&#039;&#039; a custom keybinding (keyboard shortcut), for that see [[Prototype/CustomInput]]&lt;br /&gt;
&lt;br /&gt;
{{Prototype TOC|shortcut}}&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
Inherits all properties from [[PrototypeBase]].&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|action|[[Types/string|string]]}}&lt;br /&gt;
One of &amp;quot;toggle-alt-mode&amp;quot;, &amp;quot;undo&amp;quot;, &amp;quot;copy&amp;quot;, &amp;quot;cut&amp;quot;, &amp;quot;paste&amp;quot;, &amp;quot;import-string&amp;quot;, &amp;quot;toggle-personal-roboport&amp;quot;, &amp;quot;toggle-equipment-movement-bonus&amp;quot;, &amp;quot;spawn-item&amp;quot; and &amp;quot;lua&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|icon|[[Types/Sprite|Sprite]]}}&lt;br /&gt;
Scales to fit a 16x16-pixel square.&amp;lt;br /&amp;gt;&lt;br /&gt;
Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|item_to_spawn|[[Types/string|string]]|optional=true}}&lt;br /&gt;
Name of a [[Prototype/Item]]. The item to create when clicking on a shortcut with the action set to &amp;quot;spawn-item&amp;quot;. The item must have the [[Types/ItemPrototypeFlags#.22spawnable.22|&amp;quot;spawnable&amp;quot;]] flag set.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|technology_to_unlock|[[Types/string|string]]|optional=true}}&lt;br /&gt;
Name of a [[Prototype/Technology]]. The technology that must be researched before this shortcut can be used.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|toggleable|[[Types/bool|bool]]|false|optional=true}}&lt;br /&gt;
Must be enabled for the Factorio API to be able to set the toggled state on the shortcut button, see [https://lua-api.factorio.com/latest/LuaPlayer.html#LuaPlayer.set_shortcut_toggled LuaPlayer.set_shortcut_toggled].&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|associated_control_input|[[Types/string|string]]|&amp;quot;&amp;quot;|optional=true}}&lt;br /&gt;
Name of a custom input or vanilla control. Used to show the keybind in the tooltip of the shortcut.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|small_icon|[[Types/Sprite|Sprite]]|Uses [[#icon]] definition|optional=true}}&lt;br /&gt;
The icon used in the panel for visible shortcuts, when the shortcut is usable.&amp;lt;br /&amp;gt;&lt;br /&gt;
Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|disabled_icon|[[Types/Sprite|Sprite]]|Uses [[#icon]] definition|optional=true}}&lt;br /&gt;
The icon used when the shortcut is shown in the quickbar, and is not usable.&amp;lt;br /&amp;gt;&lt;br /&gt;
Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|disabled_small_icon|[[Types/Sprite|Sprite]]| Uses [[#disabled_icon]] definition|optional=true}}&lt;br /&gt;
The icon used in the panel for visible shortcuts, when the shortcut is not usable.&amp;lt;br /&amp;gt;&lt;br /&gt;
Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|style|[[Types/string|string]]|&amp;quot;default&amp;quot;|optional=true}}&lt;br /&gt;
One of &amp;quot;default&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;red&amp;quot; and &amp;quot;green&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;  {&lt;br /&gt;
    type = &amp;quot;shortcut&amp;quot;,&lt;br /&gt;
    name = &amp;quot;give-deconstruction-planner&amp;quot;,&lt;br /&gt;
    order = &amp;quot;b[blueprints]-g[deconstruction-planner]&amp;quot;,&lt;br /&gt;
    action = &amp;quot;spawn-item&amp;quot;,&lt;br /&gt;
    localised_name = {&amp;quot;shortcut.make-deconstruction-planner&amp;quot;},&lt;br /&gt;
    associated_control_input = &amp;quot;give-deconstruction-planner&amp;quot;,&lt;br /&gt;
    technology_to_unlock = &amp;quot;construction-robotics&amp;quot;,&lt;br /&gt;
    item_to_spawn = &amp;quot;deconstruction-planner&amp;quot;,&lt;br /&gt;
    style = &amp;quot;red&amp;quot;,&lt;br /&gt;
    icon =&lt;br /&gt;
    {&lt;br /&gt;
      filename = &amp;quot;__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x32-white.png&amp;quot;,&lt;br /&gt;
      priority = &amp;quot;extra-high-no-scale&amp;quot;,&lt;br /&gt;
      size = 32,&lt;br /&gt;
      mipmap_count = 2,&lt;br /&gt;
      flags = {&amp;quot;gui-icon&amp;quot;}&lt;br /&gt;
    },&lt;br /&gt;
    small_icon =&lt;br /&gt;
    {&lt;br /&gt;
      filename = &amp;quot;__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x24-white.png&amp;quot;,&lt;br /&gt;
      priority = &amp;quot;extra-high-no-scale&amp;quot;,&lt;br /&gt;
      size = 24,&lt;br /&gt;
      mipmap_count = 2,&lt;br /&gt;
      flags = {&amp;quot;gui-icon&amp;quot;}&lt;br /&gt;
    },&lt;br /&gt;
    disabled_small_icon =&lt;br /&gt;
    {&lt;br /&gt;
      filename = &amp;quot;__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x24-white.png&amp;quot;,&lt;br /&gt;
      priority = &amp;quot;extra-high-no-scale&amp;quot;,&lt;br /&gt;
      size = 24,&lt;br /&gt;
      mipmap_count = 2,&lt;br /&gt;
      flags = {&amp;quot;gui-icon&amp;quot;}&lt;br /&gt;
    }&lt;br /&gt;
  }&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/Shortcut&amp;diff=186580</id>
		<title>Prototype/Shortcut</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/Shortcut&amp;diff=186580"/>
		<updated>2021-07-18T21:33:48Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: Add default info to optional icon properties; wording can probably be improved&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Prototype parent|PrototypeBase}}&lt;br /&gt;
Definition for a shortcut button in the [[shortcut bar]].&amp;lt;br&amp;gt;&lt;br /&gt;
This is &#039;&#039;not&#039;&#039; a custom keybinding (keyboard shortcut), for that see [[Prototype/CustomInput]]&lt;br /&gt;
&lt;br /&gt;
{{Prototype TOC|shortcut}}&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
Inherits all properties from [[PrototypeBase]].&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|action|[[Types/string|string]]}}&lt;br /&gt;
One of &amp;quot;toggle-alt-mode&amp;quot;, &amp;quot;undo&amp;quot;, &amp;quot;copy&amp;quot;, &amp;quot;cut&amp;quot;, &amp;quot;paste&amp;quot;, &amp;quot;import-string&amp;quot;, &amp;quot;toggle-personal-roboport&amp;quot;, &amp;quot;toggle-equipment-movement-bonus&amp;quot;, &amp;quot;spawn-item&amp;quot; and &amp;quot;lua&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|icon|[[Types/Sprite|Sprite]]}}&lt;br /&gt;
Scales to fit a 16x16-pixel square.&amp;lt;br /&amp;gt;&lt;br /&gt;
Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|item_to_spawn|[[Types/string|string]]|optional=true}}&lt;br /&gt;
Name of a [[Prototype/Item]]. The item to create when clicking on a shortcut with the action set to &amp;quot;spawn-item&amp;quot;. The item must have the [[Types/ItemPrototypeFlags#.22spawnable.22|&amp;quot;spawnable&amp;quot;]] flag set.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|technology_to_unlock|[[Types/string|string]]|optional=true}}&lt;br /&gt;
Name of a [[Prototype/Technology]]. The technology that must be researched before this shortcut can be used.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|toggleable|[[Types/bool|bool]]|false|optional=true}}&lt;br /&gt;
Must be enabled for the Factorio API to be able to set the toggled state on the shortcut button, see [https://lua-api.factorio.com/latest/LuaPlayer.html#LuaPlayer.set_shortcut_toggled LuaPlayer.set_shortcut_toggled].&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|associated_control_input|[[Types/string|string]]|&amp;quot;&amp;quot;|optional=true}}&lt;br /&gt;
Name of a custom input or vanilla control. Used to show the keybind in the tooltip of the shortcut.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|small_icon|[[Types/Sprite|Sprite]]|Uses icon definition|optional=true}}&lt;br /&gt;
The icon used in the panel for visible shortcuts, when the shortcut is usable.&amp;lt;br /&amp;gt;&lt;br /&gt;
Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|disabled_icon|[[Types/Sprite|Sprite]]|Uses icon definition|optional=true}}&lt;br /&gt;
The icon used when the shortcut is shown in the quickbar, and is not usable.&amp;lt;br /&amp;gt;&lt;br /&gt;
Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|disabled_small_icon|[[Types/Sprite|Sprite]]|Uses icon definition|optional=true}}&lt;br /&gt;
The icon used in the panel for visible shortcuts, when the shortcut is not usable.&amp;lt;br /&amp;gt;&lt;br /&gt;
Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.&lt;br /&gt;
&lt;br /&gt;
{{Prototype property|style|[[Types/string|string]]|&amp;quot;default&amp;quot;|optional=true}}&lt;br /&gt;
One of &amp;quot;default&amp;quot;, &amp;quot;blue&amp;quot;, &amp;quot;red&amp;quot; and &amp;quot;green&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;  {&lt;br /&gt;
    type = &amp;quot;shortcut&amp;quot;,&lt;br /&gt;
    name = &amp;quot;give-deconstruction-planner&amp;quot;,&lt;br /&gt;
    order = &amp;quot;b[blueprints]-g[deconstruction-planner]&amp;quot;,&lt;br /&gt;
    action = &amp;quot;spawn-item&amp;quot;,&lt;br /&gt;
    localised_name = {&amp;quot;shortcut.make-deconstruction-planner&amp;quot;},&lt;br /&gt;
    associated_control_input = &amp;quot;give-deconstruction-planner&amp;quot;,&lt;br /&gt;
    technology_to_unlock = &amp;quot;construction-robotics&amp;quot;,&lt;br /&gt;
    item_to_spawn = &amp;quot;deconstruction-planner&amp;quot;,&lt;br /&gt;
    style = &amp;quot;red&amp;quot;,&lt;br /&gt;
    icon =&lt;br /&gt;
    {&lt;br /&gt;
      filename = &amp;quot;__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x32-white.png&amp;quot;,&lt;br /&gt;
      priority = &amp;quot;extra-high-no-scale&amp;quot;,&lt;br /&gt;
      size = 32,&lt;br /&gt;
      mipmap_count = 2,&lt;br /&gt;
      flags = {&amp;quot;gui-icon&amp;quot;}&lt;br /&gt;
    },&lt;br /&gt;
    small_icon =&lt;br /&gt;
    {&lt;br /&gt;
      filename = &amp;quot;__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x24-white.png&amp;quot;,&lt;br /&gt;
      priority = &amp;quot;extra-high-no-scale&amp;quot;,&lt;br /&gt;
      size = 24,&lt;br /&gt;
      mipmap_count = 2,&lt;br /&gt;
      flags = {&amp;quot;gui-icon&amp;quot;}&lt;br /&gt;
    },&lt;br /&gt;
    disabled_small_icon =&lt;br /&gt;
    {&lt;br /&gt;
      filename = &amp;quot;__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x24-white.png&amp;quot;,&lt;br /&gt;
      priority = &amp;quot;extra-high-no-scale&amp;quot;,&lt;br /&gt;
      size = 24,&lt;br /&gt;
      mipmap_count = 2,&lt;br /&gt;
      flags = {&amp;quot;gui-icon&amp;quot;}&lt;br /&gt;
    }&lt;br /&gt;
  }&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Tutorial:Modding_tutorial/Gangsir&amp;diff=186012</id>
		<title>Tutorial:Modding tutorial/Gangsir</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Tutorial:Modding_tutorial/Gangsir&amp;diff=186012"/>
		<updated>2021-05-06T22:54:47Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: Update from 1.0 to 1.1&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
This is a modding tutorial for Factorio version 1.1. In this tutorial, the author will explain how Factorio works behind the scenes, how to modify Factorio, where to find documentation, and explain concepts.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
Before we start the tutorial, a few things to note:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#AAFFAA!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
Code tinted green like this should be included into the mod this tutorial is going to create; If the reader follows along with it. The best way to do this is to copy and paste, to ensure faithful reproduction.&lt;br /&gt;
Whenever code is added to the mod, a Lua comment with the file name will be at the beginning of the green box. Place the code in the box into that file. Eg:&lt;br /&gt;
--control.lua&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
Code tinted purple like this should not be included into the mod, it&#039;s just for educational/example purposes, and to boost understanding.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This tutorial was updated to version 1.1, so any &#039;&#039;viewers in the future should take note that some minor changes may have been made&#039;&#039;, and should look at the changelogs up to the current version.&lt;br /&gt;
&lt;br /&gt;
== Terminology used in modding ==&lt;br /&gt;
&lt;br /&gt;
Before we start the tutorial, a few terms and definitions should be laid out, to ensure the reader understands.&lt;br /&gt;
&lt;br /&gt;
; Mod : A script or series of scripts that allow modifications to the game through the API.&lt;br /&gt;
; Entity : An entity in Factorio is anything in the game that is not a concept, event, or tile. Examples of entities include the character, an assembling machine, a biter, etc. This can be &#039;machines&#039; or free-moving objects like the character.&lt;br /&gt;
; Character : The actual entity that the player manipulates the world through.&lt;br /&gt;
; Player : All the data that defines a player, such as username, online time or the current zoom level.&lt;br /&gt;
; Prototype : A prototype describes an instance of an entity or item etc, a bit like a template. It defines stats, like what an entity actually is, an item&#039;s stack size, a recipe&#039;s ingredients etc. A prototype is used to create an instance of an entity/item, and many functionally identical entities/items will use the same prototype.&lt;br /&gt;
; Surface : A surface is a bit like a dimension. It is composed of terrain, such as grass, sand, and water, and all the entities on the surface. By default, there is only one surface in Factorio, referred to internally as &amp;quot;nauvis&amp;quot;, or &amp;lt;code style=&amp;quot;background-color:#DDA0DD; color:black&amp;quot;&amp;gt;game.surfaces[1]&amp;lt;/code&amp;gt;, but mods may create additional surfaces through the API.&lt;br /&gt;
; Event : An event is a recurring...event, that is triggered internally by the game. There are several events that mods may connect functions to, such as &amp;lt;code style=&amp;quot;background-color:#DDA0DD; color:black&amp;quot;&amp;gt;on_entity_died&amp;lt;/code&amp;gt;, etc. More on this in the control scripting section.&lt;br /&gt;
&lt;br /&gt;
More terminology may be declared and defined later in this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Before beginning to mod ==&lt;br /&gt;
&lt;br /&gt;
Before we can start modding Factorio, we must understand what Factorio is. You may be tempted to answer in lieu of the [[Factorio:About|about page]], but that is what a player would say. Since we are trying to become a modder, we need a more detailed explanation. Factorio is a game that is coded in the language C++, with an API provided by Wube (the developers of Factorio) to mod Factorio in the programming language Lua (version 5.2.1). This API allows adding scripts to the Factorio init process, to modify it without the source code of the base game being exposed, or modifying memory. This may be different than other games that offer modding, but this is a more professional and proper way of supporting modding.&lt;br /&gt;
&lt;br /&gt;
To aid in the use of this API, the devs have kindly provided fairly comprehensive documentation of scripting at their [https://lua-api.factorio.com/latest/ API site] and documentation all around prototypes on [[Prototype definitions|this wiki]]. Get used to using these sites, as they will become frequent visits you will make while you develop mods. The scripting API site contains information on [https://lua-api.factorio.com/latest/Classes.html Factorio&#039;s classes] and information on [https://lua-api.factorio.com/latest/events.html events] that you can hook into. [[Prototype definitions]] contains and links to information all around prototypes, listing their inheritance structure and their properties. You will need to check these sites often, so the author recommends bookmarking them. In addition to these sites, there is also many resources to be found created by the community, such as this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Setup ===&lt;br /&gt;
&lt;br /&gt;
The best way to develop a mod is to develop it in a place where it can be easily tested. When the tutorial gets to making the mod, this will be explained further. Additionally, using an editor that allows ease of typing and Lua language support is recommended. Emacs, Vim, Sublime Text, VSCode, and Notepad++ are all viable candidates.&lt;br /&gt;
&lt;br /&gt;
== How Factorio loads mods ==&lt;br /&gt;
&lt;br /&gt;
=== Load order ===&lt;br /&gt;
Within stages, mods are loaded by dependency, then by alphabetical order. This is &#039;&#039;very important&#039;&#039; to understand, as it can cause you problems if you neglect it and try to add inter-mod support to your mod.&lt;br /&gt;
&lt;br /&gt;
Factorio has three kinds of dependencies. There are required dependencies, and optional dependencies. The third kind, restrictive dependencies, does not affect mod order and instead prevents the game from loading if the other mod is found. Required dependencies are loaded first, always. The game will fail to initialize if one of these is not present. Optional dependencies are loaded first if present, but do not have to be present. This is useful for enabling bonus features if mods are used together. Required dependencies should be used for mod libraries, and similar infrastructure.&lt;br /&gt;
&lt;br /&gt;
=== The settings stage ===&lt;br /&gt;
The very first mod stage that is loaded when Factorio initializes is the settings stage. This stage is used to define all mod settings that are later shown in the in-game mod settings GUI, and has no other functions or possibilities. When running through this stage, the game looks through all mods for a file called &amp;lt;code&amp;gt;settings.lua&amp;lt;/code&amp;gt;. After settings.lua has been executed for all mods, each mod&#039;s &amp;lt;code&amp;gt;settings-updates.lua&amp;lt;/code&amp;gt; is executed, and finally each mod&#039;s &amp;lt;code&amp;gt;settings-final-fixes.lua&amp;lt;/code&amp;gt; is called. These 3 different phases of the settings stage allow to change settings of other mods without needing to rely on dependencies to load last. All other files to be loaded will need to be required. All the files run here should contain nothing but setting definitions and code to produce setting definitions.&lt;br /&gt;
&lt;br /&gt;
The settings stage does not have access to prototype or runtime data because it is loaded before those stages. The settings are expected to have a certain format, and all additional code will be discarded once the stage is over.&lt;br /&gt;
&lt;br /&gt;
Mod settings are not covered in this tutorial, see [[Tutorial:Mod settings]] for further info on them.&lt;br /&gt;
&lt;br /&gt;
=== The data stage ===&lt;br /&gt;
&lt;br /&gt;
This is the most restricted part of the Factorio init, there&#039;s not much you can do here other than declare prototypes for technologies, entities, items and more. Things like manipulating files, affecting the world, etc, are blocked/unavailable. In fact, any functions or changes made will be discarded, as the lua session is terminated. You also cannot mess with the data table, it will error or be ignored. When using &amp;lt;code&amp;gt;data:extend({})&amp;lt;/code&amp;gt;, it expects a specific format, more on this later.&lt;br /&gt;
&lt;br /&gt;
When running through this stage, the game looks through all mods for a file called &amp;lt;code&amp;gt;data.lua&amp;lt;/code&amp;gt;. After data.lua has been executed for all mods, each mod&#039;s &amp;lt;code&amp;gt;data-updates.lua&amp;lt;/code&amp;gt; is executed, and finally each mod&#039;s &amp;lt;code&amp;gt;data-final-fixes.lua&amp;lt;/code&amp;gt; is called. These 3 different phases of the data stage allow to change data of other mods without needing to rely on dependencies to load last. For example, the base mod creates barrelling recipes for all (then present) fluids in data-updates.lua. This means that if you add a fluid in data.lua, the base mod&#039;s data-updates.lua will add barreling recipes for it, regardless of whether your mod depends on base. Of course this also means that if you add a fluid in data-final-fixes.lua, it is created after the barrelling code runs in data-updates.lua, so no barrelling recipe gets created, even when desired. Because of this and similar mod interactions, it is recommended to create prototypes as early as possible. So, don&#039;t use data-final-fixes.lua to exclude a fluid from barreling, instead create it in data.lua and utilize &amp;quot;auto_barrel = false&amp;quot; on the fluid.&lt;br /&gt;
&lt;br /&gt;
All other files to be loaded will need to be required. All the files run here should contain nothing but prototype definitions and code to produce prototype definitions. More on requiring files later.&lt;br /&gt;
&lt;br /&gt;
All prototypes are documented here on the wiki: [[Prototype definitions]].&lt;br /&gt;
&lt;br /&gt;
=== Migrations ===&lt;br /&gt;
&lt;br /&gt;
[https://lua-api.factorio.com/latest/Migrations.html Migrations] are scripts that are used to &amp;quot;fix&amp;quot; a save after a mod updates. Whenever prototype names change within a mod, migrations must be setup to replace all the old instances of the prototyped entity in the world. This must be done for all updated entities, or the old entities will be removed from the world, which is an unprofessional fallback that makes users dislike you. While this tutorial will not discuss migrations, there are many resources on migrations to be found around the community, and the API site.&lt;br /&gt;
&lt;br /&gt;
To avoid having to write migrations, avoid changing prototype names and technology unlocks. Prototypes names cannot be dynamically changed and technology unlocks of already researched technologies do not apply automatically, making migrations necessary. Try to avoid these changes after shipping the mod out to the public. Try to come up with a finalized version of prototype names that you can base the mod around. Of course, migrations are unnecessary if the user simply starts a new world with each mod update, but do not expect the community to do this.&lt;br /&gt;
&lt;br /&gt;
=== Runtime stage ===&lt;br /&gt;
&lt;br /&gt;
Within most mods is a file called &amp;lt;code&amp;gt;control.lua&amp;lt;/code&amp;gt;. This file contains scripting that makes the mod do things during the game, rather than just adding entities to the game. During this stage, each mod&#039;s control.lua is run, in it&#039;s own lua instance (this means no inter-communication without special setup) which it will own for the rest of the play session. During the play session, access to all tables provided by the game can be done inside of event handlers. (More on those below.) Because the control.lua is run every time a save file is created or loaded you don&#039;t need to restart the game to see changes made to the control.lua file. Simply restarting or reloading a save will re-run this stage. &#039;&#039;&#039;There are a few other caveats to this stage, reading the [https://lua-api.factorio.com/latest/Data-Lifecycle.html data life cycle] page on the API site provides the best overview.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The control stage documented is documented on [https://lua-api.factorio.com/latest lua-api.factorio.com].&lt;br /&gt;
&lt;br /&gt;
== The major components to any Factorio mod ==&lt;br /&gt;
&lt;br /&gt;
Within the average mod, there are several components that make the mod function.&lt;br /&gt;
&lt;br /&gt;
Mods that define new entities will need to declare these entities in &amp;lt;code&amp;gt;data.lua&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;data-updates.lua&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;data-final-fixes.lua&amp;lt;/code&amp;gt;, or another file &amp;lt;code&amp;gt;require&amp;lt;/code&amp;gt;d by one of these three.&lt;br /&gt;
&lt;br /&gt;
Mods with in-game effects will also need a &amp;lt;code&amp;gt;control.lua&amp;lt;/code&amp;gt; file, to add scripting.&lt;br /&gt;
&lt;br /&gt;
Mods with configurable user settings will use &amp;lt;code&amp;gt;settings.lua&amp;lt;/code&amp;gt; to describe those settings.&lt;br /&gt;
&lt;br /&gt;
Mods that define any game element with a readable name may also provide a &amp;lt;code&amp;gt;locale&amp;lt;/code&amp;gt; directory and subdirectories with names/descriptions in one or more languages.&lt;br /&gt;
&lt;br /&gt;
The mod that we&#039;ll make in this tutorial will include both data.lua prototypes and control.lua scripting, to give you a feel for both.&lt;br /&gt;
&lt;br /&gt;
== The tutorial mod ==&lt;br /&gt;
&lt;br /&gt;
And now for the moment you&#039;ve been waiting for. Let&#039;s start making your first mod. You&#039;ll need:&lt;br /&gt;
&lt;br /&gt;
* A recent install of Factorio&lt;br /&gt;
* A text editor, such as Emacs, Vim, Sublime text, etc&lt;br /&gt;
* An understanding of the tutorial above&lt;br /&gt;
* An understanding of Lua as a programming language. Enough to know the syntax and how it works. If you have prior programming experience, it should not be difficult to pick up.&lt;br /&gt;
&lt;br /&gt;
Once you have all of these things, we can begin.&lt;br /&gt;
&lt;br /&gt;
For this mod, we&#039;re going to make a set of armor that leaves behind damaging fire behind you as you walk. It will be fully resistant to fire, but weaker towards physical damage than heavy armor, making it an armor for hit and run attacks.&lt;br /&gt;
&lt;br /&gt;
=== Creation of the directory structure ===&lt;br /&gt;
&lt;br /&gt;
The game expects mod to be laid out [[Tutorial:Mod structure|in a certain way]]. To start out, create a folder in your [[Application directory|user data directory]]/mods folder. This folder must have a specific name, &amp;lt;code&amp;gt;fire-armor_0.1.0&amp;lt;/code&amp;gt;. When you&#039;re finished, the mod directory should look like this:&lt;br /&gt;
&lt;br /&gt;
* (user data directory, sometimes called .factorio)&lt;br /&gt;
** mods&lt;br /&gt;
*** fire-armor_0.1.0&lt;br /&gt;
&lt;br /&gt;
Then, inside fire-armor_0.1.0, create two files, &amp;lt;code&amp;gt;info.json&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;data.lua&amp;lt;/code&amp;gt;. The directory should now look like:&lt;br /&gt;
&lt;br /&gt;
* (user data directory, sometimes called .factorio)&lt;br /&gt;
** mods&lt;br /&gt;
*** fire-armor_0.1.0&lt;br /&gt;
**** data.lua&lt;br /&gt;
**** info.json&lt;br /&gt;
&lt;br /&gt;
=== The info.json file ===&lt;br /&gt;
&lt;br /&gt;
Then, inside [[Tutorial:Mod_structure#info.json|info.json]], copy and paste the following into it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#AAFFAA!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;fire-armor&amp;quot;,&lt;br /&gt;
  &amp;quot;version&amp;quot;: &amp;quot;0.1.0&amp;quot;,&lt;br /&gt;
  &amp;quot;title&amp;quot;: &amp;quot;Fire Armor&amp;quot;,&lt;br /&gt;
  &amp;quot;author&amp;quot;: &amp;quot;You&amp;quot;,&lt;br /&gt;
  &amp;quot;factorio_version&amp;quot;: &amp;quot;1.1&amp;quot;,&lt;br /&gt;
  &amp;quot;dependencies&amp;quot;: [&amp;quot;base &amp;gt;= 1.1&amp;quot;],&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;This mod adds in fire armor that leaves behind damaging fire as you walk around.&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To explain each field:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Item&lt;br /&gt;
! Explanation&lt;br /&gt;
|-&lt;br /&gt;
| name&lt;br /&gt;
| This is the internal name of your mod, it is used to identify your mod in code.&lt;br /&gt;
|-&lt;br /&gt;
| version&lt;br /&gt;
| This is the version of your mod. This can be anything you want, provided it&#039;s a of the format &amp;quot;number.number.number&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| title&lt;br /&gt;
| The pretty title of your mod, this will be displayed on the mods screen and when you submit it to the mod portal.&lt;br /&gt;
|-&lt;br /&gt;
| author&lt;br /&gt;
| Your name! You can change this in the example above.&lt;br /&gt;
|-&lt;br /&gt;
| factorio_version&lt;br /&gt;
| This tells the game what version the mod is for, this must match the version you&#039;re developing the mod for, 1.1 in this case.&lt;br /&gt;
|-&lt;br /&gt;
| dependencies&lt;br /&gt;
| Any dependencies of your mod.&lt;br /&gt;
|-&lt;br /&gt;
| description&lt;br /&gt;
| A &#039;&#039;short&#039;&#039; description of your mod.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And that&#039;s all for info.json! Next, in the data.lua file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#AAFFAA!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
--data.lua&lt;br /&gt;
&lt;br /&gt;
require(&amp;quot;item&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s a pretty simple file, all we&#039;re doing here is just telling the game to execute the file called item.lua, which we&#039;re about to create. Create a file in fire-armor_0.1.0 called &amp;lt;code&amp;gt;item.lua&amp;lt;/code&amp;gt;. Notice how our earlier require used the file name in it?&lt;br /&gt;
&lt;br /&gt;
We are creating this file just for our own organisation inside the mod, so there are no naming or other requirements from the game&#039;s side. As long as we tell the game to load the file with &amp;quot;require&amp;quot;, the file name or its exact location inside the mod does not matter.&lt;br /&gt;
&lt;br /&gt;
=== Prototype creation ===&lt;br /&gt;
&lt;br /&gt;
Now, there are two ways to create prototypes in Factorio. There&#039;s the short way, and the long way. The long way requires to create a complete prototype definition based on [[prototype definitions|the documentation]], and the short way just uses a lua function to copy and modify an already existing definition. For the sake of this tutorial, we&#039;ll do it the short way.&lt;br /&gt;
&lt;br /&gt;
In item.lua, copy and paste the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#AAFFAA!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
--item.lua&lt;br /&gt;
&lt;br /&gt;
local fireArmor = table.deepcopy(data.raw[&amp;quot;armor&amp;quot;][&amp;quot;heavy-armor&amp;quot;]) -- copy the table that defines the heavy armor item into the fireArmor variable&lt;br /&gt;
&lt;br /&gt;
fireArmor.name = &amp;quot;fire-armor&amp;quot;&lt;br /&gt;
fireArmor.icons = {&lt;br /&gt;
  {&lt;br /&gt;
    icon = fireArmor.icon,&lt;br /&gt;
    tint = {r=1,g=0,b=0,a=0.3}&lt;br /&gt;
  },&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
fireArmor.resistances = {&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;physical&amp;quot;,&lt;br /&gt;
    decrease = 6,&lt;br /&gt;
    percent = 10&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;explosion&amp;quot;,&lt;br /&gt;
    decrease = 10,&lt;br /&gt;
    percent = 30&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;acid&amp;quot;,&lt;br /&gt;
    decrease = 5,&lt;br /&gt;
    percent = 30&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;fire&amp;quot;,&lt;br /&gt;
    decrease = 0,&lt;br /&gt;
    percent = 100&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local recipe = table.deepcopy(data.raw[&amp;quot;recipe&amp;quot;][&amp;quot;heavy-armor&amp;quot;])&lt;br /&gt;
recipe.enabled = true&lt;br /&gt;
recipe.name = &amp;quot;fire-armor&amp;quot;&lt;br /&gt;
recipe.ingredients = {{&amp;quot;copper-plate&amp;quot;,200},{&amp;quot;steel-plate&amp;quot;,50}}&lt;br /&gt;
recipe.result = &amp;quot;fire-armor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
data:extend{fireArmor,recipe}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What we&#039;ve just done here is we&#039;ve copied the definition of heavy armor, then changed it&#039;s properties, and injected it into the Factorio init with data:extend. The first line of code is probably the most interesting. &amp;lt;code&amp;gt;table.deepcopy&amp;lt;/code&amp;gt; copies a table fully into another table. We do this from data.raw. The &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; part is a table, which will be used by game to setup the Factorio universe. In fact, it contains the function &amp;lt;code&amp;gt;extend(self, prototypes)&amp;lt;/code&amp;gt; and a table called &amp;lt;code&amp;gt;raw&amp;lt;/code&amp;gt;. The former is customary way to add new stuff to the latter. It is actually data.raw that holds the prototypes for the game. (You can view the implementation in the file [https://github.com/wube/factorio-data/blob/master/core/lualib/dataloader.lua /factorio/data/core/lualib/dataloader.lua]). It is important to note that data.raw only exists during the data loading stage of the game. During the control stage, when the game is running and being played, you cannot read this data; instead you read processed values through the API from the various types like LuaEntityPrototype.&lt;br /&gt;
&lt;br /&gt;
In addition to defining the item prototype, we also define a recipe for it. This is necessary if you want to be able to craft the thing. We also set it to enabled so it doesn&#039;t need a technology to unlock.&lt;br /&gt;
&lt;br /&gt;
=== More on data.raw ===&lt;br /&gt;
&lt;br /&gt;
When Factorio initializes, all prototypes are put into a table called data.raw. This table holds all prototype types, and within those types, individual prototypes indentified by name: &amp;lt;code&amp;gt;local prototype = data.raw[&amp;quot;prototype-type&amp;quot;][&amp;quot;internal-name&amp;quot;]&amp;lt;/code&amp;gt;. You saw earlier how we deepcopied from the definition of heavy armor, and modified some fields. In fact, let&#039;s go over each part of the deepcopy line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
local fireArmor = table.deepcopy(data.raw[&amp;quot;armor&amp;quot;][&amp;quot;heavy-armor&amp;quot;])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We assign a variable called fireArmor that holds our copy of the heavy armor definition. Notice how in data.raw, there is a type table that holds all armors, and the specific armor we&#039;re looking for is called heavy-armor. We can find [[heavy armor]]&#039;s prototype type and internal name in the infobox of its page on this wiki and just copy it from there.&amp;lt;br&amp;gt;&lt;br /&gt;
Alternatively, we can find the items prototype type and internal name by opening the game, inserting the item into our inventory and then pressing {{Keybinding|shift|ctrl|F}} while hovering over the item. This will open the prototype explorer GUI, which has rows showing the name and type of the item.&lt;br /&gt;
&lt;br /&gt;
As another example, the [[player|character]]&#039;s prototype would be, according to the infobox on the page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
data.raw[&amp;quot;character&amp;quot;][&amp;quot;character&amp;quot;]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because the character is &#039;&#039;the&#039;&#039; character, his type matches his name. You could define a new type of character with a mod. You can see all the available prototype fields of the charater in the documenation: [[Prototype/Character]].&lt;br /&gt;
&lt;br /&gt;
You may be thinking at this point, &amp;quot;Can I modify Factorio&#039;s existing prototypes without making new ones?&amp;quot; Well, the answer is yes! You would simply access the data.raw table during init, in data-final-fixes.lua if you want to run after all other mods, and change a property. For example, make the iron chest instead have 1000 health:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
data.raw[&amp;quot;container&amp;quot;][&amp;quot;iron-chest&amp;quot;].max_health = 1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reason why this code is in data-final-fixes.lua is because that is the last file run, after all mod files have been run. This prevents (to a degree) your changes from being messed with by other mods. Of course, it is still possible to have incompatibilities. You should note any that you know of in your mod&#039;s description. Again, the [https://lua-api.factorio.com/latest/Data-Lifecycle.html dev&#039;s documentation] on this should be looked at.&lt;br /&gt;
&lt;br /&gt;
This can also be applied to other mods, not just Factorio&#039;s base. You could mod a mod, as long as you add the mod (that you modified with your mod) to your dependencies so it gets loaded first.&lt;br /&gt;
&lt;br /&gt;
=== The control scripting ===&lt;br /&gt;
&lt;br /&gt;
And now, to finalize the mod, we have to make it be more than just simple armor. Let&#039;s think about what we want the armor to do. We want the armor to create fire on the ground as we walk with the armor on. The event we&#039;re going to use is called [https://lua-api.factorio.com/latest/events.html#on_player_changed_position on_player_changed_position], since we want the fire to be created when the player moves.&lt;br /&gt;
&lt;br /&gt;
In our mod folder, create a file called &amp;lt;code&amp;gt;control.lua&amp;lt;/code&amp;gt;. The game will automatically execute this file, so requiring it is not necessary.&lt;br /&gt;
&lt;br /&gt;
Inside control.lua, copy and paste the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#AAFFAA!important; color:black;&amp;quot;&amp;gt;&lt;br /&gt;
--control.lua&lt;br /&gt;
&lt;br /&gt;
script.on_event(defines.events.on_player_changed_position,&lt;br /&gt;
  function(event)&lt;br /&gt;
    local player = game.get_player(event.player_index) -- get the player that moved            &lt;br /&gt;
    -- if they&#039;re wearing our armor&lt;br /&gt;
    if player.character and player.get_inventory(defines.inventory.character_armor).get_item_count(&amp;quot;fire-armor&amp;quot;) &amp;gt;= 1 then&lt;br /&gt;
       -- create the fire where they&#039;re standing&lt;br /&gt;
       player.surface.create_entity{name=&amp;quot;fire-flame&amp;quot;, position=player.position, force=&amp;quot;neutral&amp;quot;} &lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I&#039;ve used lua comments in the code above to explain each step. It&#039;s fairly easy to understand, and it shows how you would get the current armor that the player character is wearing, with defines.inventory.character_armor, which is an inventory constant. You can read the list of defines [https://lua-api.factorio.com/latest/defines.html#defines.inventory here].&lt;br /&gt;
&lt;br /&gt;
=== Locale ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve already tried loading up Factorio and trying the mod so far (which you can at this point without it crashing), you may have noticed that the item name of the armor says &amp;quot;Unknown key&amp;quot;. This means that Factorio has the internal name, but it doesn&#039;t know what it should look like to the user. So, we need to create locale for our mod.&lt;br /&gt;
&lt;br /&gt;
In the mod folder, create a folder called &amp;lt;code&amp;gt;locale&amp;lt;/code&amp;gt;, then create another folder inside that called &amp;lt;code&amp;gt;en&amp;lt;/code&amp;gt;, then a file called &amp;lt;code&amp;gt;any_name_can_be_here.cfg&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you know another language, you can also translate your mod by making other language code files inside locale, such as de for German.&lt;br /&gt;
&lt;br /&gt;
Inside the .cfg file, paste the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#AAFFAA!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[item-name]&lt;br /&gt;
fire-armor=Fire armor&lt;br /&gt;
&lt;br /&gt;
[item-description]&lt;br /&gt;
fire-armor=An armor that seems to catch the ground itself on fire when you take a step. It&#039;s warm to the touch.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice how this is not a lua file. Locale is handled with C config files, so the format is different.&lt;br /&gt;
&lt;br /&gt;
== The finished tutorial mod ==&lt;br /&gt;
&lt;br /&gt;
Well, the mod is finished. Since this mod is only a tutorial, there isn&#039;t much balance to it. Additionally, don&#039;t try submitting it to the mod portal as your own, since it&#039;s from the Wiki.&lt;br /&gt;
&lt;br /&gt;
However, you&#039;re free to take this mod and modify it for your own use, changing recipes, adding technologies, whatever.&lt;br /&gt;
&lt;br /&gt;
== Resolving common errors in modding ==&lt;br /&gt;
&lt;br /&gt;
As you continue to write mods from scratch instead of from a tutorial, you may encounter the infamous error. There are several types of errors that you can encounter in modding Factorio, and knowing how to deal with these errors will allow you to continue working.&lt;br /&gt;
&lt;br /&gt;
=== Syntax errors ===&lt;br /&gt;
&lt;br /&gt;
The lua programming language expects things to be laid out a certain way. If you miss a bracket, = sign, or dot, you will encounter a syntax error. As an example, see the error below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
Failed to load mods: __fire-armor__/data.lua:1:__fire-armor__/prototypes/item.lua:36: syntax error near &#039;true&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As of version 0.15, you&#039;ll see an error like the one above whenever you make a syntax error within the prototype definitions. The game will offer to restart, disable the troubling mod, disable all mods, or exit. Let&#039;s dissect the error, shall we?&lt;br /&gt;
&lt;br /&gt;
Right away, we see the reason why Factorio didn&#039;t start normally. &amp;quot;Failed to load mods:&amp;quot;. So, we know that it&#039;s a mod that messed up, and by extension, we know it&#039;s our mod. Whenever the Lua engine of Factorio has a syntax error, it will print a mini stack-trace that follows through all requires, listing the call order. First, we see that the problem was indirectly caused by line 1 of data.lua. There&#039;s no problem there, so it must be the next entry, line 36 of prototypes/item.lua. After stating where it is line-wise, it will attempt to give you an estimate of where in the line the problem is. Don&#039;t trust this estimate, only roughly trust the line number, plus or minus a few lines.&lt;br /&gt;
&lt;br /&gt;
Going to line 36 of item.lua, we find:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
recipe.enabled true&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hmm, that doesn&#039;t look right. Can you see what&#039;s missing? We left off an = between enabled and true. Thus, syntax error. Fixing these can be difficult for new programmers, who don&#039;t know what to look for.&lt;br /&gt;
&lt;br /&gt;
=== Illogical actions, indexing nil ===&lt;br /&gt;
&lt;br /&gt;
In lua, &amp;quot;nothing&amp;quot; is defined as the keyword nil. This is similar to null in other programming languages. Whenever the programmer tries to access something in a table that is nil, they will get an error like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
Error while running event fire-armor::on_player_changed_position (ID 82)&lt;br /&gt;
__fire-armor__/control.lua:3: attempt to index field &#039;?&#039; (a nil value)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;attempt to index field ...&amp;quot; error is often caused by the modder making an assumption that didn&#039;t work out. These types of errors will always be identifiable by their signature line, &amp;quot;attempt to index field&amp;quot;. If we look at line 3 of control.lua (where the error is), we see:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
game.print(game.players[23])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What assumption has the modder made here? Well, there&#039;s actually two problems with this line. The first thing is that the modder has assumed that &amp;lt;code&amp;gt;game.players[23]&amp;lt;/code&amp;gt; is a valid player, which isn&#039;t the case; this is why we get the &amp;quot;index field &#039;?&#039;&amp;quot; bit. The game doesn&#039;t know what the field is that we tried to index, because it hasn&#039;t been created yet. These errors are difficult to debug unless you know the ins and outs of the modding API well.&lt;br /&gt;
&lt;br /&gt;
The second issue is a lot more subtle, and won&#039;t work. The modder is attempting to print a userdata table. [https://lua-api.factorio.com/latest/LuaPlayer.html A player] is a table of several values. Trying to print it simply print &amp;quot;LuaPlayer&amp;quot; instead of providing useful data.&lt;br /&gt;
&lt;br /&gt;
=== Error while running event ===&lt;br /&gt;
&lt;br /&gt;
Another common type of error in Factorio is the &amp;quot;Error while running event&amp;quot; error. This type of error only happens in control.lua scripting, and it happens when something goes wrong in an event function, such as a syntax error. &#039;&#039;&#039;Note that syntax errors in control.lua do not stop the game from starting, but may trigger after a save is loaded&#039;&#039;&#039;. There are a great deal of errors under this broad category, here&#039;s an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
Error while running event fire-armor::on_player_changed_position (ID 82)&lt;br /&gt;
Unknown entity name: fire-flam&lt;br /&gt;
stack traceback:&lt;br /&gt;
__fire-armor__/control.lua:7: in function &amp;lt;__fire-armor__/control.lua:2&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you saw with the prototypes syntax error, Factorio gives a small traceback and the error name itself. In this case, we&#039;ve attempted to spawn an entity called &amp;quot;fire-flam&amp;quot; on line 7 of control.lua, inside of an on_player_changed_position event hook. Fire-flam isn&#039;t a real entity type, so we crashed.&lt;br /&gt;
&lt;br /&gt;
These types of errors can range from being a simple fix (like the one above, add the missing e), or can be very difficult.&lt;br /&gt;
&lt;br /&gt;
=== Internal errors ===&lt;br /&gt;
&lt;br /&gt;
The most rare form of error and the worst form is the internal error. This is an error with the C++ code of the game, and there&#039;s nothing you can do but report it to the devs. Mods occasionally cause these, and almost all of them are considered bugs, as mods &#039;&#039;should not&#039;&#039; be able to cause these, if that makes sense. They often get thrown into the logs.&lt;br /&gt;
&lt;br /&gt;
An example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
696.148 Error FlowStatistics.cpp:236: FlowStatistics attempted to save value larger than uint16 as uint16. Exiting to prevent save corruption.&lt;br /&gt;
Logger::writeStacktrace skipped.&lt;br /&gt;
696.148 Error CrashHandler.cpp:190: Map tick at moment of crash: 432029&lt;br /&gt;
696.148 Error Util.cpp:97: Unexpected error occurred. If you&#039;re running the latest version of the game you can help us solve the problem by posting the contents of the log file on the Factorio forums.&lt;br /&gt;
Please also include the save file(s), any mods you may be using, and any steps you know of to reproduce the crash.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Multiplayer and desyncs ==&lt;br /&gt;
&lt;br /&gt;
The reader may be wondering at this point how Factorio handles multiplayer with mods. It&#039;s fairly simple, but is still worth considering.&lt;br /&gt;
&lt;br /&gt;
Factorio is [https://en.wikipedia.org/wiki/Deterministic_algorithm deterministic], which means that when you provide a constant input, you get a constant output, with no variance. Every client and the server all reach the same points at the same time in simulation, so they all agree on what happened. When this differs, the players experience a &#039;&#039;desync&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
; Desync : Misalignment with server and clients. Client 1 expected A, but got B. All other clients got A. Thus, Client 1 will desync. Desync can also happen when all clients have information (for example a variable) but a client that recently joined the game doesn&#039;t. That client will be desynced.&lt;br /&gt;
: &#039;&#039;See also: [[Desynchronization]]&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Desyncs happen a lot to new devs of Factorio mods, because they are unaware that a particular piece of code they used causes desyncs. As a general rule, there are a few things that should never be done.&lt;br /&gt;
&lt;br /&gt;
=== Use local variables that are not final outside of event hooks ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
local globalLocal = 1&lt;br /&gt;
script.on_event(defines.events.on_player_built_item, function()&lt;br /&gt;
    globalLocal = math.random()&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the modder places a local variable outside of an event hook that gets changed during runtime, desyncs will happen when that variable is utilised to modify the game state (i.e. manipulate an entity, print text to players). If making a &amp;quot;global&amp;quot; variable is necessary, place the variable in the [https://lua-api.factorio.com/latest/Global.html global] table instead. The game syncs this table between all clients, so they can all be aware of and reach the same conclusion as each other.&lt;br /&gt;
&lt;br /&gt;
=== Selective requiring ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
if setting1 then&lt;br /&gt;
   require(&amp;quot;settingOne.lua&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selective requiring, aka requiring different lua files based on settings can cause connection rejections as the checksum of the mods will not match, as they load different data. All clients&#039; mods must require the same series of files.&lt;br /&gt;
&lt;br /&gt;
=== Conditional event subscribing ===&lt;br /&gt;
&lt;br /&gt;
Mods in factorio may subscribe to events in order to be notified when they happen. This allows mods to react to events when they occur. Typically, event subscription is done at the top level of a lua file. &lt;br /&gt;
&lt;br /&gt;
Doing event subscription inside of a conditional, function, or other event is dangerous, as doing it incorrectly will lead to desyncs. Basically, since both the server and client need to reach the same conclusion after running code, conditional subscription can lead to certain clients or the server being subscribed to an event when the others are not, causing desyncs. &lt;br /&gt;
&lt;br /&gt;
=== Improper use of on_load ===&lt;br /&gt;
&lt;br /&gt;
Another way to cause desyncs is to make improper actions inside of an on_load call, which some players new to modding might try to do. According to the [https://lua-api.factorio.com/latest/LuaBootstrap.html#LuaBootstrap.on_load documentation], the on_load functionality is meant for 3 purposes &#039;&#039;&#039;only&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* Re-register conditional event handlers&lt;br /&gt;
* Re-setup meta tables&lt;br /&gt;
* Create local references to tables stored in the global table&lt;br /&gt;
&lt;br /&gt;
Doing anything else will cause desyncs. The game will catch most attempts, crashing instead and terminating the mod.&lt;br /&gt;
&lt;br /&gt;
=== Comparison by reference ===&lt;br /&gt;
&lt;br /&gt;
Be cautious of comparing tables by reference. In multiplayer syncing, tables deserialized from the server state will be new objects, not equal by reference to any table initialized by client code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
if a == b then&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
if a ~= b then&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; are tables in the above conditionals, there will for example be different results between server and client if &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; is created locally and &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; is downloaded from the server.&lt;br /&gt;
&lt;br /&gt;
Note that LuaObjects provided by the game have their equality operator overwritten to prevent this behaviour, so code such as &amp;lt;code&amp;gt;LuaEntityA ~= LuaEntityB&amp;lt;/code&amp;gt; will not desync.&lt;br /&gt;
However, this does not apply when LuaObjects are used as keys in tables:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:#DDA0DD!important; color:black&amp;quot;&amp;gt;&lt;br /&gt;
if table[LuaObject] then&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will desync in the same way as described for the plain tables &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; above. For entities it is recommended to use [https://lua-api.factorio.com/latest/LuaEntity.html#LuaEntity.unit_number LuaEntity.unit_number] as the table key instead of the whole entity.&lt;br /&gt;
&lt;br /&gt;
== Extended learning ==&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn how to mod beyond this is to look at other mods. The [[Tutorial:Inspecting a live mod]] is a good starting point for touring a particularly well-commented mod. As all mods can be opened and inspected, looking at the mods of experienced modders can help significantly when making your own mod.&lt;br /&gt;
&lt;br /&gt;
=== Keeping your mod working ===&lt;br /&gt;
&lt;br /&gt;
As Factorio evolves, things will change. Previously, you probably ignored the modding part of the changelog, you now need to read it and see if any changes affect your mod(s). If so, you&#039;ll need to fix them. If there&#039;s something wrong with your mod, the game will fail to init and explain why.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Modding]]&lt;br /&gt;
* [[Modding FAQ]]&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Tutorial:Localisation&amp;diff=185831</id>
		<title>Tutorial:Localisation</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Tutorial:Localisation&amp;diff=185831"/>
		<updated>2021-05-03T15:48:08Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: /* Localising alternate input names */ Update wording from Left click to Left-click, which is what the game actually produces&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}Mods should define human readable names for prototypes that they add. They can also define descriptions for items or custom strings for usage in GUIs etc. This is called &#039;&#039;&#039;localisation&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
Translations are stored as .cfg files, with the following format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;welcome-message=Hello world&lt;br /&gt;
[category]&lt;br /&gt;
title=Category related title&amp;lt;/pre&amp;gt;&lt;br /&gt;
Any whitespace after or before &amp;lt;code&amp;gt;=&amp;lt;/code&amp;gt; is included in the key or string, so &amp;lt;code&amp;gt;title =Category related title&amp;lt;/code&amp;gt; will give an unknown key error if you are looking for the &amp;lt;code&amp;gt;title&amp;lt;/code&amp;gt; key, since it is the &amp;lt;code&amp;gt;title&amp;amp;nbsp;&amp;lt;/code&amp;gt; key.&lt;br /&gt;
&lt;br /&gt;
These files are located within the language code of the language in the locale folder of the mod, so as an English example &amp;lt;code&amp;gt;__mod__/locale/en/any_name_here.cfg&amp;lt;/code&amp;gt;. There can be more than 1 file per language, all of them will be read.&lt;br /&gt;
&lt;br /&gt;
== Localising simple strings ==&lt;br /&gt;
The simplest localisation is of items, entities etc. If we say the item is &amp;lt;code&amp;gt;iron-plate&amp;lt;/code&amp;gt;, the game will then search all loaded locale files for &amp;lt;code&amp;gt;item-name.iron-plate&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;item-description.iron-plate&amp;lt;/code&amp;gt;, which in the locale file looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;[item-name]&lt;br /&gt;
iron-plate=Iron plate&lt;br /&gt;
[item-description]&lt;br /&gt;
iron-plate=A plate made of iron.&amp;lt;/pre&amp;gt;&lt;br /&gt;
If found in the locale, the label is set to this string. If not found, the game will instead show: &amp;lt;code&amp;gt;Unknown key: &amp;amp;quot;item-name.iron-plate&amp;amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In script, the localised string is formatted as &amp;lt;code&amp;gt;{&amp;amp;quot;category.name&amp;amp;quot;}&amp;lt;/code&amp;gt;, so &amp;lt;code&amp;gt;game.print({&amp;amp;quot;item-name.iron-plate&amp;amp;quot;})&amp;lt;/code&amp;gt; prints &#039;&#039;Iron plate&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
It is possible to use [[rich text]] features in the localised text if the location where the text is shown supports it, e.g. in the chat, prototype names and prototype tooltips.&lt;br /&gt;
&lt;br /&gt;
== Localising with parameters ==&lt;br /&gt;
For more complex strings, localisation parameters can be used. For instance we want to show &#039;&#039;Time left: 10 minutes.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
So a key with a placeholder is defined, which is replaced by the first parameter after the locale key.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;time-left=Time left: __1__ minutes.&amp;lt;/pre&amp;gt;&lt;br /&gt;
So it is used like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;game.print({&amp;quot;time-left&amp;quot;, 10})&amp;lt;/source&amp;gt;&lt;br /&gt;
It also works with multiple parameters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;game.print({&amp;quot;time-left&amp;quot;, 10, 45})&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;time-left=Time left: __1__ minutes and __2__ seconds.&amp;lt;/pre&amp;gt;&lt;br /&gt;
Which results in &#039;&#039;Time left: 10 minutes and 45 seconds.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Built-in parameters ===&lt;br /&gt;
For some situations, we use localisation to show control schemes. For instance we want to say:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;technology-prompt=Use T to open the technology screen&amp;lt;/pre&amp;gt;&lt;br /&gt;
However the player may have rebound the key, but we can’t figure out which key as it would not be deterministic. So instead we use the built-in replacement functionality&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;technology-prompt=Use __CONTROL__open-technology-gui__ to open the technology screen.&amp;lt;/pre&amp;gt;&lt;br /&gt;
We can also use this for items and entities etc.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;big-iron-plate=Big __ITEM__iron-plate__&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Plurals ===&lt;br /&gt;
Pluralization can be used in any string that uses a parameter (e.g. __1__) that is numeric, so something like an amount of minutes. It can be used multiple times per string.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;format-days=__1__ __plural_for_parameter_1_{1=day|rest=days}__&amp;lt;/pre&amp;gt;&lt;br /&gt;
This results in &amp;quot;1 day&amp;quot; and &amp;quot;2 days&amp;quot; / &amp;quot;500 days&amp;quot; etc.&lt;br /&gt;
&lt;br /&gt;
The number after &amp;lt;code&amp;gt;__plural_for_parameter_&amp;lt;/code&amp;gt; denotes which parameter is used to determine the plural. This is the parameter 1 in the above example. Anything inside the {} is used to make the plural. Each plural form is separated by a |.&lt;br /&gt;
The text in front of the = determines for what the plural form is used. Options for this are:&lt;br /&gt;
* a simple number, e.g. &amp;quot;1&amp;quot;.&lt;br /&gt;
* Multiple numbers, e.g. &amp;quot;2,3,4&amp;quot;.&lt;br /&gt;
* What the number ends with, e.g. &amp;quot;ends in 11&amp;quot; or &amp;quot;ends in 1&amp;quot;&lt;br /&gt;
* Multiple ends with, e.g. &amp;quot;ends in 1,ends in 2,ends in 12&amp;quot;.&lt;br /&gt;
* &amp;quot;rest&amp;quot; to give the default plural.&lt;br /&gt;
&lt;br /&gt;
Plural forms may be empty or contain other keys such as __1__ or spaces. This allows rather large plural forms:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;__plural_for_parameter_1_{1=__1__ player is|rest=__1__ players are}__ connecting&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system chooses the first fitting plural that it encounters when multiple would fit:&lt;br /&gt;
&amp;lt;pre&amp;gt;__plural_for_parameter_1_{ends in 12=option 1|ends in 2=option 2|rest=option 3}__&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will result in &amp;quot;option 1&amp;quot; for 12 and in &amp;quot;option 2&amp;quot; for 22 and in &amp;quot;option 3&amp;quot; for numbers not ending with 2.&lt;br /&gt;
&lt;br /&gt;
=== Concatenating localised strings ===&lt;br /&gt;
The special locale key: &amp;lt;code&amp;gt;&amp;amp;quot;&amp;amp;quot;&amp;lt;/code&amp;gt; is used to concatenate, as the table format does not support concatenation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;game.print({&amp;quot;&amp;quot;, {&amp;quot;item-name.iron-plate&amp;quot;}, &amp;quot;: &amp;quot;, 60})&amp;lt;/source&amp;gt;&lt;br /&gt;
Will result in: &#039;&#039;Iron plate: 60&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Localising alternate input names ===&lt;br /&gt;
&lt;br /&gt;
In the introduction campaign, a special locale system is used for informing players how to do certain actions with their mouse.&lt;br /&gt;
The normal form is to use eg:&lt;br /&gt;
&amp;lt;pre&amp;gt;how-to-build=Use __CONTROL__build__ to place a building&amp;lt;/pre&amp;gt;&lt;br /&gt;
which results in &amp;quot;Use Left mouse button to place a building&amp;quot;. A more natural phrasing would be &amp;quot;Left-click to place a building&amp;quot;, which can be achieved by using the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;how-to-build=__ALT_CONTROL__1__build__ to place a building&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These &amp;quot;alt&amp;quot; versions are controlled by a few special locale keys, mouse-button-X-alt-1 and mouse-button-X-alt-2. In English, form 1 produces eg &amp;quot;Left-click&amp;quot;, and form 2 produces eg &amp;quot;Left-clicking&amp;quot;.  Only two alt forms (&amp;quot;1&amp;quot; and &amp;quot;2&amp;quot;) are available at the moment, but if this a problem for some languages, more forms may be added in the future.&lt;br /&gt;
Extra mouse buttons, mouse scroll and keyboard keys are handled through the mouse-button-n-alt-1/2, mouse-wheel-alt-1/2 and keyboard-alt-1/2 keys, which just take the normal name and prepend something like &amp;quot;Press/Pressing&amp;quot;, or &amp;quot;Scroll/Scrolling&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
When translating to another language, you can use whatever forms you want here, but the important part is that you are consistent when you use the alt-forms everywhere else. It does not necessarily make sense to just copy the usages of alt forms from the English locale, and for some languages it may be more natural to simply not use this system at all.&lt;br /&gt;
&lt;br /&gt;
== Accessing the localised result in code ==&lt;br /&gt;
While usually unneeded, it is possible to read the resulting localised text in code, for example to search in localised names. See [https://lua-api.factorio.com/latest/LuaPlayer.html#LuaPlayer.request_translation LuaPlayer::request_translation] and  [https://lua-api.factorio.com/latest/events.html#on_string_translated on_string_translated event].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Types/LocalisedString|LocalisedString data stage doc]]&lt;br /&gt;
* [https://lua-api.factorio.com/latest/Concepts.html#LocalisedString LocalisedString control stage doc]&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/GiveItemModifierPrototype&amp;diff=185532</id>
		<title>Types/GiveItemModifierPrototype</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/GiveItemModifierPrototype&amp;diff=185532"/>
		<updated>2021-04-09T15:24:10Z</updated>

		<summary type="html">&lt;p&gt;Xorimuth: Fix &amp;#039;most&amp;#039; -&amp;gt; &amp;#039;must&amp;#039; typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Extends [[Types/ModifierPrototype]].&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
Inherits all properties from [[Types/ModifierPrototype]].&lt;br /&gt;
&lt;br /&gt;
=== item ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of a [[Prototype/Item]].&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
&lt;br /&gt;
=== count ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/ItemCountType]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Must be &amp;gt; 0.&lt;/div&gt;</summary>
		<author><name>Xorimuth</name></author>
	</entry>
</feed>