mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-16 11:41:50 +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
@ -116,8 +116,24 @@ export class ModLoader {
|
||||
response.statusText
|
||||
);
|
||||
}
|
||||
|
||||
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.push(await response.text());
|
||||
mods = mods.concat(json.mods);
|
||||
}
|
||||
|
||||
window.$shapez_registerMod = (modClass, meta) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user