EDIT: If you just want the script, see the following post (once it's approved).
Save it as a .cmd or .bat file -- in Notepad, File > Save As > File type: All, then use a .cmd or .bat at the end, if you leave it as File type: Text File, you will get a .bat.txt or .cmd.txt -- alternatively, stop Windows from hiding popular file type extensions by opening "File Explorer Options", or "Folder Options" (Win + E, then Alt+V, then choose Options), and then going to View > uncheck "hide extensions for known file types" box.
Right. I think you need to quit FTL after losing, then it will allow you to restore and re-launch. I'm saying this because of the
line that we see in the code. start /wait means "call this program and do not continue until it has quit". (See
here for further info on the start command).
That link you posted leads to this code, which you can save as a .bat or .cmd file to run, which you did.
~~See the version at the bottom of this post if you don't want the script to auto-launch FTL after every load / save (and instead only launch FTL when you choose to from the menu).~~
Code: Select all
:init
@echo off
set saveFolder=%userprofile%\Documents\My Games\FasterThanLight
set saveFile=continue.sav
set backupFile=continue.bak
set saved=1
set loaded=1
:choixLauncher
cls
@echo Menu FTL
set choice=
set /p choice=(S)ave/(L)oad/(F)TL/(Q)uit:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==s goto fctSave
if %choice%==S goto fctSave
if %choice%==l goto fctLoad
if %choice%==L goto fctLoad
if %choice%==f goto launchGame
if %choice%==F goto launchGame
if %choice%==q goto :eof
if %choice%==Q goto :eof
goto choixLauncher
:fctSave
cls
if exist "%saveFolder%\%saveFile%" (
if exist "%saveFolder%\%backupFile%" (
call :choixSave
) else (
echo Creation nouveau backup..
call :save
)
) else (
echo Pas de fichier a sauvegarder...
)
goto launchGame
:fctLoad
cls
if exist "%saveFolder%\%backupFile%" (
if exist "%saveFolder%\%saveFile%" (
call :choixLoad
) else (
echo Restauration du backup..
call :load
)
) else (
echo Pas de fichier a restaurer...
)
goto launchGame
:launchGame
@echo Lancement de FTL
start /wait FTLGame.exe
goto choixLauncher
:choixSave
@echo Ecraser l'ancien backup ?
set choice=
set /p choice=(Y)es/(N)o:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==y goto save
if %choice%==Y goto save
if %choice%==n goto launchGame
if %choice%==N goto launchGame
goto choixSave
:save
copy "%saveFolder%\%saveFile%" "%saveFolder%\%backupFile%"
set saved=%errorlevel%
goto :eof
:choixLoad
@echo Ecraser la sauvegarde actuelle ?
set choice=
set /p choice=(Y)es/(N)o:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==y goto load
if %choice%==Y goto load
if %choice%==n goto launchGame
if %choice%==N goto launchGame
goto choixLoad
:load
copy "%saveFolder%\%backupFile%" "%saveFolder%\%saveFile%"
set loaded=%errorlevel%
goto :eof
Which I translated from French to English:
Code: Select all
:init
@echo off
set saveFolder=%userprofile%\Documents\My Games\FasterThanLight
set saveFile=continue.sav
set backupFile=continue.bak
set saved=1
set loaded=1
:choiceLauncher
cls
@echo FTL Menu
set choice=
set /p choice=(S)ave/(L)oad/(F)TL/(Q)uit:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==s goto fctSave
if %choice%==S goto fctSave
if %choice%==l goto fctLoad
if %choice%==L goto fctLoad
if %choice%==f goto launchGame
if %choice%==F goto launchGame
if %choice%==q goto :eof
if %choice%==Q goto :eof
goto choiceLauncher
:fctSave
cls
if exist "%saveFolder%\%saveFile%" (
if exist "%saveFolder%\%backupFile%" (
call :choiceSave
) else (
echo Creating new backup..
call :save
)
) else (
echo No Saved Game...
)
goto launchGame
:fctLoad
cls
if exist "%saveFolder%\%backupFile%" (
if exist "%saveFolder%\%saveFile%" (
call :choiceLoad
) else (
echo Restoring backup..
call :load
)
) else (
echo No file restored...
)
goto launchGame
:launchGame
@echo Launching FTL
start /wait FTLGame.exe
goto choiceLauncher
:choiceSave
@echo Erase old backup ?
set choice=
set /p choice=(Y)es/(N)o:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==y goto save
if %choice%==Y goto save
if %choice%==n goto launchGame
if %choice%==N goto launchGame
goto choiceSave
:save
copy "%saveFolder%\%saveFile%" "%saveFolder%\%backupFile%"
set saved=%errorlevel%
goto :eof
:choiceLoad
@echo Overwrite the current saved game ?
set choice=
set /p choice=(Y)es/(N)o:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==y goto load
if %choice%==Y goto load
if %choice%==n goto launchGame
if %choice%==N goto launchGame
goto choiceLoad
:load
copy "%saveFolder%\%backupFile%" "%saveFolder%\%saveFile%"
set loaded=%errorlevel%
goto :eof
List of commands used in this command line script:
echo (displays text, note that the '@' symbol is used to prevent a line that is being processed from sending, so '@echo sometext' will not be seen twice -- once by the script telling cmd to tell you 'sometext', and once by it actually telling you 'sometext')
set (sets a variable)
cls (clears the screen)
if (performs conditional processing aka 'if this, then do that')
goto (goes to a section in the batch file. Sections are labeled with the ':' sign, like
is the "load" section)
call (calls one batch program from within another; in this batch file, it is used to call a section of the current batch file as if it is another batch file, 'hey go execute this section, when you are done, we resume from where we are' instead of goto, which would leave the current section and move the focus to wherever the following argument specified)
start was already mentioned (starts a program)
copy (copies a file)
Notes: anything enclosed in %, like
is a variable, which can be set by the set command before. Your system comes with some environment variables built in, this is how the script can find your %userprofile%. To see what they are, open a cmd prompt and just put
and enter, it will show you what variables are set system-wide.
Also, any of the links above lead to specific sections of the MS
Command-line reference A-Z, which is very handy and has a lot more commands in it, in case anyone is interested.
EDIT: made a small update to the English version of the script (it now asks if you wish to overwrite the current saved game instead of incorrectly asking if you want to overwrite the current backup when restoring a saved game from backup will overwrite a current saved game).
EDIT2:
Made a small modification to the script -- this is for if you wish the script to only launch FTL when you tell it to from the menu, and not also after every load or save. EDIT3: Forgot to remove launch game command when user chooses not to over-write a saved game or backup.
French:
Code: Select all
:init
@echo off
set saveFolder=%userprofile%\Documents\My Games\FasterThanLight
set saveFile=continue.sav
set backupFile=continue.bak
set saved=1
set loaded=1
:choixLauncher
cls
@echo Menu FTL
set choice=
set /p choice=(S)ave/(L)oad/(F)TL/(Q)uit:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==s goto fctSave
if %choice%==S goto fctSave
if %choice%==l goto fctLoad
if %choice%==L goto fctLoad
if %choice%==f goto launchGame
if %choice%==F goto launchGame
if %choice%==q goto :eof
if %choice%==Q goto :eof
goto choixLauncher
:fctSave
cls
if exist "%saveFolder%\%saveFile%" (
if exist "%saveFolder%\%backupFile%" (
call :choixSave
) else (
echo Creation nouveau backup..
call :save
)
) else (
echo Pas de fichier a sauvegarder...
)
goto choixLauncher
:fctLoad
cls
if exist "%saveFolder%\%backupFile%" (
if exist "%saveFolder%\%saveFile%" (
call :choixLoad
) else (
echo Restauration du backup..
call :load
)
) else (
echo Pas de fichier a restaurer...
)
goto choixLauncher
:launchGame
@echo Lancement de FTL
start /wait FTLGame.exe
goto choixLauncher
:choixSave
@echo Ecraser l'ancien backup ?
set choice=
set /p choice=(Y)es/(N)o:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==y goto save
if %choice%==Y goto save
if %choice%==n goto choixLauncher
if %choice%==N goto choixLauncher
goto choixSave
:save
copy "%saveFolder%\%saveFile%" "%saveFolder%\%backupFile%"
set saved=%errorlevel%
goto :eof
:choixLoad
@echo Ecraser la sauvegarde actuelle ?
set choice=
set /p choice=(Y)es/(N)o:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==y goto load
if %choice%==Y goto load
if %choice%==n goto choixLauncher
if %choice%==N goto choixLauncher
goto choixLoad
:load
copy "%saveFolder%\%backupFile%" "%saveFolder%\%saveFile%"
set loaded=%errorlevel%
goto :eof
English:
Code: Select all
:init
@echo off
set saveFolder=%userprofile%\Documents\My Games\FasterThanLight
set saveFile=continue.sav
set backupFile=continue.bak
set saved=1
set loaded=1
:choiceLauncher
cls
@echo FTL Menu
set choice=
set /p choice=(S)ave/(L)oad/(F)TL/(Q)uit:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==s goto fctSave
if %choice%==S goto fctSave
if %choice%==l goto fctLoad
if %choice%==L goto fctLoad
if %choice%==f goto launchGame
if %choice%==F goto launchGame
if %choice%==q goto :eof
if %choice%==Q goto :eof
goto choiceLauncher
:fctSave
cls
if exist "%saveFolder%\%saveFile%" (
if exist "%saveFolder%\%backupFile%" (
call :choiceSave
) else (
echo Creating new backup..
call :save
)
) else (
echo No Saved Game...
)
goto choiceLauncher
:fctLoad
cls
if exist "%saveFolder%\%backupFile%" (
if exist "%saveFolder%\%saveFile%" (
call :choiceLoad
) else (
echo Restoring backup..
call :load
)
) else (
echo No file restored...
)
goto choiceLauncher
:launchGame
@echo Launching FTL
start /wait FTLGame.exe
goto choiceLauncher
:choiceSave
@echo Erase old backup ?
set choice=
set /p choice=(Y)es/(N)o:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==y goto save
if %choice%==Y goto save
if %choice%==n goto choiceLauncher
if %choice%==N goto choiceLauncher
goto choiceSave
:save
copy "%saveFolder%\%saveFile%" "%saveFolder%\%backupFile%"
set saved=%errorlevel%
goto :eof
:choiceLoad
@echo Overwrite the current saved game ?
set choice=
set /p choice=(Y)es/(N)o:
if not %choice%=='' set choice=%choice:~0,1%
if %choice%==y goto load
if %choice%==Y goto load
if %choice%==n goto choiceLauncher
if %choice%==N goto choiceLauncher
goto choiceLoad
:load
copy "%saveFolder%\%backupFile%" "%saveFolder%\%saveFile%"
set loaded=%errorlevel%
goto :eof