-
Notifications
You must be signed in to change notification settings - Fork 5
Settings migrator script
DmitryS edited this page Aug 5, 2021
·
9 revisions
"use strict";
const DefaultSettings = {
"enabled": true,
"stream": false,
"lNotice": false,
"gNotice": false,
"spawnObject": true,
"speech": {
"enabled": true,
"rate": 2,
"volume": 100,
"gender": "female"
},
"cc": [
"</font><font color=\"#ffff00\">"
],
"language": "auto",
"dungeons": {},
"debug": {
"chat": true,
"all": false,
"s": false,
"e": false,
"am": false,
"ae": false,
"ab": false,
"ar": false,
"ad": false,
"h": false,
"ns": false,
"nd": false,
"rb": false,
"re": false,
"dm": false,
"qb": false
}
};
module.exports = function MigrateSettings(from_ver, to_ver, settings) {
if (from_ver === undefined) return Object.assign(Object.assign({}, DefaultSettings), settings);
else if (from_ver === null) return DefaultSettings;
else {
from_ver = Number(from_ver);
to_ver = Number(to_ver);
if (from_ver + 0.01 < to_ver) {
settings = MigrateSettings(from_ver, from_ver + 0.01, settings);
return MigrateSettings(from_ver + 0.01, to_ver, settings);
}
const oldsettings = settings;
settings = Object.assign(DefaultSettings, {});
to_ver = Math.round(to_ver * 100) / 100;
switch (to_ver) {
// your migration routines here
default:
for (const option in oldsettings) {
if (settings[option] !== undefined) settings[option] = oldsettings[option];
}
}
return settings;
}
};
Version: 2.04