 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Autem Expert Cheater
Reputation: 1
Joined: 30 Jan 2023 Posts: 156
|
Posted: Wed Dec 06, 2023 12:27 pm Post subject: Can CE auto-create a backup of a save file each session? |
|
|
I would like to have CE create a backup of my game's save file each time I use it. Once per session. Is there a way to do this each time CE attaches to the process?
Alternatively, a script that I apply a hotkey to would also be great. Then I can just instantly save a backup anytime I want, on the fly. I'm just not sure how to go about the actual task of creating the backup instantly using CE.
When searching online for solutions to automatically create a backup of a game's save file each time I use CE, I am running into unrelated info regarding other types of backups for other purposes.
|
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Wed Dec 06, 2023 10:14 pm Post subject: |
|
|
You should be able to do this using Lua. But, if the game is not writing to the save file automatically, then it might be a pointless endeavor.
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1066 Location: 0x90
|
Posted: Wed Dec 06, 2023 10:24 pm Post subject: Re: Can CE auto-create a backup of a save file each session? |
|
|
Autem wrote: | I would like to have CE create a backup of my game's save file each time I use it. Once per session. Is there a way to do this each time CE attaches to the process?
Alternatively, a script that I apply a hotkey to would also be great. Then I can just instantly save a backup anytime I want, on the fly. I'm just not sure how to go about the actual task of creating the backup instantly using CE.
When searching online for solutions to automatically create a backup of a game's save file each time I use CE, I am running into unrelated info regarding other types of backups for other purposes. |
Copy and paste this directly into the main window of Cheat Engine
Code: |
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
<CheatEntries>
<CheatEntry>
<ID>0</ID>
<Description>"Create Backup File"</Description>
<LastState/>
<VariableType>Auto Assembler Script</VariableType>
<AssemblerScript>[ENABLE]
{$LUA}
if syntaxcheck then return end
local user = os.getenv('USERNAME')
local function generateUniqueFilename(path)
local base, ext = path:match("(.*)(%..*)$")
local counter = 1
while io.open(path, 'rb') do
path = string.format("%s Copy (%d)%s", base, counter, ext)
counter = counter + 1
end
return path
end
-- Set the sourcePath to the path of your savegame (including extension)
local sourcePath = 'C:\\Users\\' .. user .. '\\Desktop\\'
local sourceFilename = 'Test.rtf'
local backupFolder = sourcePath .. 'Backup\\'
local backupFilename = 'test_backup.rtf'
if not lfs.attributes(backupFolder, 'directory') then
lfs.mkdir(backupFolder)
end
-- First check if the source file exists
local sourceFile = io.open(sourcePath .. sourceFilename, 'rb')
if not sourceFile then
print('Error: Unable to open source file')
return
end
-- Check if the file exists, if so then generate a new file with a unique filename
local backupFilePath = backupFolder .. backupFilename
while io.open(backupFilePath, 'rb') do
backupFilePath = generateUniqueFilename(backupFilePath)
end
local backupFile = io.open(backupFilePath, 'wb')
if not backupFile then
print('Error: Unable to open destination file')
sourceFile:close()
return
end
-- Read from the source file and write to the destination file
local content = sourceFile:read('*a')
backupFile:write(content)
-- Close the files
sourceFile:close()
backupFile:close()
-- You can uncomment this line if you want confirmation, but it will work providing the paths are correct.
--print('File copied successfully')
{$ASM}
nop
[DISABLE]
</AssemblerScript>
<Hotkeys>
<Hotkey>
<Action>Activate</Action>
<Keys>
<Key>17</Key>
<Key>16</Key>
<Key>106</Key>
</Keys>
<Description>Save</Description>
<ID>0</ID>
<ActivateSound TTS="EN">Created a backup save.</ActivateSound>
</Hotkey>
</Hotkeys>
</CheatEntry>
</CheatEntries>
</CheatTable>
|
You can edit the hotkeys as you see fit. It's currently set to Ctrl, Shift + Numeric *. This will create a copy of the file and place it into a folder within the source directory called 'Backup'. If the backup save already exists, it will create a new copy.
|
|
Back to top |
|
 |
Autem Expert Cheater
Reputation: 1
Joined: 30 Jan 2023 Posts: 156
|
Posted: Wed Dec 06, 2023 11:13 pm Post subject: Re: Can CE auto-create a backup of a save file each session? |
|
|
LeFiXER wrote: | Copy and paste this directly into the main window of Cheat Engine |
Works perfectly for what I'm doing. Thank you!
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|