Skip to content

Commit 243b5ef

Browse files
committed
3.3.7 compatibility
Signed-off-by: Kajot-dev <kuba10j@gmail.com>
1 parent 26c1ea3 commit 243b5ef

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

dist/saveReady_macros_EN.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/saveReady_macros_EN.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ const privateSave = {
3939
}
4040
},
4141
getDirect: slot => {
42-
let data = State.serialise();
42+
let dataObj = State.serialise();
43+
let data = null;
44+
if (dataObj.hasOwnProperty("pastAndPresent")) data = dataObj.pastAndPresent;
4345
if (typeof data === "string") return "(Saved Game " + privateSave.storyUID + ") " + slot + "\n" + data;
4446
return null;
4547
},
@@ -185,7 +187,7 @@ const privateSave = {
185187
return;
186188
}
187189
if (!file || (file.size / 1024) > privateSave.maxFileSize) {
188-
privateSave.openDialog("File too large (or your browser couldn'y provide it)");
190+
privateSave.openDialog("File too large (or your browser couldn't provide it)");
189191
reject("none/too_large");
190192
return;
191193
}
@@ -249,7 +251,7 @@ const privateSave = {
249251
},
250252
fileDirect: (name, slot) => {
251253
let saveData = privateSave.getDirect(slot);
252-
if (typeof saveData === "null") {
254+
if (saveData === null) {
253255
privateSave.openDialog("I couldn't download save - probably Twine's error!");
254256
return null;
255257
}
@@ -297,47 +299,52 @@ console.info(privateSave.appPrefix[0] + "%c Save to file script is ready!", priv
297299
const Macros = require("macros");
298300
const TwineError = require("internaltypes/twineerror");
299301
const TwineNotifier = require("internaltypes/twinenotifier");
300-
Macros.add("readfromfile", function (section, ...args) {
302+
Macros.add("readfromfile", "Instant", function (section, ...args) {
301303
let t = "";
302-
console.log(section);
303304
if (args.length > 0) {
304305
let accepted = [];
305306
if (args.length > 1) accepted = args.slice(1, args.length);
306307
else accepted = [args[0]];
307308
privateSave.read(args[0], accepted, section);
308309
}
309-
if (Engine.options.debug) t += "(readfromfile:"+args.toString()+ ")";
310+
if (Utils.options.debug) t += "(readfromfile:"+args.toString()+ ")";
310311
return {
312+
TwineScript_TypeID: "instant",
311313
TwineScript_TypeName: "a (readfromfile:) operation",
312314
TwineScript_ObjectName: "a (readfromfile:) operation",
315+
TwineScript_Unstorable: true,
313316
TwineScript_Print: function () {
314317
return t && TwineNotifier.create(t).render()[0].outerHTML;
315318
}
316319
}
317320
}, [String, Macros.TypeSignature.zeroOrMore(String)]);
318-
Macros.add("savetofile", function (_, n, s) {
321+
Macros.add("savetofile", "Instant", function (_, n, s) {
319322
let t = "";
320323
n = n.trim();
321324
if (n === "" || s === "") return TwineError.create("macrocall", "This macro does not accept empty strings!");
322325
privateSave.file(n, s);
323-
if (Engine.options.debug) t += "(savetofile:"+n+", "+s+")";
326+
if (Utils.options.debug) t += "(savetofile:"+n+", "+s+")";
324327
return {
328+
TwineScript_TypeID: "instant",
325329
TwineScript_TypeName: "a (savetofile:) operation",
326330
TwineScript_ObjectName: "a (savetofile:) operation",
331+
TwineScript_Unstorable: true,
327332
TwineScript_Print: function () {
328333
return t && TwineNotifier.create(t).render()[0].outerHTML;
329334
}
330335
}
331336
}, [String, String]);
332-
Macros.add("savetofiledirect", function (_, n, s) {
337+
Macros.add("savetofiledirect", "Instant", function (_, n, s) {
333338
let t = "";
334339
n = n.trim();
335340
if (n === "" || s === "") return TwineError.create("macrocall", "This macro does not accept empty strings!");
336341
privateSave.fileDirect(n, s);
337-
if (Engine.options.debug) t += "(savetofiledirect:"+n+", "+s+")";
342+
if (Utils.options.debug) t += "(savetofiledirect:"+n+", "+s+")";
338343
return {
344+
TwineScript_TypeID: "instant",
339345
TwineScript_TypeName: "a (savetofiledirect:) operation",
340346
TwineScript_ObjectName: "a (savetofiledirect:) operation",
347+
TwineScript_Unstorable: true,
341348
TwineScript_Print: function () {
342349
return t && TwineNotifier.create(t).render()[0].outerHTML;
343350
}

0 commit comments

Comments
 (0)