Difference between revisions of "Lua:createMemoryStream"
Jump to navigation
Jump to search
m |
|||
| Line 82: | Line 82: | ||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| + | |||
| + | {{Memory}} | ||
Revision as of 14:55, 25 June 2026
Creates a new MemoryStream object.
A MemoryStream is a stream stored in memory. It inherits from Stream and Object, and can be used to load, store, modify, or save binary data.
The MemoryStream's memory address can be accessed through its read-only Memory property. This address may change when the stream size changes.
Function Parameters
This function has no parameters.
Returns
MemoryStream — A new MemoryStream object.
Class Information
| Class | Inherits From | Description |
|---|---|---|
| MemoryStream | Stream, Object | A stream object that stores its contents in memory. |
Properties
| Property | Type | Description |
|---|---|---|
| Memory | Integer | The address in Cheat Engine's memory where this stream is currently loaded. This property is read-only and may change when the stream size changes. |
Methods
| Method | Return Type | Description |
|---|---|---|
| loadFromFile(filename) | void | Replaces the contents of the memory stream with the contents of a file on disk. |
| saveToFile(filename) | void | Writes the contents of the memory stream to the specified file. |
| loadFromFileNoError(filename) | Boolean, String | Replaces the contents of the memory stream with the contents of a file on disk. On success, returns true. On failure, returns false and a secondary return value containing the error message. |
| saveToFileNoError(filename) | Boolean, String | Writes the contents of the memory stream to the specified file. On success, returns true. On failure, returns false and a secondary return value containing the error message. |
Examples
local stream = createMemoryStream()
stream.loadFromFile("C:\\\\Temp\\\\input.bin")
print("Memory address: " .. string.format("%X", stream.Memory))
stream.saveToFile("C:\\\\Temp\\\\output.bin")
local stream = createMemoryStream()
local success, errorMessage = stream.loadFromFileNoError("C:\\\\Temp\\\\input.bin")
if success then
print("File loaded into memory stream")
else
print("Failed to load file: " .. errorMessage)
end