0.4.5-alpha • Published 8 years ago

node-factorio-api v0.4.5-alpha

Weekly downloads
63
License
ISC
Repository
gitlab
Last release
8 years ago

node-factorio-api


Download and update mods from the Factorio Mod Portal


https://nodei.co/npm/node-factorio-api.png?downloads=true&downloadRank=true&stars=true

Dependency Status

Table of Contents

Features

  • Download mods
  • Update mods
  • Search/list mods
  • Remove mods
  • Download dependencies
  • Get mods from saves (not implemented yet)
  • Get mods from server (not implemented yet)
  • Search/list servers (not implemented yet)
  • Read mod zip file (get info.json)
  • Download the game client (removed, since it was to much of a hack)

Installation

I recommend using yarn instead of npm, because it's (a lot) faster.

yarn add node-factorio-api (or npm install node-factorio-api)

Usage

// There are multiple classes now
import {Profile, FactorioAPI, Progress, Mod} from "./node-factorio-api";

// You can now (finally) get the progress. Just subscribe and it will trigger the callback every time something changes. 
// It gives you an array of tasks that are currently running.
Progress.subscribe(tasks => {
    tasks.map(task => console.log(`${task.name}: ${task.progress}`));
    console.log("\n");
});

// I present to you: The Anonymous Asynchronous Self-Invoking Arrow Function (cuz that's a thing now)
(async () => {
    // You can now create profiles! The path to the main folder of factorio is all it needs.
    let profile = new Profile("/home/daan/Games/factorio/");

    // It can even find your credentials automatically
    await profile.authenticate();

    // Tell the FactorioAPI to use this profile
    FactorioAPI.useProfile(profile);
    // Let it query the mods and wait for it to complete
    await FactorioAPI.queryMods();

    // Some mods...
    let mods = FactorioAPI.getMods([
        "boblogistics",
        "rso-mod",
        "clusterio"
    ]);

    // Let's download them
    await FactorioAPI.downloadLatestReleases(mods);

    // This is kind of silly here, but oh well
    await FactorioAPI.checkUpdates(mods);

    // Let's see what we got installed
    let installedReleases = await profile.getInstalledReleases();

    // Let's make sure are mods can load properly, that wouldn't be a bad idea right?
    for (let rel of installedReleases) {
        await FactorioAPI.downloadDependencies(rel, false);
    }

    // Let's see what's enabled
    await profile.loadModlist();

    // Maybe just enable all of them
    profile.installedReleases.forEach(rel => {
        rel.enabled = true
    });

    // Don't forget to save!
    await profile.saveModlist();

    // Not working currently (it broke yet again, I don't think that would surprise anyone here)
    let saveReleases = await FactorioAPI.getModsFromSaveFile("test.zip");
    await FactorioAPI.downloadReleases(saveReleases);
})();

Documentation Outdated! Coming soon...

Documentation

Useful information

0.3.8

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.4.7-alpha

8 years ago

0.4.6-alpha

8 years ago

0.4.5-alpha

8 years ago

0.4.4-alpha

8 years ago

0.4.3-alpha

8 years ago

0.4.2-alpha

8 years ago

0.4.1-alpha

8 years ago

0.3.3-alpha

8 years ago

0.4.0-alpha

8 years ago

0.3.2-alpha

8 years ago

0.3.1-alpha

8 years ago

0.3.0-alpha

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0-beta

8 years ago

0.1.28

8 years ago

0.1.27

9 years ago

0.1.26

9 years ago

0.1.25

9 years ago

0.1.24

9 years ago

0.1.23

9 years ago

0.1.22

9 years ago

0.1.21

9 years ago

0.1.20

9 years ago

0.1.19

9 years ago

0.1.18

9 years ago

0.1.17

9 years ago

0.1.16

9 years ago

0.1.15

9 years ago

0.1.14

9 years ago

0.1.13

9 years ago

0.1.12

9 years ago

0.1.11

9 years ago

0.1.10

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago