Lua:loadTable
Jump to navigation
Jump to search
Loads a Cheat Engine table file.
loadTable can load a table from a file path or from a stream object. It supports .CT tables and .CETRAINER files. When merge is true, the currently loaded table is kept and the loaded table is merged into it.
Contents
- 1 Function Parameters
- 2 Returns
- 3 Description
- 4 Examples
- 4.1 Load a table from disk
- 4.2 Load a trainer from disk
- 4.3 Merge a table into the current table
- 4.4 Replace the current table explicitly
- 4.5 Ask the user for a table file
- 4.6 Load a table from a MemoryStream
- 4.7 Merge a table from a MemoryStream
- 4.8 Load from a stream and ignore the Lua script dialog
- 4.9 Load an embedded table file
- 4.10 Safe helper for loading a table
- 4.11 Load multiple tables into one session
Function Parameters
| Parameter | Type | Description |
|---|---|---|
| filename | String | The path to the .CT or .CETRAINER file to load. |
| stream | Stream | A stream object containing the table data to load. |
| merge | Boolean OPTIONAL | If true, the loaded table is merged into the current table. If false or omitted, the current table is cleared before loading. |
| ignoreluascriptdialog | Boolean OPTIONAL | Only used by the stream overload. If true, the Lua script warning/dialog can be ignored when loading the table. |
Returns
This function does not return a value.
Description
loadTable loads a Cheat Engine table into the current Cheat Engine session.
When called with a filename, Cheat Engine loads the table directly from disk. When called with a stream, Cheat Engine reads the table data from the given stream object.
The merge parameter controls whether the existing address list is cleared:
| merge | Behavior |
|---|---|
| false or omitted | The current table is cleared before the new table is loaded. |
| true | The new table is merged into the currently loaded table. |
Examples
Load a table from disk
1 loadTable([[C:\\CheatTables\\example.ct]])
Load a trainer from disk
1 loadTable([[C:\\CheatTables\\example.cetrainer]])
Merge a table into the current table
1 loadTable([[C:\\CheatTables\\extra_records.ct]], true)
Replace the current table explicitly
1 loadTable([[C:\\CheatTables\\main.ct]], false)
Ask the user for a table file
1 local dialog = createOpenDialog(nil)
2
3 dialog.Filter = "Cheat Engine Tables (*.CT)|*.CT|Cheat Engine Trainers (*.CETRAINER)|*.CETRAINER|All files (*.*)|*.*"
4
5 if dialog.execute() then
6 loadTable(dialog.FileName)
7 end
8
9 dialog.destroy()
Load a table from a MemoryStream
1 local stream = createMemoryStream()
2
3 stream.loadFromFile([[C:\\CheatTables\\example.ct]])
4 stream.Position = 0
5
6 loadTable(stream)
7
8 stream.destroy()
Merge a table from a MemoryStream
1 local stream = createMemoryStream()
2
3 stream.loadFromFile([[C:\\CheatTables\\extra_records.ct]])
4 stream.Position = 0
5
6 loadTable(stream, true)
7
8 stream.destroy()
Load from a stream and ignore the Lua script dialog
1 local stream = createMemoryStream()
2
3 stream.loadFromFile([[C:\\CheatTables\\scripted_table.ct]])
4 stream.Position = 0
5
6 loadTable(stream, false, true)
7
8 stream.destroy()
Load an embedded table file
1 local tableFile = findTableFile("extra_records.ct")
2
3 if tableFile ~= nil then
4 local stream = tableFile.getData()
5
6 stream.Position = 0
7 loadTable(stream, true)
8 end
Safe helper for loading a table
1 local function loadTableIfExists(path, merge)
2 if fileExists(path) then
3 loadTable(path, merge or false)
4 return true
5 end
6
7 return false
8 end
9
10 if not loadTableIfExists([[C:\\CheatTables\\main.ct]]) then
11 print("Table file does not exist")
12 end
Load multiple tables into one session
1 loadTable([[C:\\CheatTables\\base.ct]], false)
2 loadTable([[C:\\CheatTables\\extras.ct]], true)
3 loadTable([[C:\\CheatTables\\debug.ct]], true)