Get ID or Index of current Memory Record

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
S1N74X
Cheater
Cheater
Posts: 40
Joined: Wed Sep 15, 2021 4:25 pm
Reputation: 4

Get ID or Index of current Memory Record

Post by S1N74X »

Hi there,

is there a way to figure out whats the ID or Index the current Memory Record?
I know i can use getAddressList().getMemoryRecordByDescription() and so on...
Afaik every Memory Record has a underlaying ID and Index.
Is there a way to get those more or less direct ?

Thanks for useful suggestions

imjustmaxie
Expert Cheater
Expert Cheater
Posts: 242
Joined: Mon Aug 06, 2018 6:00 pm
Reputation: 208

Re: Get ID or Index of current Memory Record

Post by imjustmaxie »

S1N74X wrote:
Mon Apr 15, 2024 11:39 am
Hi there,

is there a way to figure out whats the ID or Index the current Memory Record?
I know i can use getAddressList().getMemoryRecordByDescription() and so on...
Afaik every Memory Record has a underlaying ID and Index.
Is there a way to get those more or less direct ?

Thanks for useful suggestions
getAddressList().getMemoryRecordByDescription(‘description’).ID or .Index

[Link]

S1N74X
Cheater
Cheater
Posts: 40
Joined: Wed Sep 15, 2021 4:25 pm
Reputation: 4

Re: Get ID or Index of current Memory Record

Post by S1N74X »

[/quote]

getAddressList().getMemoryRecordByDescription(‘description’).ID or .Index

[/quote]

Thx for your reply but thats exatctly not the way i need to get the ID or the Index
The Memerc Name or Description can change. The ID is afaik uniqe

imjustmaxie
Expert Cheater
Expert Cheater
Posts: 242
Joined: Mon Aug 06, 2018 6:00 pm
Reputation: 208

Re: Get ID or Index of current Memory Record

Post by imjustmaxie »

S1N74X wrote:
Mon Apr 15, 2024 1:20 pm

Thx for your reply but thats exactly not the way I need to get the ID or the Index.
The memrec name or description can change. The ID is afaik unique
getAddressList().SelectedRecord.ID or getAddressList().SelectedRecord.Index

S1N74X
Cheater
Cheater
Posts: 40
Joined: Wed Sep 15, 2021 4:25 pm
Reputation: 4

Re: Get ID or Index of current Memory Record

Post by S1N74X »

imjustmaxie wrote:
Mon Apr 15, 2024 1:53 pm
S1N74X wrote:
Mon Apr 15, 2024 1:20 pm

Thx for your reply but thats exactly not the way I need to get the ID or the Index.
The memrec name or description can change. The ID is afaik unique
getAddressList().SelectedRecord.ID or getAddressList().SelectedRecord.Index
Does it. Thx

S1N74X
Cheater
Cheater
Posts: 40
Joined: Wed Sep 15, 2021 4:25 pm
Reputation: 4

Re: Get ID or Index of current Memory Record

Post by S1N74X »

S1N74X wrote:
Mon Apr 15, 2024 2:00 pm
imjustmaxie wrote:
Mon Apr 15, 2024 1:53 pm
S1N74X wrote:
Mon Apr 15, 2024 1:20 pm

Thx for your reply but thats exactly not the way I need to get the ID or the Index.
The memrec name or description can change. The ID is afaik unique
getAddressList().SelectedRecord.ID or getAddressList().SelectedRecord.Index
Does it. Thx
Aah sh.....
Selected == Activated
So the result doesnt match if you activate more than one script

Thx anyway

imjustmaxie
Expert Cheater
Expert Cheater
Posts: 242
Joined: Mon Aug 06, 2018 6:00 pm
Reputation: 208

Re: Get ID or Index of current Memory Record

Post by imjustmaxie »

S1N74X wrote:
Mon Apr 15, 2024 2:10 pm
S1N74X wrote:
Mon Apr 15, 2024 2:00 pm
imjustmaxie wrote:
Mon Apr 15, 2024 1:53 pm


getAddressList().SelectedRecord.ID or getAddressList().SelectedRecord.Index
Does it. Thx
Aah sh.....
Selected == Activated
So the result doesnt match if you activate more than one script

Thx anyway
Use a for loop on the AddressList and do compares if the AddressList[/i].Selected == true or AddressList[/i].Active == true or not, and do what you want to do afterwards.

Code: Select all

local al = getAddressList()
for i=0,al.Count-1 do
    if al[i].Selected == true then
        -- code here
    end
    -- or
    if al[i].Active == true then
        -- code here
    end
end

Paul44
RCE Fanatics
RCE Fanatics
Posts: 888
Joined: Thu Jul 27, 2017 9:02 am
Reputation: 566

Re: Get ID or Index of current Memory Record

Post by Paul44 »

^^ or: myMr = al.getMemoryRecordByID(ID)
(i never/rarely work with 'byDescr...' since i tend to a) rearrange/rename my entries in due time b) copy/pasting from another table keeps thàt ID (unless it already exists in current table)

KiLLerBoy_001
Noobzor
Noobzor
Posts: 14
Joined: Mon Sep 18, 2023 10:09 pm
Reputation: 1

Re: Get ID or Index of current Memory Record

Post by KiLLerBoy_001 »

Code: Select all


[ENABLE]
 
-- Do Stuff

ID.Active = false


[DISABLE]

Works like a charm

User avatar
LeFiXER
LeFixer
LeFixer
Posts: 489
Joined: Wed Mar 24, 2021 9:35 am
Reputation: 251

Re: Get ID or Index of current Memory Record

Post by LeFiXER »

Here's one way you can do it:

Code: Select all

local function getSelectedRecordIDs()
    local tmp = {}
    for i = 0, AddressList.Count - 1 do
        if AddressList[i].Selected then
           table.insert(tmp, AddressList[i].ID)
        end
    end
    return tmp
end

local function getSelectedRecordID()
  local selectedRecord = AddressList.SelectedRecord
  local ID = selectedRecord.ID
  local Description = selectedRecord.Description
  return ID, Description
end

-- Print single selected record ID
local id, desc = getSelectedRecordID()
printf('Description: %s\t-  ID: %d', desc, id)
----------------------------------------------------------------------

-- Print ID of multiple selected recrods
local selectedIDs = getSelectedRecordIDs()
for k,v in pairs(selectedIDs) do
    print('Selected IDs: ' .. v)
end
----------------------------------------------------------------------
This does not account for any error-checking though.

Post Reply

Who is online

Users browsing this forum: No registered users