<?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=Sparr</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=Sparr"/>
	<link rel="alternate" type="text/html" href="https://wiki.factorio.com/Special:Contributions/Sparr"/>
	<updated>2026-05-18T08:31:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=User:Sparr/Core_Libraries&amp;diff=181819</id>
		<title>User:Sparr/Core Libraries</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=User:Sparr/Core_Libraries&amp;diff=181819"/>
		<updated>2020-08-27T19:07:41Z</updated>

		<summary type="html">&lt;p&gt;Sparr: Initial page creation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The factorio core data includes a collection of lua libraries that are used as part of the core and base game definitions. These libraries can be used when writing new mods.&lt;br /&gt;
&lt;br /&gt;
The latest version of these libraries are visible in [https://github.com/wube/factorio-data/tree/master/core/lualib the Factorio Data git repository].&lt;br /&gt;
&lt;br /&gt;
Usage example (for most libraries):&lt;br /&gt;
&lt;br /&gt;
 local lib_name = require(&amp;quot;lib-name&amp;quot;)&lt;br /&gt;
 lib_name.some_method(...&lt;br /&gt;
&lt;br /&gt;
== autoplace_utils.lua ==&lt;br /&gt;
Helper function(s) for building [https://lua-api.factorio.com/latest/Concepts.html#AutoplaceSpecification autoplace specifications]&lt;br /&gt;
&lt;br /&gt;
== biome-visualization-utils.lua ==&lt;br /&gt;
??&lt;br /&gt;
&lt;br /&gt;
== bonus-gui-ordering.lua ==&lt;br /&gt;
Lookup table for GUI ordering of effect bonuses&lt;br /&gt;
&lt;br /&gt;
== builder.lua ==&lt;br /&gt;
Class for creating entities repeatedly on a timer with a defined set of positions&lt;br /&gt;
&lt;br /&gt;
== camera.lua ==&lt;br /&gt;
Class for managing automatic camera zooming and panning&lt;br /&gt;
&lt;br /&gt;
== circuit-connector-generated-definitions.lua &amp;lt;br /&amp;gt;circuit-connector-sprites.lua ==&lt;br /&gt;
Used to generate definitions for circuit connectors on various entities&lt;br /&gt;
&lt;br /&gt;
== crash-site.lua ==&lt;br /&gt;
Produces the start-of-game crash site entities&lt;br /&gt;
&lt;br /&gt;
== dataloader.lua ==&lt;br /&gt;
Initializes data and defines data.extend() for use in the data stage&lt;br /&gt;
&lt;br /&gt;
== event_handler.lua ==&lt;br /&gt;
Manages remote interfaces and event handlers for multiple libraries in the same mod&lt;br /&gt;
&lt;br /&gt;
== flying_tags.lua ==&lt;br /&gt;
Creates flying text entities that follow another entity&lt;br /&gt;
&lt;br /&gt;
== kill-score.lua ==&lt;br /&gt;
Defines scoring values for kills, relative to production-score.lua&lt;br /&gt;
&lt;br /&gt;
== math2d.lua ==&lt;br /&gt;
Helper functions for manipulating and operating on 2D vectors and areas&lt;br /&gt;
&lt;br /&gt;
== math3d.lua ==&lt;br /&gt;
Helper functions for operating on 2D, 3D, and 4D vectors&lt;br /&gt;
&lt;br /&gt;
== mod-gui.lua ==&lt;br /&gt;
Attempt to standardize abstractions of access to player.gui.left and player.gui.top&lt;br /&gt;
&lt;br /&gt;
== noise/expression-to-ascii-math.lua ==&lt;br /&gt;
??&lt;br /&gt;
&lt;br /&gt;
== noise.lua ==&lt;br /&gt;
Helper functions for manipulating and operating on [[Types/NoiseExpression|noise expressions]]&lt;br /&gt;
&lt;br /&gt;
== production-score.lua ==&lt;br /&gt;
Calculate score value of items produced based on their ingredients&lt;br /&gt;
&lt;br /&gt;
== resource-autoplace.lua ==&lt;br /&gt;
Turns resource patch distribution descriptions into [https://lua-api.factorio.com/latest/Concepts.html#AutoplaceSpecification autoplace specifications]&lt;br /&gt;
&lt;br /&gt;
== silo-script.lua ==&lt;br /&gt;
Handles tracking of rocket launches&lt;br /&gt;
&lt;br /&gt;
== story.lua &amp;lt;br /&amp;gt;story-skeleton.lua ==&lt;br /&gt;
Helpers for building a &amp;quot;story&amp;quot; like the Compilatron tutorial&lt;br /&gt;
&lt;br /&gt;
== util.lua ==&lt;br /&gt;
Many miscellaneous helper functions for dealing with a wide range of things&lt;/div&gt;</summary>
		<author><name>Sparr</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/MapGenPresets&amp;diff=172584</id>
		<title>Prototype/MapGenPresets</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/MapGenPresets&amp;diff=172584"/>
		<updated>2019-04-20T20:28:54Z</updated>

		<summary type="html">&lt;p&gt;Sparr: remove ambiguous `default`&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
Prototype type: &#039;&#039;&#039;map-gen-presets&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The available map gen presets.&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Must be &amp;quot;map-gen-presets&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== name ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the map-gen-presets. Must be &amp;quot;default&amp;quot; since only one instances of this prototype can be defined.&lt;br /&gt;
&lt;br /&gt;
=== the name of a preset ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/MapGenPreset]]&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;somepreset =&lt;br /&gt;
  {&lt;br /&gt;
    default = true,&lt;br /&gt;
    order = &amp;quot;a&amp;quot;&lt;br /&gt;
  },&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sparr</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=File_talk:4to4_balancer_throughput_limit_demo.gif&amp;diff=172486</id>
		<title>File talk:4to4 balancer throughput limit demo.gif</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=File_talk:4to4_balancer_throughput_limit_demo.gif&amp;diff=172486"/>
		<updated>2019-04-13T17:56:52Z</updated>

		<summary type="html">&lt;p&gt;Sparr: /* Could demonstrate better */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Could demonstrate better ==&lt;br /&gt;
&lt;br /&gt;
This illustration does not make the bottleneck obvious. It would be better if the two input belts were saturated and only moving at half speed, and the two output belts half-full. [[User:Sparr|Sparr]] ([[User talk:Sparr|talk]]) 17:56, 13 April 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Sparr</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Scenario_system&amp;diff=158359</id>
		<title>Scenario system</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Scenario_system&amp;diff=158359"/>
		<updated>2018-04-20T17:30:58Z</updated>

		<summary type="html">&lt;p&gt;Sparr: /* Installing scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
&lt;br /&gt;
The scenario system allows save-based mods to be created, so that installing mods separately is not necessary. This allows for server side scripting, or to provide a separate objective than the vanilla freeplay (which is actually a scenario, just like the [[campaign]]).&lt;br /&gt;
&lt;br /&gt;
== Creation ==&lt;br /&gt;
&lt;br /&gt;
Creation of a scenario starts in the world editor. The world editor allows an author to save a world that they have created as a scenario. This allows players to add special scripting to the scenario.&lt;br /&gt;
&lt;br /&gt;
There are two ways to create a scenario:&lt;br /&gt;
&lt;br /&gt;
* Running Factorio with the --map2scenario [[Console#Command_Line_Parameters|runtime flag]], which allows specifying a save to transform into a scenario. It is possible to turn a scenario back into a normal save with the --scenario2map runtime flag.&lt;br /&gt;
* Via the [[Map editor]].&lt;br /&gt;
&lt;br /&gt;
== Differences between scenarios, saves, and mods ==&lt;br /&gt;
&lt;br /&gt;
There are a few differences between a scenario, a save, and a mod. In a way, a scenario takes parts from both.&lt;br /&gt;
&lt;br /&gt;
* Scenarios, unlike mods, cannot add anything to the game. The only type of scripting allowed in a scenario is scripting that would occur in control.Lua.&lt;br /&gt;
* Scenarios generate the exact same world every time when created by the world editor.&lt;br /&gt;
* Scenarios do not need to be installed client side, unlike mods. This allows servers to implement small changes to gameplay on their end, such as displaying a MOTD to joining players.&lt;br /&gt;
* Scenarios, unlike normal saves, are stored in a different folder.&lt;br /&gt;
* Scenarios&#039; maps cannot be extracted directly, the game must be used to convert the scenario back into a save.&lt;br /&gt;
* Scenarios can be used to create a bit of a story, as the campaign does.&lt;br /&gt;
&lt;br /&gt;
== Limitations of Scenarios ==&lt;br /&gt;
&lt;br /&gt;
* Currently, scenarios cannot be uploaded to the official mod portal, they must be shared on other community websites.&lt;br /&gt;
* Scenarios cannot add anything to the game (Namely, they may not make calls to data:extend()).&lt;br /&gt;
* Scenarios count as mods for the purpose of isolating [[achievements]].&lt;br /&gt;
&lt;br /&gt;
== Playing a scenario ==&lt;br /&gt;
&lt;br /&gt;
There are several scenarios included into the game by default. To play a scenario, click Play-&amp;gt;Scenarios, and choose either a user scenario, or a scenario from the base game. The Freeplay scenario is the same as the basic game, where the objective is to launch a rocket.&lt;br /&gt;
&lt;br /&gt;
Upon choosing a scenario to play and saving the game, a normal save will be created that encompasses the map itself, and the control.Lua scripting that was provided by the scenario. This can be removed by deleting the script.dat and control.Lua files from the save, turning it into a normal save. Do this at your own risk, as it may break the save depending on how intertwined the scenario is with the save.&lt;br /&gt;
&lt;br /&gt;
== Installing scenarios ==&lt;br /&gt;
&lt;br /&gt;
Scenarios made by other players can be installed into a folder called scenarios in the player&#039;s [[application directory|user data directory]]. It can then be played from the scenarios menu.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Campaign]]&lt;br /&gt;
* [[Map editor]]&lt;br /&gt;
* [[World generator]]&lt;/div&gt;</summary>
		<author><name>Sparr</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Scenario_system&amp;diff=158358</id>
		<title>Scenario system</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Scenario_system&amp;diff=158358"/>
		<updated>2018-04-20T17:30:30Z</updated>

		<summary type="html">&lt;p&gt;Sparr: /* Installing scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
&lt;br /&gt;
The scenario system allows save-based mods to be created, so that installing mods separately is not necessary. This allows for server side scripting, or to provide a separate objective than the vanilla freeplay (which is actually a scenario, just like the [[campaign]]).&lt;br /&gt;
&lt;br /&gt;
== Creation ==&lt;br /&gt;
&lt;br /&gt;
Creation of a scenario starts in the world editor. The world editor allows an author to save a world that they have created as a scenario. This allows players to add special scripting to the scenario.&lt;br /&gt;
&lt;br /&gt;
There are two ways to create a scenario:&lt;br /&gt;
&lt;br /&gt;
* Running Factorio with the --map2scenario [[Console#Command_Line_Parameters|runtime flag]], which allows specifying a save to transform into a scenario. It is possible to turn a scenario back into a normal save with the --scenario2map runtime flag.&lt;br /&gt;
* Via the [[Map editor]].&lt;br /&gt;
&lt;br /&gt;
== Differences between scenarios, saves, and mods ==&lt;br /&gt;
&lt;br /&gt;
There are a few differences between a scenario, a save, and a mod. In a way, a scenario takes parts from both.&lt;br /&gt;
&lt;br /&gt;
* Scenarios, unlike mods, cannot add anything to the game. The only type of scripting allowed in a scenario is scripting that would occur in control.Lua.&lt;br /&gt;
* Scenarios generate the exact same world every time when created by the world editor.&lt;br /&gt;
* Scenarios do not need to be installed client side, unlike mods. This allows servers to implement small changes to gameplay on their end, such as displaying a MOTD to joining players.&lt;br /&gt;
* Scenarios, unlike normal saves, are stored in a different folder.&lt;br /&gt;
* Scenarios&#039; maps cannot be extracted directly, the game must be used to convert the scenario back into a save.&lt;br /&gt;
* Scenarios can be used to create a bit of a story, as the campaign does.&lt;br /&gt;
&lt;br /&gt;
== Limitations of Scenarios ==&lt;br /&gt;
&lt;br /&gt;
* Currently, scenarios cannot be uploaded to the official mod portal, they must be shared on other community websites.&lt;br /&gt;
* Scenarios cannot add anything to the game (Namely, they may not make calls to data:extend()).&lt;br /&gt;
* Scenarios count as mods for the purpose of isolating [[achievements]].&lt;br /&gt;
&lt;br /&gt;
== Playing a scenario ==&lt;br /&gt;
&lt;br /&gt;
There are several scenarios included into the game by default. To play a scenario, click Play-&amp;gt;Scenarios, and choose either a user scenario, or a scenario from the base game. The Freeplay scenario is the same as the basic game, where the objective is to launch a rocket.&lt;br /&gt;
&lt;br /&gt;
Upon choosing a scenario to play and saving the game, a normal save will be created that encompasses the map itself, and the control.Lua scripting that was provided by the scenario. This can be removed by deleting the script.dat and control.Lua files from the save, turning it into a normal save. Do this at your own risk, as it may break the save depending on how intertwined the scenario is with the save.&lt;br /&gt;
&lt;br /&gt;
== Installing scenarios ==&lt;br /&gt;
&lt;br /&gt;
Scenarios made by other players can be installed into a folder called scenarios in the player&#039;s [[user data directory]]. It can then be played from the scenarios menu.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Campaign]]&lt;br /&gt;
* [[Map editor]]&lt;br /&gt;
* [[World generator]]&lt;/div&gt;</summary>
		<author><name>Sparr</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Game-tick&amp;diff=137814</id>
		<title>Game-tick</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Game-tick&amp;diff=137814"/>
		<updated>2017-05-18T16:47:53Z</updated>

		<summary type="html">&lt;p&gt;Sparr: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
A game-tick (or just &amp;quot;tick&amp;quot;) is 1/60 of a [[Game-second]].&lt;br /&gt;
&lt;br /&gt;
Everything in Factorio is calculated with that base. For example the speed of anything is internally calculated in [[Tile]]/tick.&lt;br /&gt;
&lt;br /&gt;
The real-world duration of a game-tick depends on the speed of your computer, and is at least 1/60th of a second (0,01667 seconds). A tick can last longer when the game stops (say, to autosave) or if the framerate drops below 60FPS.&lt;br /&gt;
&lt;br /&gt;
=== What is done during one tick? ===&lt;br /&gt;
&lt;br /&gt;
[https://www.factorio.com/blog/post/fff-70 This FFF-article] explains what the game engine calculates on every tick.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Time]]&lt;br /&gt;
* [http://lua-api.factorio.com/latest/LuaGameScript.html].&lt;br /&gt;
* [[Game-second]]&lt;br /&gt;
* [[Game-day]]&lt;br /&gt;
* [[Units]]&lt;/div&gt;</summary>
		<author><name>Sparr</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Tutorial:Modding_tutorial/Gangsir&amp;diff=137504</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=137504"/>
		<updated>2017-05-15T20:39:05Z</updated>

		<summary type="html">&lt;p&gt;Sparr: elaborated on various details&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a modding tutorial for Factorio version 0.15. 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 created for version 0.15, 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, position in the player table, etc. All players have characters, but no characters have players within them.&lt;br /&gt;
; Prototype : A prototype describes a kind of entity, a bit like a template. It defines stats, what the entity actually is, etc. A prototype is used to create an entity, and many functionally identical entities 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;
; Recipe : This is a data structure a bit like a prototype that defines a recipe for the internal crafting engine. A &#039;&#039;&#039;technology&#039;&#039;&#039; follows a similar setup.&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. 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 at their [http://lua-api.factorio.com/latest/ API site.] Get used to using this site, as it will become a frequent visit you will make while you develop mods. It contains information on [http://lua-api.factorio.com/latest/Classes.html Factorio&#039;s classes], information on [http://lua-api.factorio.com/latest/Concepts.html concepts], and information on [http://lua-api.factorio.com/latest/events.html events] that you can hook into. You will need to check this site often, so the author recommends bookmarking it. In addition to this site, 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, and Notepad++ are all viable candidates. This author prefers Emacs, but it does not make a difference in the mod itself.&lt;br /&gt;
&lt;br /&gt;
== How Factorio loads mods ==&lt;br /&gt;
&lt;br /&gt;
=== The data stage ===&lt;br /&gt;
&lt;br /&gt;
When Factorio first initializes, it initializes part of itself, then starts looking for mods. 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 two kinds of dependencies. There are required dependencies, and optional dependencies. 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;
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 and entities. Stuff 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;. This file is executed, then each mod&#039;s &amp;lt;code&amp;gt;data-updates.lua&amp;lt;/code&amp;gt;, and finally each mod&#039;s &amp;lt;code&amp;gt;data-final-fixes.lua&amp;lt;/code&amp;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;
=== Migrations ===&lt;br /&gt;
&lt;br /&gt;
[http://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 prototypes change within a mod, migrations must be setup to correct 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 making changes to prototypes that effect prototype name, type, recipe, or technology. These things cannot be dynamically changed, and resetting techs or recipes may be necessary. Try to avoid these changes after shipping the mod out to the public. Try to come up with a finalized version of the prototype 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;
=== Control ===&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. Because this 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 [http://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;
=== Runtime ===&lt;br /&gt;
&lt;br /&gt;
At this stage, the mod is setup, and the save is running. Access to all tables provided by the game can be done inside of event handlers. (More on those below.)&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;
Over time, the community has settled on some conventions for how a mod&#039;s directory structure should look. Following these to a T is not necessary, but can simplify things and make discussing mod bugs and improvements with other developers easier. More on directory structure below.&lt;br /&gt;
&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;
Like this tutorial mentioned earlier, there is a somewhat community standard around for how a mod is laid out. This, combined with how the game expects mods to be laid out, limits us slightly. 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;FireArmor_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;
*** FireArmor_0.1.0&lt;br /&gt;
&lt;br /&gt;
Then, inside FireArmor_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;
*** FireArmor_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 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;FireArmor&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;contact&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
    &amp;quot;homepage&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
    &amp;quot;factorio_version&amp;quot;: &amp;quot;0.15&amp;quot;,&lt;br /&gt;
    &amp;quot;dependencies&amp;quot;: [&amp;quot;base &amp;gt;= 0.15&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;
; name : This is the internal name of your mod, it is used to identify your mod in code.&lt;br /&gt;
; version : This is the version of your mod. This can be anything you want, provided it&#039;s a number. Some mods start at 0.0.1 or 0.1.0, while others follow Factorio versions and start at 0.15.0 (for Factorio version 0.15.X)&lt;br /&gt;
; title : 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;
; author : Your name! You can change this in the example above.&lt;br /&gt;
; contact : Put contact info here, so someone can find you in the event of a problem.&lt;br /&gt;
; homepage : The homepage of your mod, put a website here if you have one for the mod. Not required.&lt;br /&gt;
; factorio_version : This tells the game what version the mod is for, this must match the version you&#039;re developing the mod for, 0.15 in this case.&lt;br /&gt;
; dependencies : Any dependencies of your mod. Some form of &amp;quot;base&amp;quot; should always be here, so base gets loaded first.&lt;br /&gt;
; description : A &#039;&#039;short&#039;&#039; description of your mod.&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;prototypes.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 in prototypes, which we&#039;re about to create. Create a folder in FireArmor_0.1.0 called &amp;lt;code&amp;gt;prototypes&amp;lt;/code&amp;gt;, then inside prototypes, create a file called &amp;lt;code&amp;gt;item.lua&amp;lt;/code&amp;gt;. Your mod directory should now match [https://github.com/TheRealGangsir/FactorioModdingTutorial/tree/cf505cf536e136bccef3d675bf2fc5648c659d97 this github snapshot].&lt;br /&gt;
&lt;br /&gt;
Notice how our earlier require used the folder and file name in it?&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 copying an existing definition from one of the default lua files provided with an install of Factorio, and the short way just uses a lua function to copy and modify a 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.armor[&amp;quot;heavy-armor&amp;quot;])&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.recipe[&amp;quot;heavy-armor&amp;quot;])&lt;br /&gt;
recipe.enabled = true&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 /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;
At this point, the mod looks like [https://github.com/TheRealGangsir/FactorioModdingTutorial/tree/2fc7dc944f5d523216762793f7c1bd31c6792b40 this].&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 types, and within those types, individual entities. 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.armor[&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. For example, the player&#039;s prototype would be:&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.player[&amp;quot;player&amp;quot;]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because the player is &#039;&#039;the&#039;&#039; player, his type matches his name. You could define a new type of player with a mod. You can see all the prototype fields for an entity in it&#039;s long declaration in the Factorio install, at (Install)/data/base/prototypes.&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, 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.container[&#039;iron-chest&#039;].max_health = 1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reason why this code must be in data-final-fixes.lua or data-updates.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 [http://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 modified 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 periodically create fire on the ground as we walk with the armor on. The event we&#039;re going to use is called on_tick, since we want the fire to be periodically created.&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 in data.lua 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_tick},&lt;br /&gt;
   function (e)&lt;br /&gt;
      if e.tick % 60 == 0 then --common trick to reduce how often this runs, we don&#039;t want it running every tick, just 1/second&lt;br /&gt;
         for index,player in pairs(game.players) do  --loop through all players on the server&lt;br /&gt;
            if player.get_inventory(defines.inventory.player_armor).get_item_count(&amp;quot;fire-armor&amp;quot;) &amp;gt;= 1 then --if they&#039;re wearing our armor&lt;br /&gt;
               game.surfaces[1].create_entity{name=&amp;quot;fire-flame&amp;quot;,position=player.position, force=&amp;quot;neutral&amp;quot;} --create the fire where they&#039;re standing&lt;br /&gt;
            end&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 is wearing, with defines.inventory.player_armor, which is an inventory constant. You can read the list of defines [http://lua-api.factorio.com/latest/defines.html#defines.inventory here].&lt;br /&gt;
&lt;br /&gt;
At this point, the mod will look like [https://github.com/TheRealGangsir/FactorioModdingTutorial/tree/26b75c799834b9a8323d500af11b0233b824d002 this].&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;config.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 config.cfg, 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;
Finally, the mod will look like [https://github.com/TheRealGangsir/FactorioModdingTutorial this].&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: __FireArmor__/data.lua:1:__FireArmor__/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 FireArmor::on_tick (ID 0)&lt;br /&gt;
__FireArmor__/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].position)&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 cause a crash. Instead, it&#039;ll just not work. The modder is attempting to print a table. [http://lua-api.factorio.com/latest/Concepts.html#Position player.position] is a table of two values, x and y. Trying to print it will just print the memory address of the table.&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;
&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 FireArmor::on_tick (ID 0)&lt;br /&gt;
Unknown entity name: fire-flam&lt;br /&gt;
stack traceback:&lt;br /&gt;
__FireArmor__/control.lua:6: in function &amp;lt;__FireArmor__/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 6 of control.lua, inside of an on_tick 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:106: Map tick at moment of crash: 432029&lt;br /&gt;
696.148 Error Util.cpp:76: 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;
&amp;lt;/pre&amp;gt;&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. As all mods can be opened and looked at, 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;
* [[Mods]]&lt;br /&gt;
* [[Modding overview]]&lt;br /&gt;
* [[Modding FAQ]]&lt;/div&gt;</summary>
		<author><name>Sparr</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Factorio:Wiki_rules&amp;diff=137182</id>
		<title>Factorio:Wiki rules</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Factorio:Wiki_rules&amp;diff=137182"/>
		<updated>2017-05-09T22:56:36Z</updated>

		<summary type="html">&lt;p&gt;Sparr: link to Editor noticeboard&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Languages}}&lt;br /&gt;
&lt;br /&gt;
Below are the community guidelines for the Official Factorio Wiki. Infringing upon any of these rules will result in either a warning or a temporary/permanent ban, depending on the circumstances. These rules are not final, and are subject to change. Additionally, all admins hold the right to enforce as they see fit, even if the rule they enforce is not specifically enumerated here.&lt;br /&gt;
&lt;br /&gt;
=== Language ===&lt;br /&gt;
&lt;br /&gt;
* The default language is American English, however English pages may also use European English. All pages must have an English version, and should be translated English -&amp;gt; Other. Use of country-specific slang must be avoided, except for localization reasons.&lt;br /&gt;
* Any other language has no right to obtain a page name which collides with English.&lt;br /&gt;
* No other language has the right to use a page name which means the same or something different in another language.&lt;br /&gt;
* Language pages when translated should use the English name with the language code appended to the end of the name. For example, &amp;quot;Transport belt&amp;quot; when translated to German should be named &amp;quot;Transport belt/de&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Typo control ===&lt;br /&gt;
&lt;br /&gt;
* Please use the &amp;quot;Show preview&amp;quot; button to view your changes before saving them, to allow yourself to catch incorrect links and typos, and improper formatting. While creating multiple edits to the same page is allowed, it creates clutter on the recent changes screen.&lt;br /&gt;
* Please correct all typos found, even if changing the sentence layout is necessary. Comprehension is important.&lt;br /&gt;
* Run a spell check of the article to catch spelling errors.&lt;br /&gt;
&lt;br /&gt;
=== Conduct ===&lt;br /&gt;
&lt;br /&gt;
* Be respectful to all editors, and readers. &#039;&#039;&#039;All forms of hate are not tolerated&#039;&#039;&#039;, and will result in a warning and ban.&lt;br /&gt;
* &#039;&#039;&#039;All forms of vandalism and spam are not tolerated&#039;&#039;&#039;, and violators will be banned without question.&lt;br /&gt;
* Do not edit-war. If a user overwrites your change and you disagree, do not edit the page back and forth, discuss it on the talk page of the page in question. In instances of edit warring, the oldest version is preferred until a decision is reached.&lt;br /&gt;
* This ties into the above rule, but assume good faith. If a wiki editor makes a mistake due to human error, the fact that they are new to the community, or any other honest reason, fellow wiki community members must assume good faith. Rather than insulting, berating, or lashing out at the editor, community members should approach situations like these with a helpful and understanding attitude.&lt;br /&gt;
* Wiki talk pages are for discussion of their respective page &#039;&#039;&#039;only&#039;&#039;&#039;. Please keep all discussion of in-game mechanics to the forums or subreddit, the links to which are in the sidebar. An article&#039;s talk page is intended for discussion or questions regarding the article&#039;s content. It is not a forum for casual discussion. Game suggestions, personal stories, shout-outs, etc. will be removed.&lt;br /&gt;
* Similarly, self/other promotional content is forbidden unless it is for &#039;&#039;specific examples and educational purposes&#039;&#039;. Edits made that simply show off or enumerate user creations will be removed.&lt;br /&gt;
* When making comments or asking questions on a talk page, be sure to sign the end with four tildes (&amp;lt;nowiki&amp;gt;~~~~&amp;lt;/nowiki&amp;gt;)&lt;br /&gt;
* Always remain civil during discussions.&lt;br /&gt;
* While the Wiki can be easily reverted in the event of a mistake, please try to avoid creating work for others.&lt;br /&gt;
* Registered users are expected to use a single account for all editing under most circumstances. The use of more than one account by a single individual is known as &amp;quot;sockpuppeting&amp;quot;, and is a very high offense. A second account can be used in certain rare circumstances by longtime established, trusted users. Some valid reasons to use a second account may include those below. In those cases, &#039;&#039;&#039;it must be made absolutely clear that the accounts are operated by the same individual.&#039;&#039;&#039;&lt;br /&gt;
** Technical testing&lt;br /&gt;
** Bot (automated) accounts&lt;br /&gt;
** Administrators who want to use non-admin accounts in less secure editing situations.&lt;br /&gt;
* Refrain from using profanity unless it is used within a direct quotation. Preferably, censor the curse with stars.&lt;br /&gt;
* Refrain from editing other users&#039; user pages, unless it is to remove broken links.&lt;br /&gt;
&lt;br /&gt;
=== Page layout guidelines and creation of new pages ===&lt;br /&gt;
&lt;br /&gt;
* Typically, a page will start with a short intro, then the content of the page, a history section, and a &amp;quot;see also&amp;quot; section. Please follow this when creating content pages. Categories should be used sparingly.&lt;br /&gt;
* Please use sane formatting, and do not Capitalize Words Like This, or L I K E T H I S.&lt;br /&gt;
* Do not overuse &#039;&#039;&#039;bold&#039;&#039;&#039;, &#039;&#039;italics&#039;&#039;, or &amp;lt;span style=&amp;quot;color:#00FF00&amp;quot;&amp;gt;colorful text.&amp;lt;/span&amp;gt; This detracts from the effect of said text when it is actually necessary.&lt;br /&gt;
* If possible, clean white-space from the ends of lines/pages. Many editors can do this for you. Emacs, Notepad++, Sublime Text, and Vim are recommended. This reduces the size of the page.&lt;br /&gt;
* Avoid creating unnecessary pages. If the info you are trying to add is related to an entity in-game, please place the info on that entity&#039;s page, and so on and so forth.&lt;br /&gt;
* See the [[Factorio:Editor noticeboard|Editor noticeboard]] for guidelines on whether the wiki is currently targeting the stable or experimental version of the game.&lt;br /&gt;
* [[Upcoming features]] should be referenced with a link to a comment or image posted by a member of Factorio&#039;s development staff.&lt;br /&gt;
* Mod related documentation is not to be hosted on this wiki. The Official Factorio Wiki is meant for documentation of the base game only. Instead, users looking for documentation or developers looking to provide documentation should do so on their mod&#039;s entry in the mod portal, or bundle the documentation with the source code of the mod. &#039;&#039;This wiki does not document nor enumerate mods.&#039;&#039;&lt;br /&gt;
* Edit in an “encyclopedia” style, avoiding use of the first person or any personal bias. Avoid words like I, me, you, etc.&lt;br /&gt;
* Do not create circular links, I.e. do not link a page to itself. While this doesn&#039;t do anything, it adds noise to the page that editors have to ignore.&lt;br /&gt;
* If making a comment to other editors is necessary, place the comment in comment delimiters, &amp;lt;nowiki&amp;gt;&amp;lt;!-- Comment --&amp;gt;&amp;lt;/nowiki&amp;gt; so it cannot be seen by users. This is only necessary to explain the page&#039;s specific formatting, such as seen on [[News]].&lt;br /&gt;
* Work in progress pages &#039;&#039;&#039;must&#039;&#039;&#039; be created in the author&#039;s userspace, and preferably an admin should be asked before merging into the greater Wiki. All WIP pages made outside the userspace will be moved into the author&#039;s space.&lt;br /&gt;
&lt;br /&gt;
=== The History section ===&lt;br /&gt;
&lt;br /&gt;
* This Wiki uses a history section on all content pages to track when entities/items are changed in the game. To do this, the Wiki uses the [[Template:History|history]] template, which provided automatic formatting and version linking.&lt;br /&gt;
* Bugs and bug fixes must not be placed in the update history section of a page, except for very significant instances. Instead, please document bugs in the bug sections of the official forums. However, bug fixes may be documented on [[Version history]] pages.&lt;br /&gt;
* While a history section is not required for information pages such as [[Railway]], all content pages concerning entities or mechanics of the game should have a history, taken from the changelog file provided with a standard Factorio install. The &amp;lt;nowiki&amp;gt;{{history}}&amp;lt;/nowiki&amp;gt; template will automatically link to the relevant page in [[Version history]].&lt;br /&gt;
* Trivia and general facts are allowed, as long as it does not contain personal opinion and is not conjecture.&lt;br /&gt;
&lt;br /&gt;
=== Media ===&lt;br /&gt;
&lt;br /&gt;
* When possible, avoid putting important text in images, as it is not search-able, and makes finding that info harder.&lt;br /&gt;
* When uploading an image, please use a descriptive, unique name, and fill out the description box. Images given a non-descriptive name will be renamed.&lt;br /&gt;
* When uploading an updated version of an image, use the &amp;quot;upload a new version of this image&amp;quot; link found on the old file&#039;s page. This ensures that all old instances are updated automatically.&lt;br /&gt;
* Please mark any duplicated files for deletion with the &amp;lt;nowiki&amp;gt;{{delete}}&amp;lt;/nowiki&amp;gt; template. If approved, an admin will delete them. Requests for pages in the requesting user&#039;s namespace are always granted.&lt;br /&gt;
* If uploading images that are not of Factorio, please ensure you hold rights to upload the image. We don&#039;t want to get DMCA requests.&lt;br /&gt;
* Please ensure that the image you are uploading is of good quality. Use the PNG filetype when possible.&lt;br /&gt;
* See the section [[#Pictures|below]] for more info on uploading images.&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
&lt;br /&gt;
* Templates are to be used for formatting/common text on many pages. Do not create templates for only a few pages, except for special circumstances.&lt;br /&gt;
* Templates should include &amp;lt;nowiki&amp;gt;{{documentation}}&amp;lt;/nowiki&amp;gt; inside of noinclude tags, and should have a /doc sub-page to describe the use of the template.&lt;br /&gt;
* Avoid making many sequential edits to a commonly used template. This creates strain on Wube&#039;s servers to update across all the pages. Preform edits to those templates with a single edit only. If you need to edit a protected template, please contact an admin, as these templates are especially heavily used.&lt;br /&gt;
* Templates should be light, contain little content, and have descriptive names.&lt;br /&gt;
* Templates must be created within the Template namespace. Please read up on this if you don&#039;t know what this means.&lt;br /&gt;
&lt;br /&gt;
=== Page protection ===&lt;br /&gt;
&lt;br /&gt;
* Typically, pages with high amounts of transclusions/importance will be protected, to both protect against vandalism, and to protect the servers from load caused by edits to these pages.&lt;br /&gt;
* If an editor needs to make a change to one of these protected pages, please contact an admin.&lt;br /&gt;
* If you encounter a page that you feel should/should not be protected, please contact an admin and explain your reasoning. &lt;br /&gt;
* We do not protect userspace pages, nor tutorials, as it is unfriendly to those who seek to fix mistakes.&lt;br /&gt;
&lt;br /&gt;
== Pictures ==&lt;br /&gt;
&lt;br /&gt;
=== Picture formats ===&lt;br /&gt;
&lt;br /&gt;
* (100 - 200) x (100-300) px&lt;br /&gt;
: For flowing with the text, pictures which explain the text, the browser can embed this into it&#039;s own rendering. You can put them left or right, the text should flow around.&lt;br /&gt;
* (400 - 600) x (100 - 600) px&lt;br /&gt;
: Something like a banner. A big picture which stays alone in its line. You may put simply a &amp;quot;:&amp;quot; in front of it to indent the picture and keep it away from flowing text.&lt;br /&gt;
* 300 x 300 px&lt;br /&gt;
: This is especially good for gif animations. Gif animations cannot be reduced in size, because Mediawiki re-renders the picture and the result is the first frame of the gif!&lt;br /&gt;
* The biggest format for flowing text should be: 600x600px&lt;br /&gt;
&lt;br /&gt;
To re-size an image when it&#039;s put onto a page, simply provide the size as an argument to the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;[[File:example.png|200x200px]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Making pictures out of the game ===&lt;br /&gt;
&lt;br /&gt;
Do&#039;s:&lt;br /&gt;
&lt;br /&gt;
* Take pictures at day! Use night or dawn only if you need to explain something that only works at night (for example, the lights).&lt;br /&gt;
* Turn off clouds! The shadows in GIF-animations are not useful.&lt;br /&gt;
* Steam/smoke is also not that useful.&lt;br /&gt;
* Use god mode! [http://lua-api.factorio.com/latest/LuaPlayer.html#LuaPlayer.set_controller]. You can move anywhere on the map and your character won&#039;t be in the picture.&lt;br /&gt;
* You can [http://lua-api.factorio.com/latest/LuaGameScript.html#LuaGameScript.speed slowdown the game] to find the right moment for the picture. Slowdown is also useful if you use Gifcam, which makes Screenshots in 30 frames/sec only.&lt;br /&gt;
* You can also use the peaceful mode to be not disturbed by the natives.&lt;br /&gt;
* You can stop the game in the right moment using SHIFT-SPACE key. That also blends the grid in.&lt;br /&gt;
* Learn how to use the [[Debug mode]] to add relevant information into the picture.&lt;br /&gt;
* Go into the highest zoom level you possibly can without missing any vital information.&lt;br /&gt;
* A good in-game picture should be rebuilt so that only the relevant entities/items are shown. Anything in the photo other than what you&#039;re trying to show/explain is unnecessary.&lt;br /&gt;
&lt;br /&gt;
Dont&#039;s:&lt;br /&gt;
&lt;br /&gt;
* Don&#039;t take pictures of clutter! The only stuff in the photo should be the stuff you&#039;re trying to show. The exception to clutter: If you&#039;re showing what a fully finished factory or setup might look like.&lt;br /&gt;
* Don&#039;t just take a screenshot. Try to remove all unneeded information from the picture.&lt;br /&gt;
* Try to make a picture without the character, except if to show something; then face the character toward it.&lt;br /&gt;
&lt;br /&gt;
See http://www.factorioforums.com/forum/viewtopic.php?f=6&amp;amp;t=2472 for more.&lt;br /&gt;
&lt;br /&gt;
== Taking Screenshots, animations and videos==&lt;br /&gt;
&lt;br /&gt;
=== Taking Screenshots ===&lt;br /&gt;
&lt;br /&gt;
* It&#039;s possible to take [http://lua-api.factorio.com/latest/LuaGameScript.html#LuaGameScript.take_screenshot Screenshots out of the game]! The [http://www.youtube.com/watch?v=9yDZM0diiYc second trailer] is made like so. See http://www.factorioforums.com/forum/viewtopic.php?f=18&amp;amp;t=5591&lt;br /&gt;
* [http://www.factorioforums.com/forum/viewtopic.php?f=18&amp;amp;t=5591 Calculate screenshot dimensions].&lt;br /&gt;
&lt;br /&gt;
==== Optimizing the picture before upload ====&lt;br /&gt;
&lt;br /&gt;
* Cut as much as possible/nice.&lt;br /&gt;
* Resolution should not normally be higher than 600x600 px. Use multiple photos or ask a trusted wiki user if you need a much larger photo.&lt;br /&gt;
* &#039;&#039;Do not add text to the photos&#039;&#039; Write any needed text outside the photo on the wiki. You cannot search text that is in a photo and users might not find what they are looking for.&lt;br /&gt;
* Sharpen the pictures. For the wiki it looks a lot better to sharpen the pictures once or twice.&lt;/div&gt;</summary>
		<author><name>Sparr</name></author>
	</entry>
</feed>