mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-17 12:11:51 +00:00
Allow external URL to load more than one mod
Instead of loading the text returned from the remote server, load a JSON object with a `mods` field, containing strings of all the mods. This lets us work on more than one mod at a time or without separate repos. This will break tooling such as `create-shapezio-mod` though.
This commit is contained in:
parent
9311ffe4e3
commit
0141df1abf
@ -117,7 +117,23 @@ export class ModLoader {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
mods.push(await response.text());
|
let json;
|
||||||
|
try {
|
||||||
|
json = await response.json();
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(
|
||||||
|
"Failed to parse JSON object from " +
|
||||||
|
globalConfig.debug.externalModUrl +
|
||||||
|
": " +
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(json.mods === undefined) {
|
||||||
|
throw new Error("Failed to load " + globalConfig.debug.externalModUrl + ": No 'mods' field in json object");
|
||||||
|
}
|
||||||
|
|
||||||
|
mods = mods.concat(json.mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.$shapez_registerMod = (modClass, meta) => {
|
window.$shapez_registerMod = (modClass, meta) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user