Page 1 of 1

4Byte Scan and Replace all Results

Posted: Mon Mar 28, 2022 11:15 pm
by StayEnforced
I was wondering if anybody could share or make a lua script for cheat engine to do a 4byte scan and replace all results with another value.
Kinda similar to this
scan = (100, 300)
replace = (500, 400)
Where you would scan for 100, And replace all with 500. And if you did multiple it would also scan for 300 and replace all with the 400.

Re: 4Byte Scan and Replace all Results

Posted: Tue Mar 29, 2022 9:32 am
by GreenHouse
You can do something like this:

This as a function:

Code: Select all

function ChangeValues(v, v2)
local MemScan = createMemScan()
MemScan.firstScan(soExactValue, vtDword, nil, v, nil, '0', '700000000000', '*W*C', fsmAligned, '0', false, true, false, false)
MemScan.waitTillDone()
local Results = createFoundList(MemScan)
Results.initialize()
for i=0,Results.Count-1 do
   writeInteger(Results[i],v2)
end
MemScan.destroy()
Results.destroy()
end
And then change values with this line:

Code: Select all

ChangeValues(100, 500) -- Search for 100, change results to 500.
But be aware that you gotta tinker with the scan range and other settings, otherwise it will change things that you don't want to, from other modules, etc.

Re: 4Byte Scan and Replace all Results

Posted: Wed Mar 30, 2022 4:11 am
by StayEnforced
This is exactly what I need, However instead of going into the lua engine to type and call changevalue is there a way to add it to the cheat table and just clicking on it to change values that are set so I can do that when I boot the game?

Re: 4Byte Scan and Replace all Results

Posted: Wed Mar 30, 2022 6:39 am
by GreenHouse
Create a script, add {$lua} under [ENABLE], and add the LUA code.

Re: 4Byte Scan and Replace all Results

Posted: Wed Mar 30, 2022 8:11 am
by StayEnforced
Thank you, Works for exactly what I need it to do.