Mod config
This commit is contained in:
@@ -247,6 +247,15 @@ function load_mod(mods_dir: string, id: string): LoadedMod {
|
||||
}
|
||||
}
|
||||
|
||||
if (exists(`${dir}/config.json`)) {
|
||||
const config = read_json(`${dir}/config.json`, (m) => error(`config.json: ${m}`));
|
||||
if (!is_object(config) || config.format_version !== FORMAT_VERSION || !is_object(config.config)) {
|
||||
error(`config.json: must be { "format_version": ${FORMAT_VERSION}, "config": { ... } }`);
|
||||
} else {
|
||||
mod.config = config.config;
|
||||
}
|
||||
}
|
||||
|
||||
// a mod only registers ids in its own namespace
|
||||
for (const { file, json } of [...mod.blocks, ...mod.models, ...mod.items, ...mod.entities]) {
|
||||
if (json.id.split(":")[0] !== id) error(`${file}: ${json.id} isn't in this mod's namespace "${id}"`);
|
||||
|
||||
Reference in New Issue
Block a user