Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


get value and replace all instances

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
mordax
Expert Cheater
Reputation: 1

Joined: 16 Apr 2010
Posts: 138

PostPosted: Fri Apr 24, 2015 3:46 pm    Post subject: get value and replace all instances Reply with quote

sorry if this been discussed here already, but i don't really know what to search for.

i'm sure someone here knows how to do this.
i want to have 2 edit boxes in my trainer (i know how to work the form editor..etc)
box1 - enter value to search
box2 - replace all found values with entered value

so it's basically a compact scanner, where i can enter value to be searched and all found values get replaced with the value you enter.
can someone please post me example lua script or something?
Back to top
View user's profile Send private message
alanze
Advanced Cheater
Reputation: 3

Joined: 03 Oct 2012
Posts: 50

PostPosted: Mon Apr 27, 2015 1:47 am    Post subject: This post has 1 review(s) Reply with quote

Go to form designer and change the name of the main form to UDF1.
Now place 2 edit boxes and a button in the form.
Select the first edit box then change it's name to SearchEB,
select the second and change name to ReplaceEB.
Put this script in the lua script window:
Code:

function checkImput(str)
 if (tonumber(str)) then
  if (str+0 > -1) then
   if (not string.find(str, ".", 1, true)) then
    return str+0
   else return nil end
  else return nil end
 else return nil end
end

function replaceAllInt()
 local st=UDF1.SearchEB.Text
 local rt=UDF1.ReplaceEB.Text
 if (checkImput(st) and checkImput(rt)) then
  local t1=""
  local t2=string.format("%X",st)
  while (string.len(t2) < 8) do t2="0"..t2 end
  for x=7, 0, -2 do t1=string.sub(t2,x,x+1).." " end
  rs=AOBScan(t1,"+W-X-C",1,"4")
  if (rs) then
   local lngt=rs.getCount()
   for x=0, lngt-1, 1 do writeInteger(rs[x],rt+0) end
   rs.Destroy()
   rs=nil
  end
 else
  showMessage("Please input an integer number between 0 and 4294967295.")
 end
end

Return to the form and select the button then change the OnClick event to replaceAllInt().
Now try out your mini replacer.

If you have other names change UDF1.SearchEB and UDF1.ReplaceEB accordingly.
To filter the memory area to search for, modify +W-X-C accordingly.
If you want to search and replace other data types, all strings, all float.. then
"createMemScan(0)" is your answer (search on the forum how to use that).


Last edited by alanze on Wed May 06, 2015 10:59 am; edited 1 time in total
Back to top
View user's profile Send private message
CodeKiller
Advanced Cheater
Reputation: 0

Joined: 30 Jun 2009
Posts: 87

PostPosted: Fri Mar 13, 2020 3:32 am    Post subject: Reply with quote

Just to say there is a mistake in the for loop.

Correct version:

Code:
for x=7, 0, -2 do t1=[b]t1[/b]..string.sub(t2,x,x+1).." " end


Without that there is no concatenation...

An enhanced version with a more understandable variable:
Code:
tmp = string.format('%x', GOLD)
    print("Hex value: " .. tmp)
    while (string.len(tmp) < 8) do
        tmp = "0" .. tmp
    end

    GOLD = ""
    for x = 7, 0, -2 do
        if GOLD and GOLD ~= '' then
            GOLD = GOLD .. " " .. string.sub(tmp, x, x+1)
        else
            GOLD = string.sub(tmp, x, x+1)
        end
    end
    print("Reversed Hex value: " .. GOLD)
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Mar 14, 2020 12:05 pm    Post subject: Reply with quote

You may want to be mindful of post dates before replying to threads like this.
This thread was 5 years old.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites