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 


Exclude String Search Results Containing Certain Substrings

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

Joined: 11 Jun 2019
Posts: 6

PostPosted: Thu Aug 08, 2019 12:21 am    Post subject: Exclude String Search Results Containing Certain Substrings Reply with quote

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
View user's profile Send private message
Lemchast
How do I cheat?
Reputation: 0

Joined: 11 Jun 2019
Posts: 6

PostPosted: Fri Aug 09, 2019 12:33 am    Post subject: Reply with quote

Just checking back to ask whether I described my problem clearly. If you need any clarifications, do let me know!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 472

Joined: 09 May 2003
Posts: 25875
Location: The netherlands

PostPosted: Fri Aug 09, 2019 2:57 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Lemchast
How do I cheat?
Reputation: 0

Joined: 11 Jun 2019
Posts: 6

PostPosted: Fri Aug 09, 2019 4:35 am    Post subject: Reply with quote

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
View user's profile Send private message
Lemchast
How do I cheat?
Reputation: 0

Joined: 11 Jun 2019
Posts: 6

PostPosted: Sun Aug 11, 2019 4:46 am    Post subject: Reply with quote

Hi again! Has anyone had any luck coming up with the code for the above solution? Thanks!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 153

Joined: 06 Jul 2014
Posts: 4734

PostPosted: Sun Aug 11, 2019 9:29 am    Post subject: Reply with quote

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
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