Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to delete addresses

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
paboya
How do I cheat?
Reputation: 0

Joined: 28 Apr 2013
Posts: 2

PostPosted: Sun Apr 28, 2013 5:31 pm    Post subject: How to delete addresses Reply with quote

hi, so i have this script to automatically add to address list

Code:
          ...
          ...
          local al=getAddressList()
          local mr=addresslist_createMemoryRecord(al)
          memoryrecord_setAddress(mr, saddress)
          ...


my question is, how can i clear all found address from the list?

i try these script
Code:
function CEButton1Click(sender)
  local al=getAddressList()
  cnt = addresslist_getCount(al)
  if cnt > 0 then
     for i=0, cnt-1 do
         local mr = addresslist_getMemoryRecord(al,i)
         print("delete mr " .. i .. " " .. memoryrecord_getDescription(mr))
         memoryrecord_delete(mr)
     end
  end
...


but it only delete half of them

output:
Code:
delete mr 0 en1_0
delete mr 1 en1_2
delete mr 2 en1_4
delete mr 3 en1_6
delete mr 4 en1_8
Error:TTreeNodes.GetNodeFromIndex Index 5 out of bounds (Count=5)


but when i remove the "memoryrecord_delete" it loop perfectly?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Sun Apr 28, 2013 6:06 pm    Post subject: Reply with quote

when you delete an entry all subsequent indexes shift by 1 (so if you delete entry 0, 1 becomes 0, 2 becomes 1, etc...)

you're best of getting and deleting memory record 0 until the count is 0, or do a reverse for loop ( for i=cnt-1, 0 do )

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
paboya
How do I cheat?
Reputation: 0

Joined: 28 Apr 2013
Posts: 2

PostPosted: Sun Apr 28, 2013 6:16 pm    Post subject: Reply with quote

Dark Byte wrote:
when you delete an entry all subsequent indexes shift by 1 (so if you delete entry 0, 1 becomes 0, 2 becomes 1, etc...)

you're best of getting and deleting memory record 0 until the count is 0, or do a reverse for loop ( for i=cnt-1, 0 do )


thank for your sugggestions, the first work

Code:
  while addresslist_getCount(al)>0 do
    local mr = addresslist_getMemoryRecord(al,0)
    memoryrecord_delete(mr)
  end
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Apr 29, 2013 5:56 am    Post subject: Reply with quote

memory records have ID too. If you want to keep other memoryrecords, do something like this:

createMemoryRecords - will create new mr
removeAllCreatedMemoryRecords - will remove mr created with above function


Code:
al=getAddressList()

IDsOfCreatedMR = {}

function createMemoryRecords() --create 10 memory records
  for a=1,10 do
    local mr=addresslist_createMemoryRecord(al)
    memoryrecord_setDescription(mr, 'memory record test '..a)
    table.insert(IDsOfCreatedMR , memoryrecord_getID(mr) )
  end
end

function removeAllCreatedMemoryRecords()
  for _,v in pairs(IDsOfCreatedMR) do
    local mr = addresslist_getMemoryRecordByID(al,v)
    if mr~=nil then memoryrecord_delete(mr) end
  end
end

_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites