-
Notifications
You must be signed in to change notification settings - Fork 50
Layout
Afforess edited this page Nov 24, 2016
·
7 revisions
The Factorio Standard Library is written to be directly included in Factorio mods.1.
- Download the latest release of the stdlib
- Unpack the archive, and copy the
stdlib/
directory into your base mod directory. - In your
control.lua
or other lua modules, you can import the stdlib classes you need.
- To import a stdlib module, use the lua
require
syntax. - All stdlib files are in the
stdlib/
directory, and then include the rest of the path to the file. - For example, to include the
Position
stdlib module, the file is instdlib/position/position.lua
, so the import would berequire 'stdlib/position/position
(note the lack of file extension)
- Stdlib modules need only be included once, but duplicate require statements will not cause issues.
-
stdlib/area
contains position, area, and other geometric utility modules -
stdlib/config
contains configuration utilities, useful for mods with complex configurations -
stdlib/data
contains factorio prototype tools, useful only in the data.law, data-updates.lua or data-updates-final.lau loading phase of Factorio -
stdlib/entity
contains entity and inventory tools. All objects in factorio (ores, assemblers, biters, and the player) are a type of entity. -
stdlib/event
contains the stdlib event manager and time events -
stdlib/gui
contains factorio gui tools and events for managing gui elements more easily -
stdlib/log
contains logging utilities -
stdlib/trains
contains train-specific APIs, as trains differ from standard factorio entities -
stdlib/
contains lua-specific utilities, outside the scope of just factorio. string, table, and other modules are located here.
-
spec/
contains all of thebusted
unit tests for the Factorio Stdlib. If you have busted installed, you can run the test suite usingmake test
or simply,busted
in the main project directory. -
examples/
contains examples on how to use some of the stdlib code -
doc/
contains ldoc specific configuration, used for the auto-generated documentation that appears on the github pages -
build/
is an autogenerated, git-ignored directory that documentation is generated in. It will only exist if you've runmake all
. -
circle.yml
describes how to auto-generate the github pages documentation using the circle-ci service.
[1] As of this writing (Factorio 0.14), there is no way for mods to share common sets of functions without reproducing the source code in their mod files.