Difference between revisions of "Lua:getAddressList"

From Cheat Engine
Jump to navigation Jump to search
(Added more detailed documentation with useful examples)
(Simplification of the entry, as most of the information should be within Addresslist)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' getAddressList() ''':''' UserData
+
{{CodeBox|'''function''' getAddressList() ''':''' Addresslist}}
  
* '''Parameters:''' <None>
+
Returns the main Cheat Engine [[Lua:Class:Addresslist|Addresslist]] object.
* '''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.
  
=== Description ===
+
===Function Parameters===
 +
This function has no parameters.
  
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:
+
===Returns===
 +
Addresslist — The main Cheat Engine address list object.
  
* Add, remove, or modify memory records
+
===Examples===
* Access existing cheat table entries
 
* Manipulate the selection
 
* Control freezing/unfreezing of values
 
* Import/export table data
 
  
 +
<syntaxhighlight lang="lua" line>
 +
local addressList = getAddressList()
  
=== Usage Examples ===
+
print("Record count: " .. tostring(addressList.Count))
 
+
</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}}
  
=== Related Variables ===
+
{{Forms}}
* [[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

<> Lua API Reference

function getAddressList() : Addresslist

Returns the main Cheat Engine Addresslist object.

This is the same object that is available through the global AddressList variable.

Function Parameters

This function has no parameters.

Returns

Addresslist — The main Cheat Engine address list object.

Examples

1 local addressList = getAddressList()
2 
3 print("Record count: " .. tostring(addressList.Count))

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Form Related Classes