tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
177 stars 41 forks source link

Add metadata to Config.saves.onSave function call #64

Closed tmedwards closed 4 years ago

tmedwards commented 4 years ago

SEE: https://intfiction.org/t/modifying-custom-save-title-code/46445


It would be useful to have metadata about the save—at the very least its type; e.g., 'autosave', 'slot', 'disk'—during the Config.saves.onSave function call.

Perhaps something like a extra parameter to the call. For example (modified example from the original post):

Config.saves.onSave = function (save, type) {
    switch (type) {
    case 'autosave':
        save.title = 'autosave';
        break;
    case 'disk':
        save.title = prompt('Name this save or use default:', save.title);
        break;
    default:
        save.title = 'Chapter ' + State.variables.chapter + ' bookmark';
        break;
    }
};

Something to that effect would be useful. Unsure at present whether there's other information, beyond the type, that could use useful to include there.