MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / saveWorld

Function saveWorld

src/world/saver.ts:21–37  ·  view source on GitHub ↗
(path: string, world: WorldData)

Source from the content-addressed store, hash-verified

19// On validation failure, returns the errors without touching the filesystem.
20// On write failure (disk full, permissions), returns `{ ok: false, errors: [...] }`.
21export function saveWorld(path: string, world: WorldData): SaveResult {
22 // Always stamp the current schema version on save so stale copies don't
23 // drift across editor sessions.
24 world.schemaVersion = WORLD_SCHEMA_VERSION;
25
26 const check = validateWorld(world);
27 if (!check.ok) {
28 return { ok: false, errors: check.errors };
29 }
30
31 const json = JSON.stringify(world, null, 2);
32 const ok = writeFile(path, json);
33 if (!ok) {
34 return { ok: false, errors: ['writeFile failed for path: ' + path] };
35 }
36 return { ok: true, errors: [] };
37}
38
39// Write a prefab file. Same semantics as `saveWorld` but for prefabs.
40export function savePrefab(path: string, prefab: PrefabData): SaveResult {

Callers

nothing calls this directly

Calls 2

validateWorldFunction · 0.90
writeFileFunction · 0.90

Tested by

no test coverage detected