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 


Append memrec as a child, indexed?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Birdi
Expert Cheater
Reputation: 0

Joined: 08 Jun 2020
Posts: 122
Location: Migrating

PostPosted: Thu Aug 19, 2021 1:26 am    Post subject: Append memrec as a child, indexed? Reply with quote

Trying to write up some freeform functions I can pull from, but I'm not sure how to change the Index of children.. I see that you have access to a memrec's Index as read-only, and you can access a group's children via Child[index].

So.. how would I change a child's index under a group? Using appendToEntry() always puts it at the bottom of the group, and I'd like more control over that.

Currently I've just got this, but it doesn't work because the Index field is read-only, I'm guessing.

Code:

local function childAppend(memDesc, parent)
  local al=getAddressList()
  for i=0,al.Count-1 do
    if al[i].Description == parent then
       trueParent = al[i]
    end
  end
  for i=0,al.Count-1 do
    if al[i].Description == memDesc then
       al[i].appendToEntry(trueParent)
    end
  end
  local TPCC = trueParent.Count -- Stores the index of the newly appended memrec
  trueParent[TPCC].Index = 0  -- Desired effect, anyway.. move the index/order of children.. can be expanded upon but I need this first
end
  -- trueParent.Child[TPCC].Index = 0 also doesn't work, presumably for the same reason?

_________________
Trying to learn!

Add me on Discord if you want hands-on help: Birdi#0007
Back to top
View user's profile Send private message Visit poster's website
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Aug 19, 2021 3:42 am    Post subject: Reply with quote

Code:

function setMemrecRelativeIndex(memrec, newindex)
  local parent=memrec.Parent
  if parent==nil then return end

  list={}

  for i=0,parent.Count-1 do
    if parent[i]~=memrec then
      table.insert(list,parent[i])
    end
  end

  table.insert(list,newindex+1, memrec)

  --the list is now ordered according to the requested order
  for i=1,#list do
    list[i].appendToEntry(parent)
  end
end

_________________
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
Birdi
Expert Cheater
Reputation: 0

Joined: 08 Jun 2020
Posts: 122
Location: Migrating

PostPosted: Thu Aug 19, 2021 7:45 am    Post subject: Reply with quote

Thanks DB ♥

I doubt it, but would it be possible to make this more of a feature? Obviously just having the working function is fine here, but for future CE versions, I don't see why it needs to be read-only, but you may have your reasons.

_________________
Trying to learn!

Add me on Discord if you want hands-on help: Birdi#0007
Back to top
View user's profile Send private message Visit poster's website
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