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

Modding: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (typo)
m (capitalize GitHub)
 
(33 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Languages}}
{{Languages}}
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.


[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.
== Downloading & installing mods ==


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]].
You can download the mods from the following places:


== Installing mods ==
* Mod portal (in-game)
* [https://mods.factorio.com/ Mod portal (website)]
* [https://forums.factorio.com/viewforum.php?f=14&sid=68de6ef9ee46dcd7566653335917752b Mod subforum]


There are 2 ways to install mods in Factorio. Both of these methods are supported.
=== Mod portal (in-game) ===


=== The mod portal ===
The "Mods" section of the main menu is the best way to get mods. It combines downloading & installing, checking installed mods for updates, and enabling/disabling installed mods.


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]].
=== Mod portal (website) ===


=== Manual downloading ===
The [https://mods.factorio.com/ mod portal (website)] is the center of mod hosting, where authors upload mods, and you can find previous versions, and discussions. Mods come as ZIP files, installed by copying (not unzipping) into the "mods" directory in the [[Application_directory#User_Data_directory|user data directory]]. Verify a successful installation by viewing the "Mods" list through the main menu, in-game.


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.
=== Mod subforum ===
 
Mod authors maintain threads in the official [https://forums.factorio.com/viewforum.php?f=14&sid=68de6ef9ee46dcd7566653335917752b mod subforum] to support their work. There may be experimental mods or updates here that aren't available on the main portal. They will be downloaded as ZIP files, either as forum "attachments", or with a link to a hosting site. These are installed the same way as mods downloaded from the portal.


=== 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 ====
 
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. The in-game mod portal automatically downloads required dependencies when downloading any mod.
 
==== 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.
 
==== Incompatibility ====
 
The dependencies can also be used to declare a mod to be incompatible with other mods, which prevents them from being loaded together.
 
=== Automatic mod sync for saves and multiplayer games ===
 
When trying to join a multiplayer game that uses mods, the game will offer to synchronize the mods with the server. Confirming the mod sync will automatically download and enable all mods used by the server. The mod startup settings can be synced as well. When syncing mods to a multiplayer server, the game will download the exact same mod versions as the server is using.
 
When loading a save file without the mods for that save, or with changed mod settings, the game will offer to synchronize the mods with the save file. Confirming the mod sync will automatically download and enable all mods used by the save file. The mod startup settings can be synced as well. When syncing with a save file, the game will use the latest mod versions by default.
 
It's possible to manually sync mods to a save file by navigating to it in the "Load game" menu and clicking the "Sync mods with save" button in the top right. By default, this enables the latest version of the mods. When using {{Keybinding|ctrl|lmb}} to click the "Sync mods with save" button, the game will use the exact same mod versions as the save file.
 
== Creating mods ==
: ''See also: [[Tutorial:Modding tutorial|Modding tutorial]]''
 
=== API documentation ===
 
* [https://lua-api.factorio.com/latest Modding API docs] - Overview page of the modding API documentation website
** [https://lua-api.factorio.com/latest/index-prototype.html Prototype documentation] — What prototypes can be added to the game, and what are their properties
** [https://lua-api.factorio.com/latest/index-runtime.html Documentation of the runtime API] — Hook into events and change the world around the player
* [[Tutorial:Mod structure|Mod structure]] — The basic structure of all mods
* [https://github.com/wube/factorio-data Factorio data GitHub repository] — Tracks changes of the Lua prototype definitions in Factorio between releases
* [[Data.raw]] — Lists the names and types of all built-in prototypes
 
=== Lua scripting ===


== Creation of mods ==
You need to use the Lua programming language (version 5.2.1) 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 Visual Studio Code.
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.


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.2/ 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 ===
=== Third-Party Tools ===
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>
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.
* control.Lua
* data.Lua
* data-updates.Lua
* data-final-fixes.Lua


=== Licensing ===
* [https://forums.factorio.com/viewforum.php?f=135 Factorio sub-forum for mod development tools]
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.


Other useful legal links include:
== See also ==
* [[:Category:Technical]] — Documentation of technical formats and API's not related to modding


* [http://www.factorioforums.com/forum/viewtopic.php?f=6&t=6202&p=48971#p48968 Forum post on allowed use of base-mod content]
{{C|Modding}}
* [http://www.factorio.com/terms-of-service Factorio terms of service]
 
 
== See also ==
* [[Modding/Overview|Modding overview]]
* [[Script interfaces]]
* [[Tutorial:Modding FAQ| Modding Frequently asked Questions]]
* [[Tutorial:Modding Tutorial|Tutorials for modding.]]
* [[Keyboard bindings]]
* [http://lua-api.factorio.com/latest/ Official Factorio Lua API documentation]
* [[Internal object names]]

Latest revision as of 16:45, 1 December 2024

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 (in-game)

The "Mods" section of the main menu is the best way to get mods. It combines downloading & installing, checking installed mods for updates, and enabling/disabling installed mods.

Mod portal (website)

The mod portal (website) is the center of mod hosting, where authors upload mods, and you can find previous versions, and discussions. Mods come as ZIP files, installed by copying (not unzipping) into the "mods" directory in the user data directory. Verify a successful installation by viewing the "Mods" list through the main menu, in-game.

Mod subforum

Mod authors maintain threads in the official mod subforum to support their work. There may be experimental mods or updates here that aren't available on the main portal. They will be downloaded as ZIP files, either as forum "attachments", or with a link to a hosting site. These are installed the same way as mods downloaded from the portal.

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. The in-game mod portal automatically downloads required dependencies when downloading any mod.

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.

Incompatibility

The dependencies can also be used to declare a mod to be incompatible with other mods, which prevents them from being loaded together.

Automatic mod sync for saves and multiplayer games

When trying to join a multiplayer game that uses mods, the game will offer to synchronize the mods with the server. Confirming the mod sync will automatically download and enable all mods used by the server. The mod startup settings can be synced as well. When syncing mods to a multiplayer server, the game will download the exact same mod versions as the server is using.

When loading a save file without the mods for that save, or with changed mod settings, the game will offer to synchronize the mods with the save file. Confirming the mod sync will automatically download and enable all mods used by the save file. The mod startup settings can be synced as well. When syncing with a save file, the game will use the latest mod versions by default.

It's possible to manually sync mods to a save file by navigating to it in the "Load game" menu and clicking the "Sync mods with save" button in the top right. By default, this enables the latest version of the mods. When using CTRL + Left mouse button to click the "Sync mods with save" button, the game will use the exact same mod versions as the save file.

Creating mods

See also: Modding tutorial

API documentation

Lua scripting

You need to use the Lua programming language (version 5.2.1) 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 Visual Studio Code.

Useful resources for Lua:

Third-Party Tools

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.

See also

  • Category:Technical — Documentation of technical formats and API's not related to modding