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 


Moving Index in Address List

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Sun Jun 26, 2016 1:09 pm    Post subject: Moving Index in Address List Reply with quote

Is a way possible to Move the position(Index) of an Address List Entry in Lua?
_________________
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Jun 26, 2016 4:57 pm    Post subject: Reply with quote

Move your entries as a child under a single one.
Then you can call appendToEntry() to rearrange those.
? Smile
Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Sun Jun 26, 2016 5:00 pm    Post subject: Reply with quote

Zanzer wrote:
Move your entries as a child under a single one.
Then you can call appendToEntry() to rearrange those.
? Smile


Ok ill try that

_________________
Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Tue Jun 28, 2016 1:55 pm    Post subject: Reply with quote

Thanks Zanzer. The child grouping seemed to be the only way to do the sort.

Is it possible to remove the Child entry from the Parent?

I have tried A couple different ways and went over the main.lua again and thr doesnt appear to be a way to remove the parent. Glad i can get the index(position) to change. I have tried


op = getAddressList().getMemoryRecordByID(4)
yep = getAddressList().getMemoryRecordByID(5)

op.appendToEntry(yep.Parent)

_________________
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Jun 28, 2016 6:55 pm    Post subject: Reply with quote

I couldn't find a way.
Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Tue Jun 28, 2016 9:10 pm    Post subject: Reply with quote

Zanzer wrote:
I couldn't find a way.


Thanks for trying Zanzer, appreciate it.

_________________
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Tue Jun 28, 2016 9:27 pm    Post subject: This post has 1 review(s) Reply with quote

mr.Destroy() or move under a dummy parent, mr.appendToEntry(dummyParent) ?

btw, here a mr sorting function:
Code:
function mrsort(parent,cmp,...)-- sort under a parent
  if cmp==nil then cmp = function(a,b)return a.Description:lower()<b.Description:lower() end end
  local index,al = {},GetAddressList()
  for i=1,parent.Count do index[i]=parent[i-1].ID end
  table.sort(index,function(ia,ib)return cmp(al.getMemoryRecordByID(ia),al.getMemoryRecordByID(ib)) end)
  for i=1,#index do
    local mr = al.getMemoryRecordByID(index[i])
    mr.appendToEntry(parent)
    local nxtCmp = ...
    if mr.Count>0 and nil~=nxtCmp then-- recursive to next level
      if true==nxtCmp then-- repeatly use previous cmp
        mrsort(mr,cmp,true)
      elseif type(nxtCmp)=='function' then
        mrsort(mr,...)
      end
    end
  end
end

-- sample cmp function

mrsort(root,function(a,b)
  -- sort by offset or address, grouped?
  local at,bt = a.Type==vtAutoAssembler,b.Type==vtAutoAssembler
  if at or bt then -- script type have no meaningful Address
    if at==bt then
      return a.Description:lower()<b.Description:lower()
    else
      return at or not bt -- for moving up script type
    end
  end
  local ao,ax = a.Address:match("^(.-)([%+%-]%x+)$")
  local bo,bx = b.Address:match("^(.-)([%+%-]%x+)$")
  if ax==nil or bx==nil then
    ao,ax = a.Address:match("^(.-)([%+%-]?%x+)[^%x]*$")
    bo,bx = b.Address:match("^(.-)([%+%-]?%x+)[^%x]*$")
  end
  ax,bx = tonumber(ax or '',16),tonumber(bx or '',16)
  if ax~=nil and bx~=nil then
    if ao==bo then
      if ax~=bx then
        return ax<bx
      end
    else
      return ao<bo
    end
  end
  return a.Index<b.Index
end)

-- recursive usage
mrsort(root,nil,true) -- recursive sort by case-insensitive description (default cmp)

mrsort(root,cmp1,cmp2) -- sort 2 level, 1st by cmp1 then its children with cmp2


bye~

_________________
- Retarded.
Back to top
View user's profile Send private message
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