Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.


Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Adding an infinite number of quicksaves with naming pattern?

GrimLefourbeGrimLefourbe Member Posts: 637
Is it possible?
Has someone tried? I like to have many many saves but i'm way too lazy to go make a save through the menu every time.

I'm thinking it could be done by adding a function that makes a save with a given naming pattern and then map it to q. Can I map custom functions to hotkeys?

I'm not bringing much sorry, I don't have a lot of time to spend on that and I'd rather not do something that's already been done.



  • Mr2150Mr2150 Member Posts: 1,170
    edited September 2016
    Yeah - I think it is possible in a roundabout kind of way and you might want to give it a different hotkey.

    You'd need to do something like this:

    Decide the format for your AutoSaved filenames - let's say it is 'Auto Save - X' where X is the number of the file (increasing from 0 to infinity).
    Create an invisible button (area -1 -1 -1 -1) on the game screen (presumably the leftsidebar menu for consistency).
    Give it the hotkey you want (on P, for example)
    Have it trigger a function
    Write the function so that it cycles through all 'Auto Save - X' files and checks the value of X each time. Once it's found the highest X, remember it.
    Save the game with new filename 'Auto Save - X+1'

    Potential issue - if the game has to cycle through lots of files it could cause it to slowdown/stop when it is running the cycle process.

    I'm pretty sure this approach would work as I have some working code that's similar - it automatically saves when you hit the rest key. It checks to see if you have 'AutoSaveRest'-ed previously, deletes that file if you have, and then saves the game with the name 'AutoSave before Rest' (to ensure you only have one file called AutoSave before Rest).

  • GrimLefourbeGrimLefourbe Member Posts: 637
    If I don't want to number them but instead use say a timestamp and the area, how'd I go about it?

  • Mr2150Mr2150 Member Posts: 1,170
    The UI doesn't know the area name so you couldn't use that - but you could timestamp them... And since they are identified by timestamp now you don't need the cycle process.

    Something like this:

    Decide the format for your AutoSaved filenames - let's say it is 'AutoSave - X' where X is the timestamp.
    Create an invisible button (area -1 -1 -1 -1) on the game screen (presumably the leftsidebar menu for consistency).
    Give it the hotkey you want (on P, for example)... so something like this:

    button { area -1 -1 -1 -1 on P action " CustomAutoSave() " }

    Write the function so it is something like this:

    function CustomAutoSave() e:GetActiveEngine():OnLeftPanelButtonClick(7) optionsScreen:SaveGame(0) Infinity_PushMenu('SAVE_NEWSAVE'); newSaveName = "AutoSave - " .. gameSaves.currentGameInfo.chapter .. ' - ' .. gameSaves.currentGameInfo.time completeSave() end

    And testing that worked... :)

    However, it revealed a bug with 'currentGameInfo.time'

    The game saves with that variable.... however the load screen uses a different variable for the timestamp - eg you may save with 'Chapter 2, Day 3 Hour 7' but the save file has timestamp 'Chapter 2, Day 17 Hour 10'. You can test this by saving the game and checking the timestamp. Then trying to load that game immediately and seeing that the timestamp is listed differently, pic:

    (I think it may be saving the game with the time since the current chapter started, but the savefile has total play time)

    I'll report it on Redmine.

  • GrimLefourbeGrimLefourbe Member Posts: 637
    @Mr2150 Small update, it crashes the game to use the shortcut when save is impossible(e.g when an entangle or cloud spell is still running), any idea on which trigger should be used to prevent that ?

  • Mr2150Mr2150 Member Posts: 1,170
    edited September 2016
    Try changing the action of the button so it becomes:

    button { area -1 -1 -1 -1 on P action " if sidebarsGreyed ~= 1 then CustomAutoSave() end " }

    Then it will check for the same conditions that would let you quicksave - and this shortcut would only work at the same time that does.

    The function/action are forcing a save in a specific format through the normal save function of the game. The challenge is that the UI doesn't 'know' if the standard save function should be accessible or not, and I can't think of a way to test for it in the UI.... If that doesn't work, I will keep checking.

    Post edited by Mr2150 on
  • GrimLefourbeGrimLefourbe Member Posts: 637
    edited September 2016
    It doesn't work, clicking on the quicksave button nets an error message in the dialog window. I looked at other possibilities, there seems to be a "canClickSaveLoad()" function that can be used as a condition but i've been unable to get any good result.

  • Mr2150Mr2150 Member Posts: 1,170
    Perfect - you found it just before I did...

    Try this:

    button { area -1 -1 -1 -1 on P action " if canClickSaveLoad() then CustomAutoSave() end " }

  • GrimLefourbeGrimLefourbe Member Posts: 637
    It doesn't work either, might be out of luck then. From the save related functions i've looked at, this seems to be managed by the engine. Clicking on "Save Game" from the options menu makes a popup but the code for the save game button doesn't include spawning this popup.

  • Mr2150Mr2150 Member Posts: 1,170
    Yeah, it may be an engine thing... this code is just automating the save process clicks that you would make if you did it manually... I'm not sure how to force it to do the same checks - Ill keep looking at it :)

  • GrimLefourbeGrimLefourbe Member Posts: 637
    Not directly related but I only realized thanks to this.

    It seems like the saving process is made heavily longer by the number of saves in the saves folder. I had like 350 saves and loading/saving was taking between 5 and 10 seconds, I cleared my folder and it's much faster now.

    Must be a bad optimisation in the engine right? It shouldn't have much impact on loading/saving time.

Sign In or Register to comment.