| View previous topic :: View next topic |
| Author |
Message |
Lemchast How do I cheat?
Reputation: 0
Joined: 11 Jun 2019 Posts: 6
|
Posted: Thu Aug 08, 2019 12:21 am Post subject: Exclude String Search Results Containing Certain Substrings |
|
|
I wish to write a LUA script to perform a string search on the opened process in Cheat Engine (in my case, BlueStacks).
However, I would like to exclude search results containing certain substrings. I've listed these strings to be excluded in a strings.txt file, each separated by a new line.
For instance, if I search ownsComponent and there are 3 results:
ownsComponent(redShirt)
ownsComponent(blueShirt)
ownsComponent(greenShirt)
Assuming my strings.txt file contains the lines redShirt and greenShirt, the only search result should be ownsComponent(blueShirt).
I would greatly appreciate any help on this matter. Thanks very much!
|
|
| Back to top |
|
 |
Lemchast How do I cheat?
Reputation: 0
Joined: 11 Jun 2019 Posts: 6
|
Posted: Fri Aug 09, 2019 12:33 am Post subject: |
|
|
| Just checking back to ask whether I described my problem clearly. If you need any clarifications, do let me know!
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25875 Location: The netherlands
|
Posted: Fri Aug 09, 2019 2:57 am Post subject: |
|
|
Do you need to know how to do a string scan? Or how to go through a list of results and then filter out the ones you like
Because you can just scan for ownsComponent and then readString every found address and check if it matches a line in string.txt and if not, add it to your own list
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Lemchast How do I cheat?
Reputation: 0
Joined: 11 Jun 2019 Posts: 6
|
Posted: Fri Aug 09, 2019 4:35 am Post subject: |
|
|
| Dark Byte wrote: | Do you need to know how to do a string scan? Or how to go through a list of results and then filter out the ones you like
Because you can just scan for ownsComponent and then readString every found address and check if it matches a line in string.txt and if not, add it to your own list |
What you've described would be perfect for what I'm trying to achieve (i.e. for every found address, add only the lines not in strings.txt to my own list).
|
|
| Back to top |
|
 |
Lemchast How do I cheat?
Reputation: 0
Joined: 11 Jun 2019 Posts: 6
|
Posted: Sun Aug 11, 2019 4:46 am Post subject: |
|
|
| Hi again! Has anyone had any luck coming up with the code for the above solution? Thanks!
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 153
Joined: 06 Jul 2014 Posts: 4734
|
Posted: Sun Aug 11, 2019 9:29 am Post subject: |
|
|
| Code: | local blacklist = createStringList()
blacklist.loadFromFile([[C:\Users\Lemchast\Documents\blacklist.txt]])
local ms = createMemScan()
local fl = createFoundList(ms)
ms.firstScan(soExactValue, vtString, 0, 'ownsComponent(', '', 0, 0x7fffffffffffffff, '*X*C*W',
fsmNotAligned, '1', false, false, false, true)
ms.waitTillDone()
fl.initialize()
local results = {}
for i = 0, fl.Count - 1 do
local s = readString(fl.Address[i],100)
local bad = false
for i = 0, blacklist.Count-1 do
if string.find(s, blacklist[i], 15, true) then
bad = true
break
end
end
if not bad then
results[#results+1] = fl.Address[i]
end
end
fl.deinitialize()
fl.destroy()
ms.destroy()
blacklist.destroy()
-- do whatever with results
-- e.g. add memory records:
for i,v in ipairs(results) do
local mr = AddressList.createMemoryRecord()
mr.Address = v
mr.Type = vtString
mr.String.Size = 100
mr.Description = 'Result '..i
end
|
Look at celua.txt for documentation and these forums for more examples.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
|