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

Function savePrefab

src/world/saver.ts:40–54  ·  view source on GitHub ↗
(path: string, prefab: PrefabData)

Source from the content-addressed store, hash-verified

38
39// Write a prefab file. Same semantics as `saveWorld` but for prefabs.
40export function savePrefab(path: string, prefab: PrefabData): SaveResult {
41 prefab.schemaVersion = WORLD_SCHEMA_VERSION;
42
43 const check = validatePrefab(prefab);
44 if (!check.ok) {
45 return { ok: false, errors: check.errors };
46 }
47
48 const json = JSON.stringify(prefab, null, 2);
49 const ok = writeFile(path, json);
50 if (!ok) {
51 return { ok: false, errors: ['writeFile failed for path: ' + path] };
52 }
53 return { ok: true, errors: [] };
54}
55
56// Convenience: format a SaveResult's errors as a single human-readable string.
57// The editor uses this for status bar / dialog messages.

Callers

nothing calls this directly

Calls 2

validatePrefabFunction · 0.90
writeFileFunction · 0.90

Tested by

no test coverage detected