Table Cleaner for Table Makers

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
GreenHouse
Expert Cheater
Expert Cheater
Posts: 852
Joined: Fri Oct 12, 2018 10:25 pm
Reputation: 896

Table Cleaner for Table Makers

Post by GreenHouse »

Image

This extension does clean the Advanced Options window, deletes all Structures, unregisters all UserSymbols and cleans the Comments window.
Previously you had to delete everything manually, which was a bit of a hassle.
You can choose what to delete specifically. And those settings will be saved for future uses of it. So if you uncheck "Delete Comments" the checkbox will never be ticked when opening the window again. Regardless of you restarting Cheat Engine or not.

- To use it, all you gotta do is either click on the top "GreenHouse" menu, choose "Clean Table", and choose what you want to remove.
Or just press Ctrl+Q and the window will open automatically.

MAKE SURE THAT YOU'RE READY TO SAVE THE TABLE WHEN USING IT, BECAUSE IT WILL ALSO DISABLE ALL SCRIPTS.

For those that don't know how to install it, just move the LUA file into the "autorun" folder inside the Cheat Engine directory.
Made for 7.4, I don't know if it will work on older versions.
Attachments
TableCleaner.zip
v1.01
(1.45 KiB) Downloaded 1638 times
TableCleaner.zip
v1.0
(1.31 KiB) Downloaded 1527 times

User avatar
SunBeam
Administration
Administration
Posts: 4932
Joined: Sun Feb 04, 2018 7:16 pm
Reputation: 4630

Re: Table Cleaner for Table Makers

Post by SunBeam »

Uhm.. there is a flag you can use so user symbols are not saved with the table :) But sure, let it be there for the kicks.

GreenHouse
Expert Cheater
Expert Cheater
Posts: 852
Joined: Fri Oct 12, 2018 10:25 pm
Reputation: 896

Re: Table Cleaner for Table Makers

Post by GreenHouse »

SunBeam wrote:
Sat Jun 11, 2022 8:20 am
Uhm.. there is a flag you can use so user symbols are not saved with the table :) But sure, let it be there for the kicks.
First time hearing about it. Is it a flag that isn't on Cheat Engine settings but that can be used with LUA?
Still, regardless of it, the extension does also delete multiple things. Symbols don't take that much space anyways, I made it mainly for the structures, and then added the others as a plus to make sure everything is cleaned up.

User avatar
gibberishh
Table Makers
Table Makers
Posts: 383
Joined: Fri Jul 02, 2021 5:48 pm
Reputation: 250

Re: Table Cleaner for Table Makers

Post by gibberishh »

Nice. I have a regex in Editpad that I run on tables before signing them. Removes everything I don't need. Apart from your list of items, it also removes the <LastState /> tags. It's near-irrelevant for tiny tables, but I have a couple of tables that legitimately run into 300-500 KB. Just removing LastState reduces their size by ~30 KB (10%).

This ext will make life simpler now. Thanks!

User avatar
gibberishh
Table Makers
Table Makers
Posts: 383
Joined: Fri Jul 02, 2021 5:48 pm
Reputation: 250

Re: Table Cleaner for Table Makers

Post by gibberishh »

Hey GH. Made some minor improvements to your code in case you wish to use this:

Code: Select all

-- Made by GreenHouse! for the FearlessRevolution Forum.
-- Version 1.01

-- Changelog [1.01]:
---- Changed scale of the Form to fit properly on other resolutions (Can't really fully test it myself, but it should fit properly.)

-- Changelog [1.02]:
---- Moved the Clean Table option to the Edit menu.
---- User can now use Alt+E (Edit) + C to open the form. Then again C to clean the table.
---- Added a Cancel button to the form
---- Added ability to close the form by hitting the Escape key
---- Removed min/maximize buttons from the form

delOptions = {'delSymbols','delAdvOptions','delComments','delStructs'}
delCaptions = {'Symbols','Advanced Options','Comments','Structures'}
chkDelBoxes = {}

local function FindForm(name)
  for i = 0,GetFormCount()-1 do
    local form = GetForm(i)
    if form.ClassName == name then return form end
  end
end

function CloseCleaner()
  frmClean.Hide()
end

function Escaper(key)
  if key == VK_ESCAPE then CloseCleaner() end
  return key
end

regSettings = getSettings('GreenH')
for key,val in pairs(delOptions) do
  if #regSettings[val..'Active'] == 0 then regSettings[val..'Active'] = 1 end --If it doesn't exist, then create and set to default
  _G[val..'Active'] = tonumber(regSettings[val..'Active']) --Then load the saved setting
end

frmClean = createForm(false)
frmClean.Width = 300
frmClean.Height = 120
frmClean.Caption = 'Table Cleaner'
frmClean.Position = 'poDesktopCenter'
frmClean.BorderStyle = 'bsToolWindow'
frmClean.OnClose = CloseCleaner
frmClean.OnShow = function()
  for key,val in pairs(delOptions) do
    checkbox_setState(chkDelBoxes[key],_G[val.."Active"])
  end
end

for key,val in pairs(delOptions) do
  chkDelBoxes[key] = createCheckBox(frmClean)
  chkDelBoxes[key].Left = 5
  chkDelBoxes[key].Top = 5 + (20*(key-1))
  chkDelBoxes[key].Height = 20
  chkDelBoxes[key].AutoSize = true
  chkDelBoxes[key].Name = val
  chkDelBoxes[key].Caption = "Delete "..delCaptions[key]
  chkDelBoxes[key].OnChange = function(sender)
    _G[sender.Name.."Active"] = checkbox_getState(sender)
    regSettings.Value[sender.Name..'Active'] = checkbox_getState(sender)
  end
  chkDelBoxes[key].OnKeyUp = function(sender,key) return Escaper(key) end
end

btnClean = createButton(frmClean)
btnClean.Left = 5
btnClean.Top = 90
btnClean.Width = 80
btnClean.Name = 'btnClean'
btnClean.Caption = '&Clean'
btnClean.OnKeyUp = function(sender,key) return Escaper(key) end
btnClean.OnClick = function()
  AddressList.disableAllWithoutExecute() --Force Disable All Scripts
  if delSymbolsActive == 1 then
    local MemBrwsr = FindForm('TMemoryBrowser')
    MemBrwsr.miUserdefinedSymbols.doClick()
    SymbHndlr = FindForm('TfrmSymbolhandler')
    local list = SymbHndlr.ListView1.Items
    for i = SymbHndlr.ListView1.Items.Count-1,0,-1 do
      unregisterSymbol(SymbHndlr.ListView1.Items[i].Caption)
    end
    SymbHndlr.Close()
  end
  if delAdvOptionsActive == 1 then
    FindForm('TAdvancedOptions').lvCodelist.Items.Clear()
  end
  if delCommentsActive == 1 then
    local Cmnts = FindForm('TComments')
    Cmnts.Memo1.Clear()
    MainForm.CommentButton.Font.Style = ''
  end
  if delStructsActive == 1 then
    if getStructureCount() ~= 0 then
      for i = getStructureCount()-1,0,-1 do
        getStructure(i).removeFromGlobalStructureList()
      end
    end
  end
end

btnCancelClean = createButton(frmClean)
btnCancelClean.Left = 90
btnCancelClean.Top = 90
btnCancelClean.Width = 80
btnCancelClean.Caption = 'Cancel'
btnCancelClean.OnClick = CloseCleaner
btnCancelClean.OnKeyUp = function(sender,key) return Escaper(key) end

if CleanerMenuItem == nil then
  local parent = getMainForm().Menu.Items[1]
  CleanerMenuItem = createMenuItem(parent)
  CleanerMenuItem.Caption = '&Clean Table'
  CleanerMenuItem.OnClick = function() ExtForm.Show() end
  CleanerMenuItem.Name = 'ghCleanTable'
  CleanerMenuItem.Shortcut = 'Ctrl+Q'
  parent.add(CleanerMenuItem)
end
FYI, it works on CE 7.2.

Post Reply

Who is online

Users browsing this forum: No registered users