Difference between revisions of "Lua:getAddressList"
Jump to navigation
Jump to search
Mr millchick (talk | contribs) (Added more detailed documentation with useful examples) |
|||
| Line 2: | Line 2: | ||
'''function''' getAddressList() ''':''' UserData | '''function''' getAddressList() ''':''' UserData | ||
| − | Returns | + | * '''Parameters:''' <None> |
| + | * '''Returns:''' The main Cheat Engine [[Lua:Class:Addresslist|Addresslist]] UserData object (the cheat table's address list panel). | ||
| + | ** '''Note:''' This is the same as accessing the global '''AddressList''' variable. | ||
| − | + | === Description === | |
| − | == Examples == | + | The address list is the central component of Cheat Engine's GUI where you manage memory records (addresses, pointers, scripts, etc.). This function provides programmatic access to: |
| + | |||
| + | * Add, remove, or modify memory records | ||
| + | * Access existing cheat table entries | ||
| + | * Manipulate the selection | ||
| + | * Control freezing/unfreezing of values | ||
| + | * Import/export table data | ||
| + | |||
| + | |||
| + | === Usage Examples === | ||
| + | |||
| + | '''Basic access:''' | ||
| + | local addressList = getAddressList() | ||
| + | print("Number of entries: " .. #addressList) | ||
| + | |||
| + | '''Iterate through all records:''' | ||
| + | local addressList = getAddressList() | ||
| + | for i = 1, #addressList do | ||
| + | local record = addressList[i] | ||
| + | print(record.Description .. " = " .. record.Value) | ||
| + | end | ||
| + | |||
| + | '''Create a new memory record:''' | ||
| + | local addressList = getAddressList() | ||
| + | local record = addressList.createMemoryRecord() | ||
| + | record.Description = "Player Health" | ||
| + | record.Address = "game.exe+12345" | ||
| + | record.Type = vtDword | ||
| + | record.Value = "1000" | ||
| + | |||
| + | '''Access selected records:''' | ||
| + | local addressList = getAddressList() | ||
| + | if addressList.SelCount > 0 then | ||
| + | local selected = addressList.SelectedRecord | ||
| + | print("Selected: " .. selected.Description) | ||
| + | end | ||
| + | |||
| + | '''Delete all records:''' | ||
| + | local addressList = getAddressList() | ||
| + | addressList.clear() | ||
| + | |||
| + | '''Activate (freeze) all selected records:''' | ||
| + | local addressList = getAddressList() | ||
| + | addressList.activateSelected() | ||
| + | |||
| + | '''Get specific record by index:''' | ||
local addressList = getAddressList() | local addressList = getAddressList() | ||
| + | if #addressList > 0 then | ||
| + | local firstRecord = addressList[0] | ||
| + | firstRecord.Active = true | ||
| + | end | ||
| + | |||
| + | '''Using the global variable (equivalent):''' | ||
| + | -- These are equivalent: | ||
| + | local al1 = getAddressList() | ||
| + | local al2 = AddressList | ||
| + | -- al1 and al2 refer to the same object | ||
| + | |||
| + | |||
| + | === Common Operations === | ||
| + | |||
| + | '''Adding Records:''' | ||
| + | local al = getAddressList() | ||
| + | local mr = al.createMemoryRecord() | ||
| + | mr.Description = "Score" | ||
| + | mr.Address = "game.exe+ABCD" | ||
| + | mr.Type = vtDword | ||
| + | |||
| + | '''Finding Records:''' | ||
| + | local al = getAddressList() | ||
| + | local mr = al.getMemoryRecordByDescription("Player Health") | ||
| + | if mr then | ||
| + | print("Found: " .. mr.Address) | ||
| + | end | ||
| + | |||
| + | '''Removing Records:''' | ||
| + | local al = getAddressList() | ||
| + | local mr = al.getMemoryRecordByDescription("Temp Value") | ||
| + | if mr then | ||
| + | mr.destroy() -- Remove from list | ||
| + | end | ||
| + | |||
| + | '''Bulk Operations:''' | ||
| + | local al = getAddressList() | ||
| + | -- Select all | ||
| + | al.SelectAll() | ||
| + | -- Freeze all selected | ||
| + | al.activateSelected() | ||
| + | -- Unfreeze all selected | ||
| + | al.deactivateSelected() | ||
| + | |||
| + | |||
| + | === Properties and Methods === | ||
| + | |||
| + | See [[Lua:Class:Addresslist|Addresslist Class]] for complete documentation of available properties and methods, including: | ||
| + | |||
| + | '''Properties:''' | ||
| + | * '''Count''' - Number of memory records | ||
| + | * '''SelCount''' - Number of selected records | ||
| + | * '''SelectedRecord''' - Currently selected record | ||
| + | |||
| + | '''Methods:''' | ||
| + | * '''createMemoryRecord()''' - Add a new record | ||
| + | * '''getMemoryRecordByDescription(description)''' - Find by name | ||
| + | * '''getMemoryRecordByID(id)''' - Find by ID | ||
| + | * '''clear()''' - Remove all records | ||
| + | * '''SelectAll()''' - Select all records | ||
| + | * '''activateSelected()''' - Freeze selected values | ||
| + | * '''deactivateSelected()''' - Unfreeze selected values | ||
| + | * '''deleteSelected()''' - Remove selected records | ||
| + | |||
| + | |||
| + | === Auto Table Initialization Script Example === | ||
| + | |||
| + | -- Auto-create table entries | ||
| + | function initializeTable() | ||
| + | local al = getAddressList() | ||
| + | al.clear() -- Start fresh | ||
| + | |||
| + | -- Add health record | ||
| + | local health = al.createMemoryRecord() | ||
| + | health.Description = "Health" | ||
| + | health.Address = "game.exe+1234" | ||
| + | health.Type = vtDword | ||
| + | |||
| + | -- Add ammo record | ||
| + | local ammo = al.createMemoryRecord() | ||
| + | ammo.Description = "Ammo" | ||
| + | ammo.Address = "game.exe+5678" | ||
| + | ammo.Type = vtDword | ||
| + | |||
| + | print("Table initialized with " .. #al .. " entries") | ||
| + | end | ||
| + | |||
| + | |||
| + | === Comparison: getAddressList() vs Global Variable === | ||
| + | |||
| + | -- Method 1: Using function | ||
| + | local al = getAddressList() | ||
| + | |||
| + | -- Method 2: Using global variable (recommended for brevity) | ||
| + | local al = AddressList | ||
| + | |||
| + | -- Both methods access the exact same object | ||
| + | -- The global variable is more commonly used in scripts | ||
| + | |||
| + | |||
| + | === Integration with GUI === | ||
| + | |||
| + | Changes made to the address list through Lua are immediately reflected in the Cheat Engine GUI: | ||
| + | |||
| + | local al = getAddressList() | ||
| + | local mr = al.createMemoryRecord() | ||
| + | mr.Description = "New Entry" | ||
| + | -- The entry appears immediately in the GUI | ||
| + | |||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| Line 16: | Line 172: | ||
* [[Lua:process|process]] | * [[Lua:process|process]] | ||
* [[Lua:MainForm|MainForm]] | * [[Lua:MainForm|MainForm]] | ||
| + | * [[Lua:createMemoryRecord|createMemoryRecord]] - Create new memory records | ||
=== Related Functions === | === Related Functions === | ||
| − | * [[Lua:getMainForm|getMainForm]] | + | * [[Lua:getMainForm|getMainForm]] - Get the main Cheat Engine window |
=== Related Classes === | === Related Classes === | ||
| − | * [[Lua:Class:Addresslist|Addresslist]] | + | * [[Lua:Class:Addresslist|Addresslist]] - Complete class documentation |
| − | * [[Lua:Class:MemoryRecord|MemoryRecord]] | + | * [[Lua:Class:MemoryRecord|MemoryRecord]] - Individual address entry documentation |
Revision as of 03:58, 21 October 2025
function getAddressList() : UserData
- Parameters: <None>
- Returns: The main Cheat Engine Addresslist UserData object (the cheat table's address list panel).
- Note: This is the same as accessing the global AddressList variable.
Contents
Description
The address list is the central component of Cheat Engine's GUI where you manage memory records (addresses, pointers, scripts, etc.). This function provides programmatic access to:
- Add, remove, or modify memory records
- Access existing cheat table entries
- Manipulate the selection
- Control freezing/unfreezing of values
- Import/export table data
Usage Examples
Basic access:
local addressList = getAddressList()
print("Number of entries: " .. #addressList)
Iterate through all records:
local addressList = getAddressList() for i = 1, #addressList do local record = addressList[i] print(record.Description .. " = " .. record.Value) end
Create a new memory record:
local addressList = getAddressList() local record = addressList.createMemoryRecord() record.Description = "Player Health" record.Address = "game.exe+12345" record.Type = vtDword record.Value = "1000"
Access selected records:
local addressList = getAddressList()
if addressList.SelCount > 0 then
local selected = addressList.SelectedRecord
print("Selected: " .. selected.Description)
end
Delete all records:
local addressList = getAddressList() addressList.clear()
Activate (freeze) all selected records:
local addressList = getAddressList() addressList.activateSelected()
Get specific record by index:
local addressList = getAddressList() if #addressList > 0 then local firstRecord = addressList[0] firstRecord.Active = true end
Using the global variable (equivalent):
-- These are equivalent: local al1 = getAddressList() local al2 = AddressList -- al1 and al2 refer to the same object
Common Operations
Adding Records:
local al = getAddressList() local mr = al.createMemoryRecord() mr.Description = "Score" mr.Address = "game.exe+ABCD" mr.Type = vtDword
Finding Records:
local al = getAddressList()
local mr = al.getMemoryRecordByDescription("Player Health")
if mr then
print("Found: " .. mr.Address)
end
Removing Records:
local al = getAddressList()
local mr = al.getMemoryRecordByDescription("Temp Value")
if mr then
mr.destroy() -- Remove from list
end
Bulk Operations:
local al = getAddressList() -- Select all al.SelectAll() -- Freeze all selected al.activateSelected() -- Unfreeze all selected al.deactivateSelected()
Properties and Methods
See Addresslist Class for complete documentation of available properties and methods, including:
Properties:
- Count - Number of memory records
- SelCount - Number of selected records
- SelectedRecord - Currently selected record
Methods:
- createMemoryRecord() - Add a new record
- getMemoryRecordByDescription(description) - Find by name
- getMemoryRecordByID(id) - Find by ID
- clear() - Remove all records
- SelectAll() - Select all records
- activateSelected() - Freeze selected values
- deactivateSelected() - Unfreeze selected values
- deleteSelected() - Remove selected records
Auto Table Initialization Script Example
-- Auto-create table entries
function initializeTable()
local al = getAddressList()
al.clear() -- Start fresh
-- Add health record
local health = al.createMemoryRecord()
health.Description = "Health"
health.Address = "game.exe+1234"
health.Type = vtDword
-- Add ammo record
local ammo = al.createMemoryRecord()
ammo.Description = "Ammo"
ammo.Address = "game.exe+5678"
ammo.Type = vtDword
print("Table initialized with " .. #al .. " entries")
end
Comparison: getAddressList() vs Global Variable
-- Method 1: Using function local al = getAddressList() -- Method 2: Using global variable (recommended for brevity) local al = AddressList -- Both methods access the exact same object -- The global variable is more commonly used in scripts
Integration with GUI
Changes made to the address list through Lua are immediately reflected in the Cheat Engine GUI:
local al = getAddressList() local mr = al.createMemoryRecord() mr.Description = "New Entry" -- The entry appears immediately in the GUI
Related Variables
- AddressList
- process
- MainForm
- createMemoryRecord - Create new memory records
Related Functions
- getMainForm - Get the main Cheat Engine window
Related Classes
- Addresslist - Complete class documentation
- MemoryRecord - Individual address entry documentation