  | 
				
				Cheat Engine The Official Site of Cheat Engine   
				
 
				 | 
			 
		 
		 
	
		| View previous topic :: View next topic   | 
	 
	
	
		| Author | 
		Message | 
	 
	
		Dark Byte Site Admin
  Reputation: 470
  Joined: 09 May 2003 Posts: 25807 Location: The netherlands
  | 
		
			
				 Posted: Mon Jan 20, 2020 3:09 pm    Post subject: Add to new group | 
				        | 
			 
			
				
  | 
			 
			
				This code adds a new menuitem called "Add to new group" which will move all currently selected entries to a newly created group
 
 
 	  | Code: | 	 		  
 
local pm=AddressList.PopupMenu
 
local pmAddToNewGroup=createMenuItem(pm)
 
pmAddToNewGroup.Caption='Add to new group'
 
pmAddToNewGroup.ImageIndex=MainForm.CreateGroup.ImageIndex
 
pm.Items.insert(MainForm.CreateGroup.MenuIndex, pmAddToNewGroup)
 
 
local oldOnPopup=AddressList.PopupMenu.OnPopup
 
AddressList.PopupMenu.OnPopup=function(s)
 
  if oldOnPopup then
 
    oldOnPopup(s)
 
  end
 
  pmAddToNewGroup.Visible=AddressList.SelCount>=1
 
end
 
 
pmAddToNewGroup.OnClick=function(s)
 
  local i
 
  local count=0
 
  local selcount=0
 
  local withAddress=false
 
  local hasAddressSupport=false
 
 
  if AddressList.SelCount==0 then
 
    messageDialog('Please select at least one entry first', mtError, mbOK)
 
    return
 
  end
 
 
  hasAddressSupport=AddressList[0].IsAddressGroupHeader~=nil
 
 
  for i=0,AddressList.Count-1 do
 
    if AddressList[i].IsGroupHeader then
 
      count=count+1
 
    end
 
  end
 
 
 
  local groupname='Group '..count+1
 
  if (isKeyPressed(VK_CONTROL)==false) then
 
    groupname = InputQuery('Groups', 'What do you want the groupname to be?', groupname)
 
    if groupname then
 
      if hasAddressSupport then
 
        withAddress=messageDialog('Do you want "address" version?', mtConfirmation, mbYes, mbNo)==mrYes
 
      end
 
    else
 
      return
 
    end
 
  end
 
 
 
  --create a new group and add all selected records to the list
 
  local header=AddressList.createMemoryRecord()
 
  header.IsGroupHeader=true
 
  header.IsAddressGroupHeader=withAddress
 
  header.Description=groupname
 
 
  records={}
 
 
  for i=0,AddressList.Count-1 do
 
    if AddressList[i].Selected then
 
      local selectedparent=false
 
      local p=AddressList[i].Parent
 
      while p do
 
        if p.Selected then selectedparent=true end
 
        p=p.Parent
 
      end
 
 
      if selectedparent==false then
 
        table.insert(records,AddressList[i])
 
      end
 
    end
 
  end
 
 
  for i=1,#records do
 
    records[i].Parent=header
 
  end
 
end
 
 
 | 	  
	
  
	 
	
	
		
	 
	
		|  Description: | 
		
			
		 | 
		  Download | 
	 
	
		|  Filename: | 
		 AddToNewGroup.LUA | 
	 
	
		|  Filesize: | 
		 1.88 KB | 
	 
	
		|  Downloaded: | 
		 1047 Time(s) | 
	 
	 
	 
 _________________
 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 
  Last edited by Dark Byte on Fri Jan 31, 2020 6:25 am; edited 1 time in total | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Csimbi I post too much
  Reputation: 97
  Joined: 14 Jul 2007 Posts: 3327
 
  | 
		
			
				 Posted: Tue Jan 21, 2020 4:14 am    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				Useful, thank you!
 
 
Edit:
 
Bug: you are prompted for the name of the new group, but the name you enter does not seem to get used (mine ended up 'Group 8' anyway, regardless what I entered).
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		mgr.inz.Player I post too much
  Reputation: 222
  Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
  | 
		
			
				 Posted: Tue Jan 21, 2020 3:28 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				change line:
 
 	  | Code: | 	 		  | if InputQuery('Groups', 'What do you want the groupname to be?', groupname) then | 	  
 
 
to:
 
 	  | Code: | 	 		  groupname = InputQuery('Groups', 'What do you want the groupname to be?', groupname)
 
if groupname then | 	  
 _________________
  | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		Csimbi I post too much
  Reputation: 97
  Joined: 14 Jul 2007 Posts: 3327
 
  | 
		
			
				 Posted: Tue Jan 21, 2020 5:18 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				| Perfect, thanks!
 | 
			 
		  | 
	 
	
		| Back to top | 
		 | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
	 
	    
	   | 
	
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
  | 
   
 
		 |