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

Modding: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (unorphan data.raw)
(Dynamic merge Modding/Overview, and Mods into this page.)
Line 1: Line 1:
__TOC__
{{Languages}}
{{Languages}}
[[File:Fff-18-entity-graph.jpg|400px|thumb|'Diagram of entities' (objects on the map) class inheritance structure generated by doxygen. Taken From Friday Facts #18 http://www.factorio.com/blog/post/fff-18]]


==Resources==
[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 is a starting point, but you'll often want more depth.
* [[Modding FAQ]] page
* The [http://www.factorioforums.com/forum/viewforum.php?f=25 Modding Help board] has a great community and focuses on answering modding questions
* The [http://lua-api.factorio.com/ Official Lua API documentation] is a great reference for understanding the Factorio functions and types in the game.
* You can also find inspiration from any of the mod databases listed on the [[Mods|Mods page]].


==Licensing==
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]].
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.


See also
== Installing mods ==
* [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]
There are 2 ways to install mods in Factorio. Both of these methods are supported.
 
=== The mod portal ==
 
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]].
 
=== Manual downloading ===
 
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.
 
=== 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.
 
== Creation of mods ==
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:
* [http://lua-users.org/wiki/TutorialDirectory Lua tutorial]
* [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.
 
=== Format ===
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>
* control.Lua
* data.Lua
* data-updates.Lua
* data-final-fixes.Lua


==Creating a scenario from a saved game (map)==
=== Licensing ===
An often asked question is how to make a scenario (something which can be edited in the map editor) from a map:
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.
[http://www.factorioforums.com/forum/viewtopic.php?f=18&t=2844 Factorio can convert them] ([http://www.factorioforums.com/forum/viewtopic.php?f=5&t=3801&p=28289#p28289 see also this post]):
./bin/prod/factorio --map2scenario mapfoo


[[Console#Command_Line_Parameters|More about the client parameters]]
Other useful legal links include:


==Creating scenarios with the map editor==
* [http://www.factorioforums.com/forum/viewtopic.php?f=6&t=6202&p=48971#p48968 Forum post on allowed use of base-mod content]
Another first step is also making maps with the ingame editor. That stores the map as a '''scenario''', which is just a directory on disk with some files in it. You can look into those files to get a better understanding as to what they are for, or you can read the following pages:
* [http://www.factorio.com/terms-of-service Factorio terms of service]




== See also ==
== See also ==
* Tutorial: [http://www.factorioforums.com/forum/viewtopic.php?f=15&t=8613 Create graphics for your mod...], how to generate sprite maps
* [[Modding/Overview|Modding overview]]
* [[Modding/Overview|Modding overview]]
* [[Script interfaces]]
* [[Script interfaces]]
* [[Migration scripts]]
* [[Tutorial:Modding FAQ| Modding Frequently asked Questions]]
* [[Modding FAQ]]
* [[Tutorial:Modding Tutorial|Tutorials for modding.]]
* [[Modding Tutorial]]
* [[Keyboard bindings]]
* [[Keyboard bindings]]
* [http://lua-api.factorio.com/latest/ Official Factorio lua API documentation]
* [http://lua-api.factorio.com/latest/ Official Factorio Lua API documentation]
* [[Data.raw]]
* [[Internal object names]]

Revision as of 22:21, 17 June 2017


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 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 documents modding of Factorio in general, for a tutorial for making mods, see this wiki's tutorials, and for information on where mods are installed to, see Application directory.

Installing mods

There are 2 ways to install mods in Factorio. Both of these methods are supported.

= The mod portal

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 mods directory.

Manual downloading

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 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.

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.

Creation of mods

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:

Format

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.

  • info.json
  • control.Lua
  • data.Lua
  • data-updates.Lua
  • data-final-fixes.Lua

Licensing

All mods require a license since v0.11. If a mod has no license it is assumed to have a Creative Commons 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