The TableFile class represents a file embedded in the current cheat table.
Table files can be created with createTableFile or retrieved with findTableFile. Their contents can be accessed through a MemoryStream, saved to disk, or used directly by functions that accept table files.
Inheritance[edit]
| Class
|
Inherits From
|
Description
|
| TableFile
|
Object
|
Represents a file stored inside the cheat table.
|
Related Functions[edit]
| Function
|
Return Type
|
Description
|
| findTableFile(filename)
|
TableFile
|
Returns the TableFile object for a file stored in the cheat table.
|
| createTableFile(filename, filepath OPTIONAL)
|
TableFile
|
Adds a new file to the cheat table. If filepath is not specified, it creates a blank file. If filepath is specified, it reads the contents from disk.
|
Properties[edit]
| Property
|
Type
|
Description
|
| Name
|
String
|
The name of the file stored in the cheat table.
|
| Stream
|
MemoryStream
|
The stream containing the file data.
|
Methods[edit]
| Method
|
Return Type
|
Description
|
| delete()
|
void
|
Deletes this file from the cheat table.
|
| saveToFile(filename)
|
void
|
Saves this table file to disk.
|
| getData()
|
MemoryStream
|
Returns a MemoryStream object containing the file data.
|
Examples[edit]
Find an embedded table file[edit]
1 local file = findTableFile("protected.wav")
2
3 if file ~= nil then
4 print("Found table file: " .. file.Name)
5 end
Play an embedded sound[edit]
1 local file = findTableFile("protected.wav")
2
3 if file ~= nil then
4 playSound(file)
5 end
Create a blank table file[edit]
1 local file = createTableFile("runtime.dat")
2
3 print("Created table file: " .. file.Name)
Create a table file from disk[edit]
1 local file = createTableFile("config.json", [[C:\\Temp\\config.json]])
2
3 print("Added table file: " .. file.Name)
Save a table file to disk[edit]
1 local file = findTableFile("config.json")
2
3 if file ~= nil then
4 file.saveToFile([[C:\\Temp\\config_copy.json]])
5 end
Read table file data as a MemoryStream[edit]
1 local file = findTableFile("data.bin")
2
3 if file ~= nil then
4 local stream = file.getData()
5
6 print("Stream size: " .. tostring(stream.Size))
7 end
Access the Stream property[edit]
1 local file = findTableFile("data.bin")
2
3 if file ~= nil then
4 local stream = file.Stream
5
6 stream.Position = 0
7 print("Stream size: " .. tostring(stream.Size))
8 end
1 local fileStr = nil
2 local tableFile = findTableFile('PlayerBaseHook.CEA')
3 if tableFile ~= nil then
4 local stringStream = createStringStream()
5 stringStream.Position = 0 -- if not set before using 'copyFrom' the 'StringStream' object will be inconsistent.
6 stringStream.copyFrom(tableFile.Stream, tableFile.Stream.Size)
7 fileStr = stringStream.DataString
8 stringStream.destroy()
9 end
Copy table file data into another MemoryStream[edit]
1 local file = findTableFile("data.bin")
2
3 if file ~= nil then
4 local source = file.getData()
5 local copy = createMemoryStream()
6
7 source.Position = 0
8 copy.copyFrom(source, source.Size)
9
10 print("Copied bytes: " .. tostring(copy.Size))
11
12 copy.destroy()
13 end
Delete a table file[edit]
1 local file = findTableFile("old_data.bin")
2
3 if file ~= nil then
4 file.delete()
5 end
Replace an embedded file[edit]
1 local oldFile = findTableFile("config.json")
2
3 if oldFile ~= nil then
4 oldFile.delete()
5 end
6
7 local newFile = createTableFile("config.json", [[C:\\Temp\\config.json]])
8
9 print("Replaced table file: " .. newFile.Name)
Core Lua documentation entry points