Skip to content

Expose quicksave functionality to the lua API

At #6367 (comment 714035792) and elsewhere in that issue it was suggested that timed autosaves would be a good candidate for a lua mod. I decided to write that mod... and found that save functionality wasn't exposed in the lua API. This MR exposes a quicksave() function, with an optional name parameter so that it functions similar to the C++ namesake that it calls.

Because it uses the existing C++ quicksave function, it will use the same global settings for rotating through N saves of the same name that quick saves and auto saves do.

I suspect there's a cleaner way to map a lua function with optional parameter to an overloaded C++ function, but it wasn't apparent to me when looking at the docs and examples for sol.

This new function cannot be tested directly from the lua console because saving is blocked with the console open. I've been testing with a mod that boils down to something like require( 'openmw_aux.time' ).runRepeatedly( function () require( 'openmw.world' ).quicksave( 'Timedsave' ) end, 5 ), which I'll publish when this feature is merged.

Edited by Clarence "Sparr" Risher

Merge request reports

Loading