Provides feature-management functionality to server & exposes info to clients+sandbox
Clone or download
James Cook James Cook
James Cook and James Cook Update readme
Latest commit 6666d1f Jul 30, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Add getFeature CLI Jul 30, 2017
.gitignore Initial commit Jul 19, 2017
LICENSE Initial commit Jul 19, 2017
README.md Update readme Jul 30, 2017
index.js Initial commit Jul 19, 2017
package.json Update readme Jul 30, 2017

README.md

screepsmod-features

Provides feature-management functionality to server and exposes info to clients+sandbox

NPM info

Installation

  1. npm install screepsmod-features in your server folder.
  2. Enjoy!

Usage

Other mods:
config.engine.on('init', function (processType) {
    if (config.features && processType === "main") {
        config.features.defineFeature(<feature name>, <feature source, e.g. mod name>, <feature version>); // features are enabled by default when defined
    }
});
...
config.features.getFeatureEnabled("my-feature").then((enabled) => {
    if (enabled) {
        // run code
    }
});
User code:
if (Game.features['my-feature'].enabled) {
    // run code
}
External tools/clients:
connection.get("api/features/list").then((features) => {
    if (features['my-features'].enabled) {
        // run code
    }
})
Server CLI:
setFeatureEnabled('my-feature', <boolean>);