4Byte Scan and Replace all Results

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
StayEnforced
What is cheating?
What is cheating?
Posts: 3
Joined: Mon Mar 28, 2022 11:07 pm
Reputation: 0

4Byte Scan and Replace all Results

Post 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.

GreenHouse
Expert Cheater
Expert Cheater
Posts: 857
Joined: Fri Oct 12, 2018 10:25 pm
Reputation: 889

Re: 4Byte Scan and Replace all Results

Post 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.

StayEnforced
What is cheating?
What is cheating?
Posts: 3
Joined: Mon Mar 28, 2022 11:07 pm
Reputation: 0

Re: 4Byte Scan and Replace all Results

Post 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?

GreenHouse
Expert Cheater
Expert Cheater
Posts: 857
Joined: Fri Oct 12, 2018 10:25 pm
Reputation: 889

Re: 4Byte Scan and Replace all Results

Post by GreenHouse »

Create a script, add {$lua} under [ENABLE], and add the LUA code.

StayEnforced
What is cheating?
What is cheating?
Posts: 3
Joined: Mon Mar 28, 2022 11:07 pm
Reputation: 0

Re: 4Byte Scan and Replace all Results

Post by StayEnforced »

Thank you, Works for exactly what I need it to do.

Post Reply

Who is online

Users browsing this forum: No registered users