This wiki is about 0.17, the current experimental version of Factorio.

Information about 0.16, the current stable version of Factorio, can be found on stable.wiki.factorio.com.

In other languages: Русский Українська 中文

Difference between revisions of "Modding"

From Official Factorio Wiki
Jump to: navigation, search
m (unorphaned page)
(Simplify, organize, and elaborate.)
Line 1: Line 1:
 +
 
{{Languages}}
 
{{Languages}}
  
[http://lua-api.Factorio.com/latest Factorio's modding API] allows for members of the community to add features and entities to the game. Factorio's modding API uses the language [https://lua.org Lua] to interpret scripting and setup of entities, and injects them into the start up and data construction of the game. This API offers many hooks for modders to have actions run when the hook triggers.
+
This page tells you how to download and install mods, and gives a quick overview of what you should keep in mind when creating a mod. For more detailed instructions on creating mods, you may view the [[Tutorial:Modding Tutorial| modding tutorial page]]. If you are looking for the modding API, check out the [http://lua-api.factorio.com/latest/ official Factorio Lua API documentation] website. If you wish to know where to install a mod which is in a zipped format, please read the instructions on the [[Application directory|application directory]] page.
 +
 
 +
== Downloading & installing mods ==
 +
 
 +
You can download the mods from the following places:
  
This page documents modding of Factorio in general, for a tutorial for making mods, see [[Tutorial:Modding Tutorial|this wiki's tutorials]], and for information on where mods are installed to, see [[Application directory]].
+
* [https://mods.factorio.com/ Mod portal (website)]
 +
* Mod portal (in-game)
 +
* [https://forums.factorio.com/viewforum.php?f=14&sid=68de6ef9ee46dcd7566653335917752b Mod subforum]
  
== Installing mods ==
+
=== Mod portal (website) ===
  
There are 2 ways to install mods in Factorio. Both of these methods are supported.
+
Factorio's developers created the [https://mods.factorio.com/ mod portal (website)] to allow the players to share mods. A mod you download from the website comes in the form of a zipped file. To install the mod, you need to copy the zipped file into the mods directory located under the [[Application directory|application directory]] without unzipping it. You can verify whether or not you installed it correctly by viewing the mods list which you can access through the game's main menu.
  
=== The mod portal ===
+
=== Mod portal (in-game) ===
  
Factorio's devs have set up a mod portal for uploading, hosting, and sharing mods to be downloaded by players. This is the primary place to get mods, secondary being the forums. To download a mod, simply visit the mod portal in-game or with a browser, and download the mod. If you're browsing in-game, the game will automatically install the mod for you. If you're browsing with a browser, you will need to place the downloaded zipped mod in your [[Application directory|mods directory]].
+
The mods displayed on the [https://mods.factorio.com/ mod portal (website)] should show in the in-game mod portal which you can access through the game's main menu. The differences in the in-game mod portal are that you can use it to both automatically download and install mods, and to enable or disable the mods.
  
=== Manual downloading ===
+
=== Mod subforum ===
  
Whether the mod was downloaded from the mod portal or the forums, sometimes manual installation is required. Simply drop the ZIP archive of the mod into your [[Application directory|mods directory]], no need to unzip it. You can see if it has loaded correctly by checking the in-game mods list, in the main menu.
+
Some mod creators upload their mods to the official [https://forums.factorio.com/viewforum.php?f=14&sid=68de6ef9ee46dcd7566653335917752b mod subforum] to showcase their work without submitting to the mod portal or to get feedbacks from the community on their mods before updating or sending them to the mod portal. An uploaded mod should show as an attachment.  Occasionally, a mod you download from the subforum comes in the form of a zipped file. You need to copy it into the mods directory located under the [[Application directory|application directory]] to install it — you do not have to unzip it. You can verify whether or not you installed it correctly by viewing the mods list which you can access through the game's main menu.
  
 
=== Dependencies ===
 
=== Dependencies ===
  
Factorio's mods have the ability to setup dependencies for themselves, which means that some mods will also require some other mods to be installed, or in some cases, not require them, but enable extra functionality if the extra mods are installed. In either case, currently dependencies are not automatically resolved, so it is up to the user to find and install all of the dependencies that the mod requires. This is expected to be made an automatic process in the future.
+
Many mods use Factorio's base mod as their only dependency which you do not have to install separately. However, some mods may require you to install other mods for them to work and can also make suggestions for you to install other mods for them to extend their functionality.
 +
 
 +
==== Required dependency ====
  
== Creation of mods ==
+
When a mod you installed requires you to install another mod for it to work,  the other mod, in this case, is a required dependency.
All modding in Factorio is done in the Lua programming language. Lua files can be created and edited in any text editor. Well-known ones that offer syntax highlighting are Notepad++ and Sublime Text.
+
 
 +
==== Optional dependency ====
 +
 
 +
When a mod makes a suggestion to install another mod, but if it does not need that other mod for it to work, the other mod, in this case, is an optional dependency. You can install the optional dependencies which extend the functionality of a mod to enhance your gaming experience with the mod.
 +
 
 +
==== Sidenote ====
 +
 
 +
Currently, the in-game mod portal does not automatically download neither required nor optional dependencies; therefore, it is up to the user to find and install them. However, such process is expected to be made automatic in the future.
 +
 
 +
== Creating mods ==
 +
 
 +
=== Factorio modding API ===
 +
 
 +
[http://lua-api.Factorio.com/latest Factorio's modding API] allows you to add new game entities and introduce new behaviors to the game — it offers many hooks which you can use to trigger new and exciting actions.
 +
 
 +
=== Lua scripting ===
 +
 
 +
You need to use the Lua programming language to create any mods in Factorio. The game's mod system injects your code into the startup and to the data construction stage of the game. You can use any text editor to write the code for your mod. Well-known text editors that offer syntax highlighting for Lua are Notepad++ and Sublime Text.
  
 
Useful resources for Lua:
 
Useful resources for Lua:
 +
 
* [http://lua-users.org/wiki/TutorialDirectory Lua tutorial]
 
* [http://lua-users.org/wiki/TutorialDirectory Lua tutorial]
 
* [https://www.lua.org/manual/5.3/ Lua reference manual]
 
* [https://www.lua.org/manual/5.3/ Lua reference manual]
 
* [https://repl.it/languages/lua Lua REPL] : A Lua read-eval-print-loop, essentially a sandbox.
 
* [https://repl.it/languages/lua Lua REPL] : A Lua read-eval-print-loop, essentially a sandbox.
  
=== Format ===
+
=== Basic structure of a mod ===
Factorio's mods are distributed in ZIP archives, and contain a few key files that Factorio looks for when loading mods. These files are listed below, with red entries being absolutely required.
 
  
* <span style="color:#FF5555">info.json</span>
+
Factorio's mods are distributed in ZIP archives and contain several important files that Factorio looks for when loading mods. These files are listed below, and the required files are colored red.
* control.Lua
+
 
* data.Lua
+
* ExampleMod_v0.0.1.zip
* data-updates.Lua
+
** <span style="color:#FF5555">info.json</span>
* data-final-fixes.Lua
+
** control.Lua
 +
** data.Lua
 +
** data-updates.Lua
 +
** data-final-fixes.Lua
  
 
=== Licensing ===
 
=== Licensing ===
All mods require a license since v0.11. If a mod has no license it is assumed to have a Creative Commons [http://creativecommons.org/licenses/by-nc/4.0 Attribution-Noncommercial 4.0 International (CC BY-NC 4.0)] license. However, it is possible to purposely unlicense the mod, to allow the code within it to be common public domain. The most common and popular distribution licenses for factorio mods are the MIT license, and the GPL license.
+
 
 +
Every mod requires a license since Factorio '''v0.11'''. If a mod has no license, it is assumed to have a Creative Commons license — [http://creativecommons.org/licenses/by-nc/4.0 Attribution-Noncommercial 4.0 International (CC BY-NC 4.0)]. However, it is possible to purposely make the mod [https://choosealicense.com/licenses/unlicense/ unlicensed], to allow the code within it to be available to the public domain. The most popular distribution licenses for Factorio mods are the [https://choosealicense.com/licenses/mit/ MIT license] and the [https://choosealicense.com/licenses/gpl-3.0/ GPLv3] license.
  
 
Other useful legal links include:
 
Other useful legal links include:
Line 45: Line 75:
 
* [http://www.factorioforums.com/forum/viewtopic.php?f=6&t=6202&p=48971#p48968 Forum post on allowed use of base-mod content]
 
* [http://www.factorioforums.com/forum/viewtopic.php?f=6&t=6202&p=48971#p48968 Forum post on allowed use of base-mod content]
 
* [http://www.factorio.com/terms-of-service Factorio terms of service]
 
* [http://www.factorio.com/terms-of-service Factorio terms of service]
 +
* [https://choosealicense.com/licenses/ Choose a license]
  
 
== See also ==
 
== See also ==
 +
 +
* [[Internal object names]]
 +
* [[Prototype definitions]]
 
* [[Script interfaces]]
 
* [[Script interfaces]]
 
* [[Tutorial:Modding FAQ| Modding Frequently asked Questions]]
 
* [[Tutorial:Modding FAQ| Modding Frequently asked Questions]]
* [[Tutorial:Modding Tutorial|Tutorials for modding.]]
+
* [[Tutorial:Modding Tutorial|Tutorials for modding]]
 
* [http://lua-api.factorio.com/latest/ Official Factorio Lua API documentation]
 
* [http://lua-api.factorio.com/latest/ Official Factorio Lua API documentation]
* [[Internal object names]]
 
* [[Prototype definitions]]
 

Revision as of 05:49, 21 July 2017


This page tells you how to download and install mods, and gives a quick overview of what you should keep in mind when creating a mod. For more detailed instructions on creating mods, you may view the modding tutorial page. If you are looking for the modding API, check out the official Factorio Lua API documentation website. If you wish to know where to install a mod which is in a zipped format, please read the instructions on the application directory page.

Downloading & installing mods

You can download the mods from the following places:

Mod portal (website)

Factorio's developers created the mod portal (website) to allow the players to share mods. A mod you download from the website comes in the form of a zipped file. To install the mod, you need to copy the zipped file into the mods directory located under the application directory without unzipping it. You can verify whether or not you installed it correctly by viewing the mods list which you can access through the game's main menu.

Mod portal (in-game)

The mods displayed on the mod portal (website) should show in the in-game mod portal which you can access through the game's main menu. The differences in the in-game mod portal are that you can use it to both automatically download and install mods, and to enable or disable the mods.

Mod subforum

Some mod creators upload their mods to the official mod subforum to showcase their work without submitting to the mod portal or to get feedbacks from the community on their mods before updating or sending them to the mod portal. An uploaded mod should show as an attachment. Occasionally, a mod you download from the subforum comes in the form of a zipped file. You need to copy it into the mods directory located under the application directory to install it — you do not have to unzip it. You can verify whether or not you installed it correctly by viewing the mods list which you can access through the game's main menu.

Dependencies

Many mods use Factorio's base mod as their only dependency which you do not have to install separately. However, some mods may require you to install other mods for them to work and can also make suggestions for you to install other mods for them to extend their functionality.

Required dependency

When a mod you installed requires you to install another mod for it to work, the other mod, in this case, is a required dependency.

Optional dependency

When a mod makes a suggestion to install another mod, but if it does not need that other mod for it to work, the other mod, in this case, is an optional dependency. You can install the optional dependencies which extend the functionality of a mod to enhance your gaming experience with the mod.

Sidenote

Currently, the in-game mod portal does not automatically download neither required nor optional dependencies; therefore, it is up to the user to find and install them. However, such process is expected to be made automatic in the future.

Creating mods

Factorio modding API

Factorio's modding API allows you to add new game entities and introduce new behaviors to the game — it offers many hooks which you can use to trigger new and exciting actions.

Lua scripting

You need to use the Lua programming language to create any mods in Factorio. The game's mod system injects your code into the startup and to the data construction stage of the game. You can use any text editor to write the code for your mod. Well-known text editors that offer syntax highlighting for Lua are Notepad++ and Sublime Text.

Useful resources for Lua:

Basic structure of a mod

Factorio's mods are distributed in ZIP archives and contain several important files that Factorio looks for when loading mods. These files are listed below, and the required files are colored red.

  • ExampleMod_v0.0.1.zip
    • info.json
    • control.Lua
    • data.Lua
    • data-updates.Lua
    • data-final-fixes.Lua

Licensing

Every mod requires a license since Factorio v0.11. If a mod has no license, it is assumed to have a Creative Commons license — Attribution-Noncommercial 4.0 International (CC BY-NC 4.0). However, it is possible to purposely make the mod unlicensed, to allow the code within it to be available to the public domain. The most popular distribution licenses for Factorio mods are the MIT license and the GPLv3 license.

Other useful legal links include:

See also