Difference between revisions of "Lua:loadTable"
Jump to navigation
Jump to search
m |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | '''function''' loadTable('' | + | {{CodeBox|'''function''' loadTable(''filename'', ''merge'' OPTIONAL) ''':''' void}} |
| − | ''' | ||
| − | Loads a | + | {{CodeBox|'''function''' loadTable(''stream'', ''merge'' OPTIONAL, ''ignoreluascriptdialog'' OPTIONAL) ''':''' void}} |
| + | |||
| + | 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. | ||
===Function Parameters=== | ===Function Parameters=== | ||
| − | {|width="85%" cellpadding="10 | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" |
!align="left"|Parameter | !align="left"|Parameter | ||
!align="left"|Type | !align="left"|Type | ||
!style="width: 80%;background-color:white;" align="left"|Description | !style="width: 80%;background-color:white;" align="left"|Description | ||
|- | |- | ||
| − | | | + | |filename |
|String | |String | ||
| − | |The | + | |The path to the .CT or .CETRAINER file to load. |
| + | |- | ||
| + | |stream | ||
| + | |Stream | ||
| + | |A stream object containing the table data to load. | ||
|- | |- | ||
|merge | |merge | ||
| − | |Boolean | + | |Boolean OPTIONAL |
| − | |If | + | |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. | ||
|} | |} | ||
| − | {|width="85%" cellpadding="10 | + | ===Returns=== |
| − | !align="left"| | + | This function does not return a value. |
| − | + | ||
| − | !style="width: 80%;background-color:white;" align="left"| | + | ===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: | ||
| + | |||
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
| + | !align="left"|merge | ||
| + | !style="width: 80%;background-color:white;" align="left"|Behavior | ||
|- | |- | ||
| − | | | + | |false or omitted |
| − | + | |The current table is cleared before the new table is loaded. | |
| − | |The | ||
|- | |- | ||
| − | | | + | |true |
| − | + | |The new table is merged into the currently loaded table. | |
| − | | | ||
| − | |||
| − | |||
| − | |||
| − | |||
|} | |} | ||
| − | == Examples == | + | ===Examples=== |
| − | < | + | |
| − | loadTable( | + | ====Load a table from disk==== |
| − | </ | + | <syntaxhighlight lang="lua" line> |
| − | < | + | loadTable([[C:\\CheatTables\\example.ct]]) |
| − | loadTable( | + | </syntaxhighlight> |
| − | </ | + | |
| − | < | + | ====Load a trainer from disk==== |
| + | <syntaxhighlight lang="lua" line> | ||
| + | loadTable([[C:\\CheatTables\\example.cetrainer]]) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Merge a table into the current table==== | ||
| + | <syntaxhighlight lang="lua" line> | ||
| + | loadTable([[C:\\CheatTables\\extra_records.ct]], true) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Replace the current table explicitly==== | ||
| + | <syntaxhighlight lang="lua" line> | ||
| + | loadTable([[C:\\CheatTables\\main.ct]], false) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Ask the user for a table file==== | ||
| + | <syntaxhighlight lang="lua" line> | ||
| + | local dialog = createOpenDialog(nil) | ||
| + | |||
| + | dialog.Filter = "Cheat Engine Tables (*.CT)|*.CT|Cheat Engine Trainers (*.CETRAINER)|*.CETRAINER|All files (*.*)|*.*" | ||
| + | |||
| + | if dialog.execute() then | ||
| + | loadTable(dialog.FileName) | ||
| + | end | ||
| + | |||
| + | dialog.destroy() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Load a table from a MemoryStream==== | ||
| + | <syntaxhighlight lang="lua" line> | ||
local stream = createMemoryStream() | local stream = createMemoryStream() | ||
| − | stream.loadFromFile( | + | |
| + | stream.loadFromFile([[C:\\CheatTables\\example.ct]]) | ||
| + | stream.Position = 0 | ||
| + | |||
loadTable(stream) | loadTable(stream) | ||
| − | |||
| + | stream.destroy() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Merge a table from a MemoryStream==== | ||
| + | <syntaxhighlight lang="lua" line> | ||
| + | local stream = createMemoryStream() | ||
| + | |||
| + | stream.loadFromFile([[C:\\CheatTables\\extra_records.ct]]) | ||
| + | stream.Position = 0 | ||
| + | |||
| + | loadTable(stream, true) | ||
| + | |||
| + | stream.destroy() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Load from a stream and ignore the Lua script dialog==== | ||
| + | <syntaxhighlight lang="lua" line> | ||
| + | local stream = createMemoryStream() | ||
| + | |||
| + | stream.loadFromFile([[C:\\CheatTables\\scripted_table.ct]]) | ||
| + | stream.Position = 0 | ||
| + | |||
| + | loadTable(stream, false, true) | ||
| + | |||
| + | stream.destroy() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Load an embedded table file==== | ||
| + | <syntaxhighlight lang="lua" line> | ||
| + | local tableFile = findTableFile("extra_records.ct") | ||
| + | |||
| + | if tableFile ~= nil then | ||
| + | local stream = tableFile.getData() | ||
| + | |||
| + | stream.Position = 0 | ||
| + | loadTable(stream, true) | ||
| + | end | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Safe helper for loading a table==== | ||
| + | <syntaxhighlight lang="lua" line> | ||
| + | local function loadTableIfExists(path, merge) | ||
| + | if fileExists(path) then | ||
| + | loadTable(path, merge or false) | ||
| + | return true | ||
| + | end | ||
| + | |||
| + | return false | ||
| + | end | ||
| + | |||
| + | if not loadTableIfExists([[C:\\CheatTables\\main.ct]]) then | ||
| + | print("Table file does not exist") | ||
| + | end | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Load multiple tables into one session==== | ||
| + | <syntaxhighlight lang="lua" line> | ||
| + | loadTable([[C:\\CheatTables\\base.ct]], false) | ||
| + | loadTable([[C:\\CheatTables\\extras.ct]], true) | ||
| + | loadTable([[C:\\CheatTables\\debug.ct]], true) | ||
| + | </syntaxhighlight> | ||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| − | + | {{CheatTable}} | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 19:05, 25 June 2026
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[edit]
| 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[edit]
This function does not return a value.
Description[edit]
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[edit]
Load a table from disk[edit]
1 loadTable([[C:\\CheatTables\\example.ct]])
Load a trainer from disk[edit]
1 loadTable([[C:\\CheatTables\\example.cetrainer]])
Merge a table into the current table[edit]
1 loadTable([[C:\\CheatTables\\extra_records.ct]], true)
Replace the current table explicitly[edit]
1 loadTable([[C:\\CheatTables\\main.ct]], false)
Ask the user for a table file[edit]
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[edit]
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[edit]
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[edit]
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[edit]
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[edit]
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[edit]
1 loadTable([[C:\\CheatTables\\base.ct]], false)
2 loadTable([[C:\\CheatTables\\extras.ct]], true)
3 loadTable([[C:\\CheatTables\\debug.ct]], true)
Cheat Table Related Functions