mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 11:10:58 +02:00
API: Add getSaveData API (#1390)
This commit is contained in:
@@ -1169,6 +1169,17 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
||||
if (!Player.currentWork) return null;
|
||||
return Player.currentWork.APICopy();
|
||||
},
|
||||
getSaveData: (ctx) => async () => {
|
||||
helpers.checkSingularityAccess(ctx);
|
||||
const saveData = await saveObject.getSaveData();
|
||||
if (typeof saveData === "string") {
|
||||
// saveData is the base64-encoded json save string. A base64-encoded string only uses ASCII characters, so it's
|
||||
// fine to use new TextEncoder().encode() to encode it to a Uint8Array.
|
||||
return new TextEncoder().encode(saveData);
|
||||
}
|
||||
// saveData is the compressed json save string.
|
||||
return saveData;
|
||||
},
|
||||
exportGame: (ctx) => () => {
|
||||
helpers.checkSingularityAccess(ctx);
|
||||
onExport();
|
||||
|
||||
Reference in New Issue
Block a user