private void save() {
			// Clear old errors emitted by compilation.
			problemTracking.removeByPhase(ProblemPhase.BUILD);

			// Invoke compiler with data.
			engine.compile(editor.getText()).whenCompleteAsync((result, throwable) -> {
				if (result != null && result.wasSuccess()) {
					// Don't care about compilation, just wanted to validate it was valid semantics.
					Animations.animateSuccess(this, 1000);
				} else {
					// Handle compile-result failure, or uncaught thrown exception.
					if (result != null) {
						for (CompilerDiagnostic diagnostic : result.diagnostics())
							problemTracking.add(Problem.fromDiagnostic(diagnostic));
					} else {
						logger.error("Compilation encountered an error", throwable);
					}
					Animations.animateFailure(this, 1000);
				}

				// Write to disk regardless, if path is given. If not given, prompt user for it.
				if (scriptPath == null) {
					FileChooser chooser = new FileChooserBuilder()
							.setInitialDirectory(directories.getScriptsDirectory())
							.setTitle(Lang.get("dialog.file.save"))
							.build();

					File selected = chooser.showSaveDialog(getScene().getWindow());
					if (selected != null)
						scriptPath = selected.toPath();
				}
				if (scriptPath != null) {
					try {
						Files.writeString(scriptPath, editor.getText());
					} catch (IOException ex) {
						logger.error("Failed to write to script file", ex);
					}
				}

				// Redraw paragraph graphics to update things like in-line problem graphics.
				editor.redrawParagraphGraphics();
			}, FxThreadUtil.executor());
		}
Save the script to {@link #scriptPath}.
recaf-ui/src/main/java/software/coley/recaf/ui/pane/ScriptManagerPane.java