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 


Swapping Strings in Lua

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Snytex
How do I cheat?
Reputation: 0

Joined: 08 Feb 2023
Posts: 1

PostPosted: Wed Feb 08, 2023 9:23 am    Post subject: Swapping Strings in Lua Reply with quote

Hey I've been tryna make a trainer that lets me swap 2 string values with UTF 16 and Case sensitive enabled. Now I did read the Lua Guide but I didnt really get far with it. Could someone please explain how to do that? e.g. the first string value is [Dice] and I want to scan for that, then change the value to [car]. I hope someone can help me.
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Wed Feb 08, 2023 9:37 am    Post subject: Reply with quote

You can use writeString.
Code:

writeString(address,text, widechar OPTIONAL) : Write a string to the specified address. Returns true on success


More info can be found here: celua.txt
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1533

PostPosted: Tue Feb 14, 2023 8:46 am    Post subject: Reply with quote

Try this;

Code:
function byteTableToAobString(t)
  for k,v in ipairs(t) do
    t[k] = ('%02X'):format(v)
  end
  return table.concat(t, ' ')
end

function TextToAobs(text)
  newvalue = (text) --:lower()
  --print(newvalue)
  if not newvalue then return end
newvalue = stringToByteTable(newvalue)
  newvalue = byteTableToAobString(newvalue)
  print(newvalue)
return newvalue
end

print(TextToAobs("Zar"))

function multiReplace(from,to)
  local good,aob = 0,AOBScan(tostring(from),"+W*XC")

  if (aob == nil) then
  showMessage("Code not found..")
  else
 aobCnt=strings_getCount(aob) - 1
    for i=0, aobCnt do
      if autoAssemble (aob[i]..":\ndb "..tostring(to)) then good=good+1
      end
    end
  end
    aob.Destroy()
    showMessage("Replace code: " .. good)
  return good
end

--use:
multiReplace(TextToAobs("Dice"),TextToAobs("car"))

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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