View previous topic :: View next topic |
Author |
Message |
lolAnonymous Expert Cheater Reputation: 1
Joined: 19 Jul 2015 Posts: 154
|
Posted: Thu Nov 12, 2015 8:48 pm Post subject: Scan And Replace In String (Help....) |
|
|
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
Thanks In Advance
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Nov 14, 2015 5:29 pm Post subject: |
|
|
Code: | local str = "This is a string."
str = string.gsub(str, "is", "##")
print(str) |
|
|
Back to top |
|
|
lolAnonymous Expert Cheater Reputation: 1
Joined: 19 Jul 2015 Posts: 154
|
Posted: Sat Nov 14, 2015 6:11 pm Post subject: |
|
|
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 |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Nov 14, 2015 9:01 pm Post subject: |
|
|
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 |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sat Nov 14, 2015 9:50 pm Post subject: |
|
|
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 |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sun Nov 15, 2015 6:40 am Post subject: |
|
|
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 |
|
|
|