-- Pointer Offset Batch Editor Tool -- For Cheat Engine Lua Script -- Define function to create tool window local function createPointerOffsetTool() local f = createForm(true) f.Caption = 'Pointer Offset Batch Editor' f.Width = 500 -- Increased width to accommodate new controls f.Height = 250 -- Increased height f.Position = poDesktopCenter -- Center window -- Create labels local lblLayer = createLabel(f) lblLayer.Caption = 'Pointer Level:' lblLayer.Left = 30 lblLayer.Top = 40 lblLayer.Font.Size = 10 local lblOperation = createLabel(f) lblOperation.Caption = 'Operation:' lblOperation.Left = 30 lblOperation.Top = 85 lblOperation.Font.Size = 10 local lblValue = createLabel(f) lblValue.Caption = 'Value:' lblValue.Left = 30 lblValue.Top = 130 lblValue.Font.Size = 10 -- Create input fields local edtLayer = createEdit(f) edtLayer.Left = 180 edtLayer.Top = 35 edtLayer.Width = 200 edtLayer.Height = 30 edtLayer.Text = '1' edtLayer.Font.Size = 10 -- Create operation type dropdown local cmbOperation = createComboBox(f) cmbOperation.Left = 180 cmbOperation.Top = 80 cmbOperation.Width = 200 cmbOperation.Height = 30 cmbOperation.Font.Size = 10 cmbOperation.Items.add('Set To') -- 等于 cmbOperation.Items.add('Add') -- 加 cmbOperation.Items.add('Subtract') -- 减 cmbOperation.ItemIndex = 0 -- Default to "Set To" local edtValue = createEdit(f) edtValue.Left = 180 edtValue.Top = 125 edtValue.Width = 200 edtValue.Height = 30 edtValue.Text = '0' edtValue.Font.Size = 10 -- Create button local btnApply = createButton(f) btnApply.Caption = 'Apply Changes' btnApply.Left = 180 btnApply.Top = 170 btnApply.Width = 100 btnApply.Height = 35 btnApply.Font.Size = 10 -- Convert hexadecimal string to number local function hexToNumber(hexStr) -- Remove spaces hexStr = string.gsub(hexStr, " ", "") -- If string is empty, return 0 if hexStr == "" then return 0 end -- Convert to number with base 16 (hexadecimal) local num = tonumber(hexStr, 16) return num or 0 -- Return 0 if conversion fails end -- Function to apply changes local function applyChanges() local list = getAddressList() if list == nil or list.Count == 0 then showMessage('Address list is empty!') return end -- Get input level value (starting from 1) local layerInput = tonumber(edtLayer.Text) if layerInput == nil or layerInput < 1 then showMessage('Level must be a number greater than 0!') return end -- Convert to internal index (starting from 0) local layerIndex = layerInput - 1 -- Get operation type local operation = cmbOperation.Text -- Get input value local changeValue = hexToNumber(edtValue.Text) -- Record number of modifications local modifiedCount = 0 -- Iterate through address list for i = 0, list.Count - 1 do local rec = list[i] -- Only modify selected addresses if rec.Selected then -- Check if pointer level is sufficient if rec.OffsetCount > layerIndex then -- Get current offset value local currentOffset = rec.Offset[layerIndex] -- Calculate new offset based on operation type local newOffset = currentOffset if operation == 'Set To' then newOffset = changeValue elseif operation == 'Add' then newOffset = currentOffset + changeValue elseif operation == 'Subtract' then newOffset = currentOffset - changeValue end -- Modify offset at specified level rec.Offset[layerIndex] = newOffset modifiedCount = modifiedCount + 1 end end end -- Display result if modifiedCount > 0 then showMessage(string.format('Successfully modified %d selected addresses at level %d!\nOperation: %s, Value: %X', modifiedCount, layerInput, operation, changeValue)) else showMessage('No addresses selected, or selected addresses have insufficient levels!') end end -- Button click event btnApply.OnClick = applyChanges -- Input validation edtLayer.OnChange = function(sender) local text = sender.Text -- Allow positive integers only, no 0 or negative if not string.match(text, "^%d*$") then sender.Text = sender.OldText or "1" else -- If empty string, set to 1 if text == "" then sender.Text = "1" else -- Check if greater than 0 local num = tonumber(text) if num and num <= 0 then sender.Text = "1" else sender.OldText = text end end end end edtValue.OnChange = function(sender) local text = sender.Text -- Allow hexadecimal characters only (0-9, A-F, a-f) local valid = string.match(text, "^[0-9A-Fa-f]*$") if not valid then sender.Text = sender.OldText or "" else sender.OldText = text end end -- Add keyboard shortcut support f.OnKeyDown = function(sender, key) if key == 13 then -- Enter key applyChanges() elseif key == 27 then -- ESC key f.close() end end -- Form close event f.OnClose = function() f.destroy() end -- Show form f.show() end -- Execute after 1 second delay to add tool to menu local timer = createTimer() timer.Interval = 1000 -- 1 second timer.OnTimer = function(t) -- Stop timer t.destroy() -- Find "Batch Tools" menu local mainMenu = getMainForm().Menu local batchToolsMenuItem = nil -- Traverse main menu to find "Batch Tools" for i = 0, mainMenu.Items.Count - 1 do local menuItem = mainMenu.Items[i] if menuItem.Caption == 'Batch Tools' then batchToolsMenuItem = menuItem break end end -- If "Batch Tools" menu not found, create one if not batchToolsMenuItem then batchToolsMenuItem = createMenuItem(MainForm.Menu) batchToolsMenuItem.Caption = 'Batch Tools' mainMenu.Items.add(batchToolsMenuItem) end -- Create tool menu item local pointerOffsetMenuItem = createMenuItem(batchToolsMenuItem) pointerOffsetMenuItem.Caption = 'Pointer Offset Batch Editor' pointerOffsetMenuItem.OnClick = createPointerOffsetTool -- Add to batch tools menu batchToolsMenuItem.add(pointerOffsetMenuItem) -- Optional: Show notification message -- showMessage('Pointer Offset Batch Editor has been added to menu: Batch Tools -> Pointer Offset Batch Editor') end