You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (funcDef != null && funcDef.lookaheadSafe && state.inStringEvaluation()) {
509
+
// 16th Jan 2023: Example ink that was failing:
510
+
//
511
+
// A line above
512
+
// ~ temp text = "{theFunc()}"
513
+
// {text}
514
+
//
515
+
// === function theFunc()
516
+
// { external():
517
+
// Boom
518
+
// }
519
+
//
520
+
// EXTERNAL external()
521
+
//
522
+
// What was happening: The external() call would exit out early due to
523
+
// _stateSnapshotAtLastNewline having a value, leaving the evaluation stack
524
+
// without a return value on it. When the if-statement tried to pop a value,
525
+
// the evaluation stack would be empty, and there would be an exception.
526
+
//
527
+
// The snapshot rewinding code is only designed to work when outside of
528
+
// string generation code (there's a check for that in the snapshot rewinding code),
529
+
// hence these things are incompatible, you can't have unsafe functions that
530
+
// cause snapshot rewinding in the middle of string generation.
531
+
//
532
+
error("External function " + funcName
533
+
+ " could not be called because 1) it wasn't marked as lookaheadSafe when BindExternalFunction was called and 2) the story is in the middle of string generation, either because choice text is being generated, or because you have ink like \"hello {func()}\". You can work around this by generating the result of your function into a temporary variable before the string or choice gets generated: ~ temp x = "
534
+
+ funcName + "()");
535
+
return;
536
+
}
537
+
508
538
// Should this function break glue? Abort run if we've already seen a newline.
509
539
// Set a bool to tell it to restore the snapshot at the end of this instruction.
0 commit comments