Provides feature-management functionality to server and exposes info to clients+sandbox
npm install screepsmod-features
in your server folder.- Enjoy!
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
}
});
if (Game.features['my-feature'].enabled) {
// run code
}
connection.get("api/features/list").then((features) => {
if (features['my-features'].enabled) {
// run code
}
})
setFeatureEnabled('my-feature', <boolean>);