This is a set of scripts that can take the raw data export from Factorio, as found on the Factorio Wiki, and produce a set of Python libraries that can be used for further scripting.
make
awk
lua
python3
pip3
virtualenv
(on my system this was a system package calledpython3.10-venv
)
Then you can:
$ virtualenv -p python3 venv
$ source venv/bin/activate
(venv) $ pip3 install -r requirements.txt .
If you want to start all the way from the beginning, download the raw
data export from the link at the top of this file, and call this data.raw
.
Then, run make
. This will:
-
Convert
data.raw
intodata.lua
, a Lua script that can export the raw data as JSON. There are various cleanup activities that must be done to accomplish this successfully, most of which are inutil.lua
, including:- Substituting
inf
or-inf
into numbers that are valid JSON. - Turning sparse arrays into dictionaries/tables keyed by the string representations of the original integer array indices.
- Converting mixed tables (i.e. ones that have keys that suggest they can be treated as Lua arrays as well as keys (usually strings) for other properties.
- Substituting
-
Run
data.lua
to outputdata.json
. -
Run
generate.py
ondata.json
to create the hardcoded instances/constants of various Python classes as the__init__.py
for the Python module we'll package. -
Run
python3 -m build
to produce the distributable Python packages.