Lua:getAddressList

From Cheat Engine
Jump to navigation Jump to search

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[edit]

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[edit]

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[edit]

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[edit]

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[edit]

-- 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[edit]

-- 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[edit]

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


See also[edit]

Related Variables[edit]

Related Functions[edit]

Related Classes[edit]