Awesome menu and saves
This commit is contained in:
+13
-6
@@ -27,19 +27,18 @@ export class ModsError extends Error {
|
||||
}
|
||||
|
||||
// engine_textures are the cubi: texture ids, for checking the textures mods use. config_dir has the server's
|
||||
// <mod id>.json files that change mods' config. a mod with problems stops the whole server from starting, the game
|
||||
// never runs with some mods missing
|
||||
// <mod id>.json files that change mods' config. only, when given, is which of dir's files to load, like a
|
||||
// singleplayer world's mods. a mod with problems stops the whole server from starting, the game never runs with some
|
||||
// mods missing
|
||||
export async function load_mods(
|
||||
dir: string,
|
||||
engine_textures: Iterable<string>,
|
||||
config_dir?: string,
|
||||
only?: string[],
|
||||
): Promise<ServerMod[]> {
|
||||
let files: string[];
|
||||
try {
|
||||
files = [...Deno.readDirSync(dir)]
|
||||
.filter((entry) => entry.isFile && entry.name.endsWith(MOD_EXTENSION))
|
||||
.map((entry) => entry.name)
|
||||
.sort();
|
||||
files = only ?? mod_files(dir);
|
||||
} catch (e) {
|
||||
if (e instanceof Deno.errors.NotFound) return [];
|
||||
throw e;
|
||||
@@ -104,6 +103,14 @@ export async function load_mods(
|
||||
}));
|
||||
}
|
||||
|
||||
// the .cubi files in a folder, by name
|
||||
export function mod_files(dir: string): string[] {
|
||||
return [...Deno.readDirSync(dir)]
|
||||
.filter((entry) => entry.isFile && entry.name.endsWith(MOD_EXTENSION))
|
||||
.map((entry) => entry.name)
|
||||
.sort();
|
||||
}
|
||||
|
||||
// runs the content phase of the mods' scripts in a worker without permissions and adds the blocks they register to
|
||||
// their data, after their files' ones. from then on they're the mod's data like the rest: checked, in the copy players
|
||||
// download, and in the worldgen bundle
|
||||
|
||||
Reference in New Issue
Block a user