 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
sir-gunny Advanced Cheater
Reputation: 0
Joined: 15 Mar 2012 Posts: 81
|
Posted: Fri Mar 18, 2022 11:27 am Post subject: Recreating a string with references from a string (as table) |
|
|
Hello.
I would like to use the references from a string to create a new string from it. The references are in a table. The strings have sometimes several references and sometimes none at all. Sometimes there are references that are not in the table. I do not know what to do at the moment. I hope you can help me. Sorry for my english, I use deepl.
Example:
Code: | MyString = [[{1101,2344} - {1102,874} \({3501,78} a {457,57}{74,978}\)!]]
MyBigTable = { [49] = {
[1101] = {[2344] = [[Hello]]},
[457] = {[57] = nil}, -- {457,57} does not exist in the table
[1102] = {[874] = [[World]]},
[3501] = {[78] = [[{8745,589} {84,987}]]},
[8745] = {[589] = [[This]]},
[84] = {[987] = [[is]]},
[74] = {[978] = [[test!]]}
}} |
Code: | Hello - World (This is a test!)! |
|
|
Back to top |
|
 |
sir-gunny Advanced Cheater
Reputation: 0
Joined: 15 Mar 2012 Posts: 81
|
Posted: Sat Mar 19, 2022 3:10 pm Post subject: |
|
|
Hi.
I have tested around a bit and found this solution for me. Probably not the nicest but OK for me.
Code: | function stringReplaceFromTable(sString,tTable)
local d1,d2 = sString:match("{(%d+),(%d+)}")
local sTemp = sString:gsub("{%d+,%d+}",tTable[tonumber(d1)] and tTable[tonumber(d1)][tonumber(d2)] or "",1)
if sTemp:match("{%d+,%d+}") then
return stringReplaceFromTable(sTemp,tTable)
else
sTemp = sTemp:gsub("\\","")
return sTemp
end
end
print(stringReplaceFromTable(MyString,MyBigTable[49])) |
|
|
Back to top |
|
 |
|
|
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
|
|