Difference between revisions of "Lua:getAddressList"

From Cheat Engine
Jump to navigation Jump to search
(Simplification of the entry, as most of the information should be within Addresslist)
m (Undo revision 8247 by Leunsel (talk))
(Tag: Undo)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
{{CodeBox|'''function''' getAddressList() ''':''' Addresslist}}
+
'''function''' getAddressList() ''':''' UserData
  
Returns the main Cheat Engine [[Lua:Class:Addresslist|Addresslist]] object.
+
* '''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.
  
This is the same object that is available through the global [[Lua:AddressList|AddressList]] variable.
 
  
===Function Parameters===
+
=== Description ===
This function has no parameters.
 
  
===Returns===
+
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:
Addresslist — The main Cheat Engine address list object.
 
  
===Examples===
+
* Add, remove, or modify memory records
 +
* Access existing cheat table entries
 +
* Manipulate the selection
 +
* Control freezing/unfreezing of values
 +
* Import/export table data
  
<syntaxhighlight lang="lua" line>
 
local addressList = getAddressList()
 
  
print("Record count: " .. tostring(addressList.Count))
+
=== Usage Examples ===
</syntaxhighlight>
+
 
 +
'''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 [[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}}
  
{{Forms}}
+
=== Related Variables ===
 +
* [[Lua:AddressList|AddressList]]
 +
* [[Lua:process|process]]
 +
* [[Lua:MainForm|MainForm]]
 +
* [[Lua:createMemoryRecord|createMemoryRecord]] - Create new memory records
 +
 
 +
=== Related Functions ===
 +
* [[Lua:getMainForm|getMainForm]] - Get the main Cheat Engine window
 +
 
 +
=== Related Classes ===
 +
* [[Lua:Class:Addresslist|Addresslist]] - Complete class documentation
 +
* [[Lua:Class:MemoryRecord|MemoryRecord]] - Individual address entry documentation

Revision as of 18:39, 25 June 2026

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.


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


Main Pages

Core Lua documentation entry points

Lua
Script Engine

Related Variables

Related Functions

Related Classes