Open asasine opened 2 years ago
The factorio binary includes a mods-list.json file that lists out the mods that should be included in the game. This file can be read when the daemon launches in order to download the correct version of the mods.
There's a mod portal API for listing mods and downloading them https://wiki.factorio.com/Mod_portal_API
Downloading mods requires authentication, either by using the authentication API or by copying the player's token from player-data.json
Auth tokens can be retrieved from https://factorio.com/profile without going through player-data.json.
Mods can have dependencies, as documented here. To get dependencies, factoriod should either use the /full
API for a mod, or read the info.json file in the mod's zip. Mods with unmet dependencies are silently ignored when launching factorio.
The in-game mod downloader seems to always download the latest of a dependency, regardless of the required version. The dependency is also listed in mod-list.json, even though it isn't directly requested.
mod-list.json entries may optionally contain a version for a mod, in which case that specific version is used. If no version is used, the latest currently-downloaded version is used (natural sort order), and the latest version is downloaded if it isn't local.
I'm thinking I'll need to create a tree of requested mods and their dependencies, identifying any incompatibilities from mods with the !
(incompatibility) constraint, mods with non-overlapping version constraints, and mods with "base"
mod constraints incompatible with the current game version. A valid tree can be walked to get a list of mods for mod-list.json and to download. Versions are optional, defaulting to the latest. Once a mod's dependencies are downloaded, they're considered "requested" mods too. This can happen during game startup such that the REST API to manipulate the mod list is fast and mods are always up-to-date.
Turns out, a proper package dependency system with "correct" versioning semantics is NP-hard.
Mods should be downloaded and updated automatically