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 


Scan And Replace In String (Help....)

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

Joined: 19 Jul 2015
Posts: 154

PostPosted: Thu Nov 12, 2015 8:48 pm    Post subject: Scan And Replace In String (Help....) Reply with quote

Hello Friends I Need Help With A Function Which Will Scan And Replace in String I Saw People Don't Put Codes In There Trainer So If I Can Also Do That... I Have An Idea ( Secret ) :p So Friends If Any One Here Can Help Me Smile


Thanks In Advance Wink
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Nov 14, 2015 5:29 pm    Post subject: Reply with quote

Code:
local str = "This is a string."
str = string.gsub(str, "is", "##")
print(str)
Back to top
View user's profile Send private message
lolAnonymous
Expert Cheater
Reputation: 1

Joined: 19 Jul 2015
Posts: 154

PostPosted: Sat Nov 14, 2015 6:11 pm    Post subject: Reply with quote

Sir can u tell me from which string to which string your function is replacing and how can I put it in a trainer (on Button)
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Nov 14, 2015 9:01 pm    Post subject: Reply with quote

You assign the OnClick event to your button.
Code:
function CEButton1Click(sender)
  new_string = string.gsub(original_string, replace_this_string, with_this_string)
end
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Nov 14, 2015 9:50 pm    Post subject: Reply with quote

Hi,

Then if a string or string(s) will replace with another string(s) with Zanzer function,
the creator who made strings in "trainer scripts" will add a function to avoid someone changing the original string(s) in the trainer :

Code:

function singleString_checker()
org_string = "This is a string"
check_string = control_getCaption(UDF1.CELabel_xx)
check_string = tostring(check_string)
if org_string  == check_string then
print("Everything is okay...")
else
-- do something weird
print("It's not okay..")
closeCE() end
end


-- or we can use string.len(string) to get number of a string(s) lengths
-- and compare it with original string(s) length
-- or if strings store in a file we can check "filename" and "bytes file
-- length" as a stated variable value and if the "filename" or "bytes file
-- length is not same with stated variable / value, next stop it's  script
-- running


Regard
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Nov 15, 2015 6:40 am    Post subject: Reply with quote

Hi,

Here is example mentioned by Zanzer

Code:

function change_str()
----- string.gsub(s, pattern,replace [,n])
local str1 = "This is original string"   <- change this with a caption, etc
local rpl1 = "Done, replaced original string"  <-change this also
d = string.gsub(str1,str1,rpl1)
-- print(d)
end

function CEButton1Click(sender)
change_str()
end


Edit :
The sample above will change all string "This is original string" with "Done, replaced original string".
If you want to change a part of string, then put the "string" you want to change it with another string.

example :

Code:

local str1 = "This is original string"
str = string.gsub(str1,"original","my old")
print(str)

--- result will give you : "This is my old string"


regards
Back to top
View user's profile Send private message
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