Searching .txt files and print to drop down. Even possible?

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
oldstuff
Expert Cheater
Expert Cheater
Posts: 477
Joined: Thu Apr 06, 2017 6:53 pm
Reputation: 188

Searching .txt files and print to drop down. Even possible?

Post by oldstuff »

So i suck at lua.. Not even going to try and hide it. I've searched all over trying to figure this out with no luck. Im hoping someone here with much more knowledge in lua can help with a script.

Ill try and be as detailed as i can be. I have a dump file in .txt format and im trying to get CE to search the txt file for key words and then print to a dropdown list with the address and name..

Text file name is C:\[Borderlands3.exe] ObjectsDump.txt File will always be dumped to c:\ and name will never change but i need to dump the file and grab new address's every time due to the address's changing every time you start the game

Dump file is formatted like so:
Spoiler
These are actually 1 line each in the dump file but due to the length ItemPoolData /Game drops to the next line here

[00452874] 000002B68A31E320 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Trinkets.ItemPool_BloodyHarvest_Trinkets

[00452875] 000002B68A31D280 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Skins.ItemPool_BloodyHarvest_Skins

[00452876] 000002B68A31D1A0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_EchoThemes.ItemPool_BloodyHarvest_EchoThemes

[00452877] 000002B68A31D0C0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Cosmetics.ItemPool_BloodyHarvest_Cosmetics

[00452878] 000002B68A31CFE0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Legendary.ItemPool_BloodyHarvest_Legendary
So is what i need is a way to search the text file for:
Spoiler
ItemPool_BloodyHarvest_Trinkets.ItemPool_BloodyHarvest_Trinkets
ItemPool_BloodyHarvest_Skins.ItemPool_BloodyHarvest_Skins
ItemPool_BloodyHarvest_EchoThemes.ItemPool_BloodyHarvest_EchoThemes
ItemPool_BloodyHarvest_Cosmetics.ItemPool_BloodyHarvest_Cosmetics
ItemPool_BloodyHarvest_Legendary.ItemPool_BloodyHarvest_Legendary
I cant search for only ItemPool_BloodyHarvest_Trinkets for example.. it must be ItemPool_BloodyHarvest_Trinkets.ItemPool_BloodyHarvest_Trinkets do to it coming up with more than 1 result if i dont.

After the search I need grab the address 000002B68A31E320 and the name ItemPool_BloodyHarvest_Trinkets and add them to a dropdown list.
Example:
Spoiler
000002B68A31E320:ItemPool_BloodyHarvest_Trinkets
000002B68A31D280:ItemPool_BloodyHarvest_Skins
000002B68A31D1A0:ItemPool_BloodyHarvest_EchoThemes
000002B68A31D0C0:ItemPool_BloodyHarvest_Cosmetics
000002B68A31CFE0:ItemPool_BloodyHarvest_Legendary

Or if the above is not possible add just the address and search term:

000002B68A31E320:ItemPool_BloodyHarvest_Trinkets.ItemPool_BloodyHarvest_Trinkets
000002B68A31D280:ItemPool_BloodyHarvest_Skins.ItemPool_BloodyHarvest_Skins
000002B68A31D1A0:ItemPool_BloodyHarvest_EchoThemes.ItemPool_BloodyHarvest_EchoThemes
000002B68A31D0C0:ItemPool_BloodyHarvest_Cosmetics.ItemPool_BloodyHarvest_Cosmetics
000002B68A31CFE0:ItemPool_BloodyHarvest_Legendary.ItemPool_BloodyHarvest_Legendary
I have 709 ItemPools to add to the table.. but im hoping someone can help get me started with a basic script that i can modify and add all the rest.

Im not even sure if this is possible to add only the address and ending name or not but this is way over my head. Hoping one of you lua gods might have a solution.

If its not possible.. another option would be to do a search as stated above and just print the entire line to Lua window.. I know its not as clean and people will have to copy and paste.. but will at least save them from searching through thousands of lines in a dump file for all the itempools and instead print all 709 pools to the lua window or even a txt file for them.

Thank you in advance for any help you can provide. I will be sure to give credit in the script for anyone that can figure this out

ShyTwig16
Expert Cheater
Expert Cheater
Posts: 335
Joined: Thu Apr 06, 2017 7:14 pm
Reputation: 20

Re: Searching .txt files and print to drop down. Even possible?

Post by ShyTwig16 »

Try something like this:

Code: Select all

local s = [[
[00452874] 000002B68A31E320 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Trinkets.ItemPool_BloodyHarvest_Trinkets

[00452875] 000002B68A31D280 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Skins.ItemPool_BloodyHarvest_Skins

[00452876] 000002B68A31D1A0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_EchoThemes.ItemPool_BloodyHarvest_EchoThemes

[00452877] 000002B68A31D0C0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Cosmetics.ItemPool_BloodyHarvest_Cosmetics

[00452878] 000002B68A31CFE0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Legendary.ItemPool_BloodyHarvest_Legendary
]]

for address, name in s:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
	print(address, name)
end
Edit:
For checking the names you want you could do something like this:

Code: Select all

local s = [[
[00452874] 000002B68A31E320 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Trinkets.ItemPool_BloodyHarvest_Trinkets

[00452875] 000002B68A31D280 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Skins.ItemPool_BloodyHarvest_Skins

[00452876] 000002B68A31D1A0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_EchoThemes.ItemPool_BloodyHarvest_EchoThemes

[00452877] 000002B68A31D0C0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Cosmetics.ItemPool_BloodyHarvest_Cosmetics

[00452878] 000002B68A31CFE0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Legendary.ItemPool_BloodyHarvest_Legendary
]]

local wanted = {
      ['ItemPool_BloodyHarvest_Legendary.ItemPool_BloodyHarvest_Legendary'] = true,
}

local found = { }

for address, name in s:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
    if wanted[name] then
       found[name] = address
    end
end

for name, address in pairs(found) do
    print(name, address)
end

oldstuff
Expert Cheater
Expert Cheater
Posts: 477
Joined: Thu Apr 06, 2017 6:53 pm
Reputation: 188

Re: Searching .txt files and print to drop down. Even possible?

Post by oldstuff »

ShyTwig16 wrote:
Thu Dec 23, 2021 5:14 pm
Try something like this:

Code: Select all

local s = [[
[00452874] 000002B68A31E320 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Trinkets.ItemPool_BloodyHarvest_Trinkets

[00452875] 000002B68A31D280 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Skins.ItemPool_BloodyHarvest_Skins

[00452876] 000002B68A31D1A0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_EchoThemes.ItemPool_BloodyHarvest_EchoThemes

[00452877] 000002B68A31D0C0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Cosmetics.ItemPool_BloodyHarvest_Cosmetics

[00452878] 000002B68A31CFE0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Legendary.ItemPool_BloodyHarvest_Legendary
]]

for address, name in s:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
	print(address, name)
end
Edit:
For checking the names you want you could do something like this:

Code: Select all

local s = [[
[00452874] 000002B68A31E320 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Trinkets.ItemPool_BloodyHarvest_Trinkets

[00452875] 000002B68A31D280 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Skins.ItemPool_BloodyHarvest_Skins

[00452876] 000002B68A31D1A0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_EchoThemes.ItemPool_BloodyHarvest_EchoThemes

[00452877] 000002B68A31D0C0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Cosmetics.ItemPool_BloodyHarvest_Cosmetics

[00452878] 000002B68A31CFE0 ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Legendary.ItemPool_BloodyHarvest_Legendary
]]

local wanted = {
      ['ItemPool_BloodyHarvest_Legendary.ItemPool_BloodyHarvest_Legendary'] = true,
}

local found = { }

for address, name in s:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
    if wanted[name] then
       found[name] = address
    end
end

for name, address in pairs(found) do
    print(name, address)
end
Thank you so much for this.. Only a few things.. [00452874] 000002B68A31E320 changes in the dump file.. How can i get it to search for ItemPoolData /Game/PatchDLC/BloodyHarvest/GameData/Loot/ItemPool_BloodyHarvest_Legendary.ItemPool_BloodyHarvest_Legendary then print the updated address from the dump file. I cant really have it reading the address's from the lua script because those address's change.. how do i get the script to access the dump file on my C drive.. Search the txt file.. then print the entire line with the updated address? In the first post in included the text file name as well as the location and everything for reference.

The way it works is the user would run a script to dump the game.. Then the script i need would search that text file and print the string.. I really like the format its currently showing.. I just need it to pull the new address from the dump file so they have the updated address whenever they start the game.

Thanks again.. I love your work and am thrilled you popped on to help me with this

ShyTwig16
Expert Cheater
Expert Cheater
Posts: 335
Joined: Thu Apr 06, 2017 7:14 pm
Reputation: 20

Re: Searching .txt files and print to drop down. Even possible?

Post by ShyTwig16 »

To read the file do something like this:

Code: Select all

local fileStr
local f, err = io.open(path, 'r')
if err then
    error(err)
elseif f then
   fileStr = f:read('*all')
   f:close()
end

Paul44
RCE Fanatics
RCE Fanatics
Posts: 887
Joined: Thu Jul 27, 2017 9:02 am
Reputation: 566

Re: Searching .txt files and print to drop down. Even possible?

Post by Paul44 »

^@ Yellowsub: i've recently worked on a table doing similar stuff. if you can't get it working, just pm me and i'll upload that table for you... (don't want to upload it here now as it's "work in progress")
that said: #ShyTwig16 also uses arrays in his example; and that is something you'll definitely need to "grasp" (like in 'sooner then later')

ps: my table also makes use of a form to report the info (which "might" complicate things a bit), but output - evt - can be: print to lua window (can be very slow compared to a (form)Listbox), or to file (and also to a mr_dropdown_list if that makes more sense)
ps2: any OOP knowledge ? (as that will save the/your day ~ fyi: i do not consider myself a programmer, but have "touched" enough languages to get around)

oldstuff
Expert Cheater
Expert Cheater
Posts: 477
Joined: Thu Apr 06, 2017 6:53 pm
Reputation: 188

Re: Searching .txt files and print to drop down. Even possible?

Post by oldstuff »

ShyTwig16 wrote:
Thu Dec 23, 2021 6:00 pm
To read the file do something like this:

Code: Select all

local fileStr
local f, err = io.open(path, 'r')
if err then
    error(err)
elseif f then
   fileStr = f:read('*all')
   f:close()
end

Code: Select all

{$lua}
[ENABLE]
local fileStr
local f, err = io.open('C:\\[Borderlands3.exe] ObjectsDump.txt', 'r')
if err then
    error(err)
elseif f then
   fileStr = f:read('*all')



local wanted = {
      ['ItemPool_BloodyHarvest_Legendary.ItemPool_BloodyHarvest_Legendary'] = true,
}

local found = { }

for address, name in fileStr:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
    if wanted[name] then
       found[name] = address
    end

end

for name, address in pairs(found) do
    print(name, address)
end

local wanted = {
      ['ItemPool_BloodyHarvest_Cosmetics.ItemPool_BloodyHarvest_Cosmetics'] = true,
}

local found = { }

for address, name in fileStr:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
    if wanted[name] then
       found[name] = address
    end

end

for name, address in pairs(found) do
    print(name, address)
end
   f:close()
end
[DISABLE]
Woot it works.. Its now grabbing the address from the text file and printing correctly in the lua script.. Just out of curiosity though is the way did it the correct layout? I added a second print out as you can see.. but wow it prints super slow.. like a few seconds per line.. I think its do to the massive size of the dump file.. Would it make and cense to search the file for all ItemPoolData and write that to another txt file so its looking though a much smaller file for the address's? if so how would i add something like that into the script?

Also putting these in 1 line at a time like i did above the correct thing to do.. or is there a better option to do this?

Thanks again for all the help.. Im ecstatic that this is actually working.. slow or not lol!

oldstuff
Expert Cheater
Expert Cheater
Posts: 477
Joined: Thu Apr 06, 2017 6:53 pm
Reputation: 188

Re: Searching .txt files and print to drop down. Even possible?

Post by oldstuff »

Ok im an idiot.. this works a million times better.. just needed some trial and error lol.. Thanks again for all the help

Code: Select all

{$lua}
[ENABLE]
local fileStr
local f, err = io.open('C:\\[Borderlands3.exe] ObjectsDump.txt', 'r')
if err then
    error(err)
elseif f then
   fileStr = f:read('*all')



local wanted = {
      ['ItemPool_BigBoomBlaster.ItemPool_BigBoomBlaster'] = true,
      ['ItemPool_Pills_Upper.ItemPool_Pills_Upper'] = true,
      ['ItemPool_Pills_Downer.ItemPool_Pills_Downer'] = true,
}

local found = { }

for address, name in fileStr:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
    if wanted[name] then
       found[name] = address
    end

end

for name, address in pairs(found) do
    print(name, address)
end


   f:close()
end
[DISABLE]

panraven
Table Makers
Table Makers
Posts: 129
Joined: Fri Mar 03, 2017 12:03 am
Reputation: 118

Re: Searching .txt files and print to drop down. Even possible?

Post by panraven »

May try this pattern

Code: Select all

  local ss = io.open(<-your file path->)
  ss = ss and ss:read'*a', ss and ss:close()
  if ss then -- ss is now the file content as string
    ss:gsub('%[(%x+)%]%s*(%x+)%s*([^\r\n]-)/([_%w]+)%.%4',function(idx,addy,path,name)
      -- do thing on collected item
      print(string.format('idx=%x addr=%x path=%s name=%s',idx,addy,path,name))
    end)
   end
 
-- pattern note:
%[(%x+)%] -- the hexdedcimal idx inside [], collected 1st parameter
%s* - any spaces
(%x+) - the address, 2nd
%s* - spaces
([^\r\n]-)/ - the called path which ended with / , 3rd (modified to force all in same line)
([_%w]+)%.%4 - the 4th name, it followed by same text which pattern as %4

----

oldstuff
Expert Cheater
Expert Cheater
Posts: 477
Joined: Thu Apr 06, 2017 6:53 pm
Reputation: 188

Re: Searching .txt files and print to drop down. Even possible?

Post by oldstuff »

panraven wrote:
Thu Dec 23, 2021 8:30 pm
May try this pattern

Code: Select all

  local ss = io.open(<-your file path->)
  ss = ss and ss:read'*a', ss and ss:close()
  if ss then -- ss is now the file content as string
    ss:gsub('%[(%x+)%]%s*(%x+)%s*([^\r\n]-)/([_%w]+)%.%4',function(idx,addy,path,name)
      -- do thing on collected item
      print(string.format('idx=%x addr=%x path=%s name=%s',idx,addy,path,name))
    end)
   end
 
-- pattern note:
%[(%x+)%] -- the hexdedcimal idx inside [], collected 1st parameter
%s* - any spaces
(%x+) - the address, 2nd
%s* - spaces
([^\r\n]-)/ - the called path which ended with / , 3rd (modified to force all in same line)
([_%w]+)%.%4 - the 4th name, it followed by same text which pattern as %4

----
Thank you for this.. I actually got it working really well now.. but i will try your version and see the difference when i get home. We are about to leave for the holidays but ill be back saturday and will try it out.. If you or anyone know how the heck to add this to a dropdown list now that would be awesome ;)

Thank you everyone so much for all the help on this script :)

ShyTwig16
Expert Cheater
Expert Cheater
Posts: 335
Joined: Thu Apr 06, 2017 7:14 pm
Reputation: 20

Re: Searching .txt files and print to drop down. Even possible?

Post by ShyTwig16 »

I'd try it like this, it might speed things up just to get if off the main thread.

Code: Select all

{$lua}
[ENABLE]
local function getDumpData(thread)
	local fileStr
	local f, err = io.open([[C:\[Borderlands3.exe] ObjectsDump.txt]], 'r')
	if err then
		error(err)
	elseif f then
		fileStr = f:read('*all')
		---- close file right after reading so if there's an error the file won't be stuck open.
		f:close()
	end
	local wanted = {
		['ItemPool_BigBoomBlaster.ItemPool_BigBoomBlaster'] = true,
		['ItemPool_Pills_Upper.ItemPool_Pills_Upper'] = true,
		['ItemPool_Pills_Downer.ItemPool_Pills_Downer'] = true,
	}
	local dropDownData = { }
	for address, name in fileStr:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
		if wanted[name] then
			local prettyName = name:match('^[%w_]-%.ItemPool_(.-)$'):gsub('_', ' ')
			---- this will make the names look like this: "BigBoomBlaster", "Pills Downer"
			---- 	But you can just use name if this doesn't match enough.
			---- Here we setup a table to call concat on.
			table.insert(dropDownData, address..':'..prettyName)
		end
	end
	local mr = AddressList.getMemoryRecordByDescription('The MR description with the drop down list')
	---- or use: AddressList.getMemoryRecordByID(id)
	mr.DropDownList.Text = table.concat(dropDownData, '\n')
	thread.terminate()
end
createThread(getDumpData)
[DISABLE]

oldstuff
Expert Cheater
Expert Cheater
Posts: 477
Joined: Thu Apr 06, 2017 6:53 pm
Reputation: 188

Re: Searching .txt files and print to drop down. Even possible?

Post by oldstuff »

ShyTwig16 wrote:
Fri Dec 24, 2021 1:34 am
I'd try it like this, it might speed things up just to get if off the main thread.

Code: Select all

{$lua}
[ENABLE]
local function getDumpData(thread)
	local fileStr
	local f, err = io.open([[C:\[Borderlands3.exe] ObjectsDump.txt]], 'r')
	if err then
		error(err)
	elseif f then
		fileStr = f:read('*all')
		---- close file right after reading so if there's an error the file won't be stuck open.
		f:close()
	end
	local wanted = {
		['ItemPool_BigBoomBlaster.ItemPool_BigBoomBlaster'] = true,
		['ItemPool_Pills_Upper.ItemPool_Pills_Upper'] = true,
		['ItemPool_Pills_Downer.ItemPool_Pills_Downer'] = true,
	}
	local dropDownData = { }
	for address, name in fileStr:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
		if wanted[name] then
			local prettyName = name:match('^[%w_]-%.ItemPool_(.-)$'):gsub('_', ' ')
			---- this will make the names look like this: "BigBoomBlaster", "Pills Downer"
			---- 	But you can just use name if this doesn't match enough.
			---- Here we setup a table to call concat on.
			table.insert(dropDownData, address..':'..prettyName)
		end
	end
	local mr = AddressList.getMemoryRecordByDescription('The MR description with the drop down list')
	---- or use: AddressList.getMemoryRecordByID(id)
	mr.DropDownList.Text = table.concat(dropDownData, '\n')
	thread.terminate()
end
createThread(getDumpData)
[DISABLE]
This is awesome. Thank you so much for this. Will definitely give u credit for all this in the table. I love the smaller names and thank you for the comments to help me learn and understand it.

Paul44
RCE Fanatics
RCE Fanatics
Posts: 887
Joined: Thu Jul 27, 2017 9:02 am
Reputation: 566

Re: Searching .txt files and print to drop down. Even possible?

Post by Paul44 »

@Yellowsub: tried to pm you, but you have disabled that feature... :oops:

anyways: it looks like you got the solution already. as for lua references, try to get your hands on these:
* Beginning Lua Programming
* Programming in lua (1st &) 2nd edition

i haven't actually "read" these per se - only picked up some specific discussions - but i do like "the style of writing"...

ps: if you search @CEF, i recall #atom0s posting an article on all sorts of lua sources (most, if not all, links still alive and kicking)

oops, almost forgot: you also might have a look at [Cygwin] to get a working Lua environment for Win...
(aside from CE's Lua window)

oldstuff
Expert Cheater
Expert Cheater
Posts: 477
Joined: Thu Apr 06, 2017 6:53 pm
Reputation: 188

Re: Searching .txt files and print to drop down. Even possible?

Post by oldstuff »

Paul44 wrote:
Fri Dec 24, 2021 7:52 am
@Yellowsub: tried to pm you, but you have disabled that feature... :oops:

anyways: it looks like you got the solution already. as for lua references, try to get your hands on these:
* Beginning Lua Programming
* Programming in lua (1st &) 2nd edition

i haven't actually "read" these per se - only picked up some specific discussions - but i do like "the style of writing"...

ps: if you search @CEF, i recall #atom0s posting an article on all sorts of lua sources (most, if not all, links still alive and kicking)

oops, almost forgot: you also might have a look at [Cygwin] to get a working Lua environment for Win...
(aside from CE's Lua window)
Ahh right I forgot about that, I'll turn that back on now. Also thank you for all the info, I'll look into all that as it is something I do really want to learn more about.

Thanks again for all the help. I really appreciate all you guys and how helpful you all are

oldstuff
Expert Cheater
Expert Cheater
Posts: 477
Joined: Thu Apr 06, 2017 6:53 pm
Reputation: 188

Re: Searching .txt files and print to drop down. Even possible?

Post by oldstuff »

ShyTwig16 wrote:
Fri Dec 24, 2021 1:34 am
I'd try it like this, it might speed things up just to get if off the main thread.

Code: Select all

{$lua}
[ENABLE]
local function getDumpData(thread)
	local fileStr
	local f, err = io.open([[C:\[Borderlands3.exe] ObjectsDump.txt]], 'r')
	if err then
		error(err)
	elseif f then
		fileStr = f:read('*all')
		---- close file right after reading so if there's an error the file won't be stuck open.
		f:close()
	end
	local wanted = {
		['ItemPool_BigBoomBlaster.ItemPool_BigBoomBlaster'] = true,
		['ItemPool_Pills_Upper.ItemPool_Pills_Upper'] = true,
		['ItemPool_Pills_Downer.ItemPool_Pills_Downer'] = true,
	}
	local dropDownData = { }
	for address, name in fileStr:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
		if wanted[name] then
			local prettyName = name:match('^[%w_]-%.ItemPool_(.-)$'):gsub('_', ' ')
			---- this will make the names look like this: "BigBoomBlaster", "Pills Downer"
			---- 	But you can just use name if this doesn't match enough.
			---- Here we setup a table to call concat on.
			table.insert(dropDownData, address..':'..prettyName)
		end
	end
	local mr = AddressList.getMemoryRecordByDescription('The MR description with the drop down list')
	---- or use: AddressList.getMemoryRecordByID(id)
	mr.DropDownList.Text = table.concat(dropDownData, '\n')
	thread.terminate()
end
createThread(getDumpData)
[DISABLE]
Hey bud, 1 last question for you and i think i have this thing working the way i need. This part in your code:

Code: Select all

	local dropDownData = { }
	for address, name in fileStr:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
		if wanted[name] then
			local prettyName = name:match('^[%w_]-%.ItemPool_(.-)$'):gsub('_', ' ')
			---- this will make the names look like this: "BigBoomBlaster", "Pills Downer"
			---- 	But you can just use name if this doesn't match enough.
			---- Here we setup a table to call concat on.
			table.insert(dropDownData, address..':'..prettyName)
		end
	end
How can i add more search terms?

These are the lines i need to add:
['Itempool_GrenadeMods_AllAndDLC.Itempool_GrenadeMods_AllAndDLC'] = true,
As you can see here Itempool the P is not capitalized in the dump so it wont grab these address's

and here:
['DA_ItemPool_Test.DA_ItemPool_Test'] = true,
The dump adds DA_ so its missing these as well..

How would i go about adding more search terms so i can get these to populate as well.. I tried looking online and doing a few things like this:

Code: Select all

	local dropDownData = { }
	for address, name in fileStr:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
		if wanted[name] then
			local prettyName = name:match('^[%w_]-%.ItemPool_(.-)$'):gsub('_', ' ')
		else if local prettyName = name:match('^[%w_]-%.ItemPool_(.-)$'):gsub('_', ' ')	
			---- this will make the names look like this: "BigBoomBlaster", "Pills Downer"
			---- 	But you can just use name if this doesn't match enough.
			---- Here we setup a table to call concat on.
			table.insert(dropDownData, address..':'..prettyName)
		end
	end
Obviously this didnt work lol.. i tried a few other things as well.. but nothing seems to work. Im sure its something simple, Just cant seem to figure it out.. Thanks again for your time.

ShyTwig16
Expert Cheater
Expert Cheater
Posts: 335
Joined: Thu Apr 06, 2017 7:14 pm
Reputation: 20

Re: Searching .txt files and print to drop down. Even possible?

Post by ShyTwig16 »

Try this:

Code: Select all

	local dropDownData = { }
	for address, name in fileStr:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
		if wanted[name] then
			local prettyName = name:match('^[%w_]-%.[DA_]*Item[pP]ool_(.-)$'):gsub('_', ' ')
			---- this will make the names look like this: "BigBoomBlaster", "Pills Downer"
			---- 	But you can just use name if this doesn't match enough.
			---- Here we setup a table to call concat on.
			table.insert(dropDownData, address..':'..prettyName)
		end
	end
You can even check "prettyName" and use that or name if it doesn't match, you could also use match again with a different pattern.

Code: Select all

	local dropDownData = { }
	for address, name in fileStr:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
		if wanted[name] then
			local prettyName = name:match('^[%w_]-%.[DA_]*Item[pP]ool_(.-)$')
			---- this will make the names look like this: "BigBoomBlaster", "Pills Downer"
			---- 	But you can just use name if this doesn't match enough.
			---- Here we setup a table to call concat on.
			if prettyName then
				table.insert(dropDownData, address..':'..prettyName:gsub('_', ' '))
			else
				table.insert(dropDownData, address..':'..name)
			end
		end
	end

Code: Select all

	local dropDownData = { }
	for address, name in fileStr:gmatch('%[%x-%]%s(%x-)%sItemPoolData%s.-([%w_]*%.[%w_]*)') do
		if wanted[name] then
			local prettyName = name:match('^[%w_]-%.[DA_]*Item[pP]ool_(.-)$')
			---- this will make the names look like this: "BigBoomBlaster", "Pills Downer"
			---- 	But you can just use name if this doesn't match enough.
			---- Here we setup a table to call concat on.
			if prettyName then
				table.insert(dropDownData, address..':'..prettyName:gsub('_', ' '))
			else
				prettyName = name:match('^[%w_]-%.(.-)$')
				if prettyName then
					table.insert(dropDownData, address..':'..prettyName:gsub('_', ' '))
				else
					table.insert(dropDownData, address..':'..name)
				end
			end
		end
	end

Post Reply

Who is online

Users browsing this forum: No registered users