Disabling "Save" buttons inside the "Saves" dialog

Twine Version: 2.3.9
Story Format: Sugarcube 2.33.0

In my game, I want to disable saving, but not loading in certain passages. So far I found a working solution with config.saves.isAllowed. The problem is, this doesn’t disable the “Save” buttons inside the Save window, only alerts the player that saving is disallowed after they press them. I have a feeling this might get very frustrating for players of my game, where most passages don’t allow saving.

Is there a way to disable just the “Save” buttons in passages with certain tags? (or, even better for my game, in passages with none of several tags?)

Any help appreciated!

You can simply add a “checkpoint” tag to any passage where you want to allow saving, and then add this code to your JavaScript section:

$(document).on(':dialogopening', function (ev) {
	if (!$("body").hasClass("checkpoint")) {
		if ($(ev.target).find(".save").length) {
			$(ev.target).find(".save").ariaDisabled(true);
		}
	}
});

That will only allow saves in passages with a “checkpoint” tag by disabling the “Save” buttons in the “SAVES” dialog in any non-checkpoint passages.

For details on how that works, see the SugarCube :dialogopening event and <jQuery>.ariaDisabled() method, along with the jQuery .on(), .hasClass(), and .find() methods.

Enjoy! :grinning:

1 Like

This is exactly what I needed. Thanks a lot!