Seeing the most recent documentation for the lua functionality in cheat-engine/Cheat Engine/bin/celua.txt please rewrite all the documentation related to MemoryRecords as an organized documentation in markdown.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
This document provides an organized and comprehensive overview of the Lua functionality related to MemoryRecords in Cheat Engine. These functions allow manipulation and interaction with memory records (i.e., cheat entries) programmatically via Lua scripts.
Table of Contents
Overview of MemoryRecords
MemoryRecord Properties
MemoryRecord Methods
Accessing MemoryRecords
Examples
Overview of MemoryRecords
MemoryRecords in Cheat Engine represent individual cheat entries in a cheat table. These entries define how a specific memory address or value should be read, manipulated, or displayed. Lua provides a robust API for interacting with these records programmatically, enabling users to automate modifications, searches, and other operations.
MemoryRecord Properties
Below are the key properties of a MemoryRecord object that can be accessed or modified using Lua scripts.
Common Properties
Description
Type:string
Description: The label or name of the memory record.
Example:
lua
local desc = mr.Description
mr.Description = "New Cheat Entry"
Address
Type:string
Description: The memory address or expression associated with the record.
Example:
lua
local addr = mr.Address
mr.Address = "player_health"
Type
Type:ValueType
Description: The data type of the memory record.
Supported Values:
vtByte
vtWord
vtDword
vtQword
vtSingle (float)
vtDouble
vtString
[Redacted Person]
vtAutoAssembler
vtPointer
Example:
lua
local t = mr.Type
mr.Type = vtDword
Value
Type:string
Description: The current value of the memory record. Can be read or written.
Example:
lua
local v = mr.Value
mr.Value = "100"
Active
Type:boolean
Description: Whether the memory record is active (e.g., a script is running or a freeze is applied).
Example:
lua
local isActive = mr.Active
mr.Active = true
Color
Type:integer
Description: The color of the memory record in the cheat table.
Example:
lua
local color = mr.Color
mr.Color = 0xFF0000 -- Red
Parent
Type:MemoryRecord
Description: The parent memory record if this record is a child or part of a group.
Example:
lua
local parent = mr.Parent
Children
Type:table of MemoryRecord
Description: A list of child memory records if this record is a parent/group.
Example:
lua
local children = mr.Children
print(#children)
Script
Type:string
Description: The Lua or AutoAssembler script associated with the memory record.
Description: Whether the memory record's value is frozen.
Example:
lua
mr.Frozen = true
HotkeyCount
Type:integer
Description: Returns the number of hotkeys associated with the memory record.
Example:
lua
local count = mr.HotkeyCount
MemoryRecord Methods
Below are the key methods available for MemoryRecord objects.
getHotkey(index)
Retrieves a hotkey object associated with the memory record.
Parameters:
index (integer): The index of the hotkey (1-based).
Returns:Hotkey object.
Example:
lua
local hk = mr.getHotkey(1)
print(hk.Description)
addHotkey(description, keys, action)
Adds a hotkey to the memory record.
Parameters:
description (string): Description of the hotkey.
keys (table): A table containing key codes (e.g., VK_F1).
action (function): The Lua function to execute when the hotkey is pressed.
Example:
lua
mr.addHotkey("Freeze Health", {VK_F1}, function()
mr.Frozen = not mr.Frozen
end)
deleteHotkey(index)
Removes a hotkey from the memory record.
Parameters:
index (integer): The index of the hotkey to remove.
Example:
lua
mr.deleteHotkey(1)
expand()
Expands the memory record if it is a group.
Example:
lua
mr.expand()
collapse()
Collapses the memory record if it is a group.
Example:
lua
[Redacted Person]()
moveUp()
Moves the memory record up in the cheat table.
Accessing MemoryRecords
MemoryRecords can be accessed via the Cheat Engine Lua API. There are several ways to interact with them:
Access by Index:
lua
local mr = getMemoryRecord(1) -- Get the first memory record
Access by Description:
lua
local mr = getMemoryRecordByDescription("Health")
Iterating Through All Records:
lua
for i = 0, getMemoryRecordCount() - 1 do
local mr = getMemoryRecord(i)
print(mr.Description)
end
Examples
Example 1: Activating a Script
lua
local mr = getMemoryRecordByDescription("God Mode")
if [Redacted Person] [Redacted Person]
mr.Active = true
end
Example 2: Adding a Hotkey
lua
local mr = getMemoryRecordByDescription("Infinite Ammo")
if [Redacted Person] [Redacted Person]
mr.addHotkey("Toggle Freeze", {VK_F2}, function()
mr.Frozen = not mr.Frozen
end)
end
Example 3: Creating a Memory Record Programmatically
lua
local mr = createMemoryRecord()
mr.Description = "New Cheat"
mr.Address = "player_health"
mr.Type = vtDword
mr.Value = "100"
This documentation provides an overview of the capabilities for interacting with MemoryRecords in Cheat Engine. For further customization, consult the complete Cheat Engine Lua scripting reference.