Lua:saveTable
Jump to navigation
Jump to search
Saves the current Cheat Engine table.
saveTable can save the table to a file path or to a stream object. When saving to a filename with the .CETRAINER extension, the optional protect parameter can be used to protect the trainer from being read normally.
Contents
- 1 Function Parameters
- 2 Returns
- 3 Description
- 4 Save Modes
- 5 Examples
- 5.1 Save the current table as a CT file
- 5.2 Save the current table as a CETRAINER file
- 5.3 Save a protected CETRAINER file
- 5.4 Save a table without deactivating designer forms
- 5.5 Ask the user where to save the table
- 5.6 Save only if the filename is valid
- 5.7 Create a timestamped backup
- 5.8 Save the current table to a MemoryStream
- 5.9 Save the current table to a stream and then to disk
- 5.10 Save to a stream without deactivating designer forms
- 5.11 Store the current table as an embedded table file
- 5.12 Replace an existing backup file
Function Parameters
| Parameter | Type | Description |
|---|---|---|
| filename | String | The path where the current table should be saved. Usually this is a .CT or .CETRAINER file. |
| stream | Stream | A stream object the current table should be saved to. |
| protect | Boolean OPTIONAL | Only used by the filename overload. If true and filename has the .CETRAINER extension, the trainer is protected from being read normally. |
| dontDeactivateDesignerForms | Boolean OPTIONAL | If true, designer forms are not deactivated while saving the table. |
Returns
This function does not return a value.
Description
saveTable saves the currently loaded Cheat Engine table.
When called with a filename, Cheat Engine writes the current table to disk. When called with a stream, Cheat Engine writes the table data to the given stream object.
The protect parameter only applies to the filename overload and is intended for protected .CETRAINER output.
Save Modes
| Call | Behavior |
|---|---|
| saveTable(filename) | Saves the current table to a file. |
| saveTable(filename, protect) | Saves the current table to a file and optionally protects .CETRAINER output. |
| saveTable(filename, protect, dontDeactivateDesignerForms) | Saves the current table to a file with explicit protection and designer-form behavior. |
| saveTable(stream) | Saves the current table to a stream object. |
| saveTable(stream, dontDeactivateDesignerForms) | Saves the current table to a stream object with explicit designer-form behavior. |
Examples
Save the current table as a CT file
1 saveTable([[C:\\CheatTables\\example.ct]])
Save the current table as a CETRAINER file
1 saveTable([[C:\\CheatTables\\example.cetrainer]])
Save a protected CETRAINER file
1 saveTable([[C:\\CheatTables\\protected.cetrainer]], true)
Save a table without deactivating designer forms
1 saveTable([[C:\\CheatTables\\example.ct]], false, true)
Ask the user where to save the table
1 local dialog = createSaveDialog(nil)
2
3 dialog.Filter = "Cheat Engine Tables (*.CT)|*.CT|Cheat Engine Trainers (*.CETRAINER)|*.CETRAINER|All files (*.*)|*.*"
4 dialog.DefaultExt = "ct"
5
6 if dialog.execute() then
7 saveTable(dialog.FileName)
8 end
9
10 dialog.destroy()
Save only if the filename is valid
1 local filename = [[C:\\CheatTables\\backup.ct]]
2
3 if filename ~= "" then
4 saveTable(filename)
5 end
Create a timestamped backup
1 local backupName = os.date([[C:\\CheatTables\\backup_%Y%m%d_%H%M%S.ct]])
2
3 saveTable(backupName)
Save the current table to a MemoryStream
1 local stream = createMemoryStream()
2
3 saveTable(stream)
4
5 print("Saved bytes: " .. tostring(stream.Size))
6
7 stream.destroy()
Save the current table to a stream and then to disk
1 local stream = createMemoryStream()
2
3 saveTable(stream)
4
5 stream.Position = 0
6 stream.saveToFile([[C:\\CheatTables\\stream_saved.ct]])
7
8 stream.destroy()
Save to a stream without deactivating designer forms
1 local stream = createMemoryStream()
2
3 saveTable(stream, true)
4
5 print("Saved bytes: " .. tostring(stream.Size))
6
7 stream.destroy()
Store the current table as an embedded table file
1 local stream = createMemoryStream()
2
3 saveTable(stream)
4 stream.Position = 0
5
6 local tableFile = createTableFile("backup.ct")
7 tableFile.Stream.copyFrom(stream, stream.Size)
8
9 stream.destroy()
Replace an existing backup file
1 local filename = [[C:\\CheatTables\\backup.ct]]
2
3 if fileExists(filename) then
4 deleteFile(filename)
5 end
6
7 saveTable(filename)
Cheat Table Related Functions